Subject: Re: Bug in timeout()/untimeout() ?
To: Manuel Bouyer <bouyer@antioche.lip6.fr>
From: enami tsugutomo <enami@sm.sony.co.jp>
List: tech-kern
Date: 04/14/2000 11:27:51
Manuel Bouyer <bouyer@antioche.lip6.fr> writes:
> Let's look at softclock() (from kern/clock.c):
> while ((c = calltodo.c_next) != NULL && c->c_time <= 0) {
> func = c->c_func;
> arg = c->c_arg;
> calltodo.c_next = c->c_next;
> c->c_next = callfree;
> callfree = c;
> splx(s);
> (*func)(arg);
> (void) splhigh();
> }
>
> My theory is based on the fact that c_next is not declared volatile, so
> calltodo.c_next may be cached in a register and not re-read from memory
> in the next iteration.
Since there is a function call between each test of calltodo.c_next,
the sane compiler shouldn't assume it can be cached. At least 1.4.2
compiler wit -O2 generates following assember code and it looks like
doing memory access each time.
583 .globl _softclock
584 .type _softclock,@function
585 _softclock:
586 pushl %ebp
:
597 movl _calltodo,%edx
598 movl %ecx,%edi
599 notl %edi
600 testl %edx,%edx
601 je L178
602 .align 2,0x90
603 L184:
604 cmpl $0,12(%edx)
605 jg L178
:
618 call _Xspllower
619 L182:
620 pushl %ebx
621 call *%esi
622 addl $4,%esp
623 movl _cpl,%eax
624 orl _imask+4,%eax
625 movl %eax,_cpl
626 movl _calltodo,%edx
627 testl %edx,%edx
628 jne L184
629 L178:
:
enami.