kernel: make sure procalarm() remaining time doesnt become negative
This commit is contained in:
parent
01b4c2a63d
commit
5d9deb77e9
1 changed files with 9 additions and 3 deletions
|
@ -63,14 +63,20 @@ procalarm(ulong time)
|
|||
Proc **l, *f;
|
||||
ulong when, old;
|
||||
|
||||
when = MACHP(0)->ticks;
|
||||
old = up->alarm;
|
||||
if(old)
|
||||
old = tk2ms(old - MACHP(0)->ticks);
|
||||
if(old) {
|
||||
old -= when;
|
||||
if((long)old > 0)
|
||||
old = tk2ms(old);
|
||||
else
|
||||
old = 0;
|
||||
}
|
||||
if(time == 0) {
|
||||
up->alarm = 0;
|
||||
return old;
|
||||
}
|
||||
when = ms2tk(time)+MACHP(0)->ticks;
|
||||
when += ms2tk(time);
|
||||
if(when == 0)
|
||||
when = 1;
|
||||
|
||||
|
|
Loading…
Reference in a new issue