diff options
author | avg <avg@FreeBSD.org> | 2013-07-09 09:01:44 +0000 |
---|---|---|
committer | avg <avg@FreeBSD.org> | 2013-07-09 09:01:44 +0000 |
commit | 44c288e1496cf711ed470b921a3dc028c75fffe3 (patch) | |
tree | 0e3df933b35a6abe659511e476c5f9d33eea660e | |
parent | 22e327d0053fd6094d76854a6c73d640ef59799a (diff) | |
download | FreeBSD-src-44c288e1496cf711ed470b921a3dc028c75fffe3.zip FreeBSD-src-44c288e1496cf711ed470b921a3dc028c75fffe3.tar.gz |
should_yield: protect from td_swvoltick being uninitialized or too stale
The distance between ticks and td_swvoltick should be calculated as
an unsigned number. Previously we could end up comparing a negative
number with hogticks in which case should_yield() would give incorrect
answer.
We should probably ensure that td_swvoltick is properly initialized.
Sponsored by: HybridCluster
MFC after: 5 days
-rw-r--r-- | sys/kern/kern_synch.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 84b1c61..fb9c9bf 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -581,7 +581,7 @@ int should_yield(void) { - return (ticks - curthread->td_swvoltick >= hogticks); + return ((unsigned int)(ticks - curthread->td_swvoltick) >= hogticks); } void |