Re: [OT] volatile keyword

2005-08-26 Thread Alan Cox
On Iau, 2005-08-25 at 15:26 -0600, Christopher Friesen wrote: > > do > > expires = timr->it_timer.expires; > > while ((volatile long) (timr->it_timer.expires) != expires); > > > > Seems it's casting the value, not the pointer. > > Someone else will have to give the definitive answer, but it l

Re: [OT] volatile keyword

2005-08-26 Thread Paolo Ornati
On Thu, 25 Aug 2005 13:44:55 -0700 (PDT) Vadim Lobanov <[EMAIL PROTECTED]> wrote: > int main (void) { > pthread_t other; > > data.lock = 1; > data.value = 1; > pthread_create(&other, NULL, thread, NULL); > while ((volatile unsigned long)(data.lock)); > printf("Value is %lu

Re: [OT] volatile keyword

2005-08-25 Thread Christopher Friesen
Vadim Lobanov wrote: I figured it was something along these lines. In that case, is the following code (from kernel/posix-timers.c) really doing the right thing? do expires = timr->it_timer.expires; while ((volatile long) (timr->it_timer.expires) != expires); Seems it's casting the value,

Re: [OT] volatile keyword

2005-08-25 Thread Vadim Lobanov
On Thu, 25 Aug 2005, Christopher Friesen wrote: > Vadim Lobanov wrote: > > > I'm positive I'm doing something wrong here. In fact, I bet it's the > > volatile cast within the loop that's wrong; but I'm not sure how to do > > it correctly. Any help / pointers / discussion would be appreciated. > >

Re: [OT] volatile keyword

2005-08-25 Thread Christopher Friesen
Vadim Lobanov wrote: I'm positive I'm doing something wrong here. In fact, I bet it's the volatile cast within the loop that's wrong; but I'm not sure how to do it correctly. Any help / pointers / discussion would be appreciated. You need to cast is as dereferencing a volatile pointer. Chris

[OT] volatile keyword

2005-08-25 Thread Vadim Lobanov
Hi, The recent discussion on the list concerning memory barriers and write ordering took a side-trip to the volatile keyword, especially its correct / incorrect usage. Someone posted a link to the LKML archives, in which the argument is made that it is best to keep 'volatile' _out_ of variable and