two egcs (gcc ?) bugs for you

Martin von Loewis martin@mira.isdn.cs.tu-berlin.de
Thu Nov 5 13:27:00 GMT 1998


> extern long realtime;
> 
> void rttask1(void) {
> 	  int count;
> 	  for (count=1;;count++)
>    {
> 		   print(count, 800+80);
>      RTTASK1.time = realtime  +  606200;
> 		   quantumDone();
>    }
> }
> 
> long realtime is constantly changed by the timer interrupt.
> 
> This doesn't work like I had expected.

This is what 'volatile' is for. Specifying

extern volatile long realtime;

tells the compiler that volatile may change at any time, and therefore
has to be reloaded from memory every time it is accessed.

Hope this helps,
Martin



More information about the Gcc-bugs mailing list