kernel: prevent alarm(2) from returning instantly when the tick timer wraps. (from erik quanstros alarmwrap patch)
This commit is contained in:
parent
f6833ce428
commit
92b550d665
1 changed files with 5 additions and 3 deletions
|
@ -16,7 +16,7 @@ alarmkproc(void*)
|
|||
for(;;){
|
||||
now = MACHP(0)->ticks;
|
||||
qlock(&alarms);
|
||||
while((rp = alarms.head) && rp->alarm <= now){
|
||||
while((rp = alarms.head) && (long)(now - rp->alarm) >= 0){
|
||||
if(rp->alarm != 0L){
|
||||
if(canqlock(&rp->debug)){
|
||||
if(!waserror()){
|
||||
|
@ -48,7 +48,7 @@ checkalarms(void)
|
|||
p = alarms.head;
|
||||
now = MACHP(0)->ticks;
|
||||
|
||||
if(p && p->alarm <= now)
|
||||
if(p != nil && (long)(now - p->alarm) >= 0)
|
||||
wakeup(&alarmr);
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,8 @@ procalarm(ulong time)
|
|||
return old;
|
||||
}
|
||||
when = ms2tk(time)+MACHP(0)->ticks;
|
||||
if(when == 0)
|
||||
when = 1;
|
||||
|
||||
qlock(&alarms);
|
||||
l = &alarms.head;
|
||||
|
@ -82,7 +84,7 @@ procalarm(ulong time)
|
|||
if(alarms.head) {
|
||||
l = &alarms.head;
|
||||
for(f = *l; f; f = f->palarm) {
|
||||
if(f->alarm > when) {
|
||||
if((long)(f->alarm - when) >= 0) {
|
||||
up->palarm = f;
|
||||
*l = up;
|
||||
goto done;
|
||||
|
|
Loading…
Reference in a new issue