kernel: prevent alarm(2) from returning instantly when the tick timer wraps. (from erik quanstros alarmwrap patch)

This commit is contained in:
cinap_lenrek 2013-05-21 19:31:41 +02:00
parent f6833ce428
commit 92b550d665

View file

@ -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;