[OSy] Kompilovanie testov
Ondrej Palkovsky
ondrap at penguin.cz
Fri Nov 5 11:58:16 CET 2004
Ale neee....
Problem je v tom, ze mezi current->state=TS_SLEEP a while(!expired) muze
vyexpirovat timer (ktery samozrejme volatile je). Jestlize se tak stane,
pak schedule() nezpusobi uspani threadu, ale projde, protoze
current->state pripadny timer prepne do TS_RUN. Jenomze compiler
pravdepodobne zjisti, ze while (!expired) neni current->state ovlivneno,
takze to klidne da az za tu podminku. Jenomze kdyz timer vyexpiruje po
'expired' a pred 'current->state=TS_SLEEP', tak nasledujici schedule()
thread uspi a uz ho nema nikdo co vzbudit....
Ondrej Palkovsky
On Fri, 5 Nov 2004, Petr Tuma wrote:
> > Taky mi prijde optimalizace -O2 pomerne drasticka. Vcera jsem hledal bug,
> > a s nejvyssi pravdepodobnosti se mi nasledujici kod:
> > timer_start(&tmr);
> > current->state = TS_SLEEP;
> > while (!expired) {
> > schedule();
> > current->state = TS_SLEEP;
> > }
> > current->state = TS_RUN;
> >
> > prelozil na:
> > timer_start(&tmr);
> > while (!expired) {
> > current->state = TS_SLEEP;
> > schedule();
> > }
> > current->state = TS_RUN;
>
More information about the NSWI004
mailing list