[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gettimeofday seconds rollover problem?
- Date: Thu, 23 Feb 2006 13:52:26 +0100
- From: trauscher at loytec.com (Thomas Rauscher)
- Subject: gettimeofday seconds rollover problem?
> -----Original Message-----
> From: Joel Sherrill [mailto:joel.sherrill at oarcorp.com]
> Sent: Thursday, February 23, 2006 1:26 PM
> To: Thomas Rauscher
> Cc: rtems-users; Thomas Doerfler; Andrew Sinclair
> Subject: Re: gettimeofday seconds rollover problem?
> Thomas Rauscher wrote:
> >The following macro is used in the Linux kernel. It tells the
> >compiler that the asm statement globbers memory in an
> >unpredictable way. The compiler cannot schedule instructions
> >over this barrier and has to forget all memory values kept in
> >/* Optimization barrier */
> >/* The "volatile" is due to gcc bugs */
> >#define barrier() __asm__ __volatile__("": : :"memory")
> >I hope, this helps.
> Is this just a gcc 3.x issue or is it an issue with newer compilers.
I've seen this with gcc 3.4.
The compiler can delay stores to optimize CPU pipelining.
Then it is possible that a critical section is executed without having
back the memory location. I believe (though I'm not sure) that this
is even true for volatiles. This should be correct, as a C
compiler does not know about interrupts and threads.
I think this is the reason why Linux uses the barrier macros.
LOYTEC electronics GmbH