Re: question on semantics

2005-05-04 Thread Chris Friesen
Mike Stump wrote: On May 4, 2005, at 12:47 PM, Chris Friesen wrote: One problem with using volatile is that it can destroy performance. Gosh, I was going to elaborate and give the more complete answer, but decided against it, I was wrong. Heh...sorry. I've been trying to figure out who's respo

Re: question on semantics

2005-05-04 Thread Mike Stump
On May 4, 2005, at 12:47 PM, Chris Friesen wrote: One problem with using volatile is that it can destroy performance. Gosh, I was going to elaborate and give the more complete answer, but decided against it, I was wrong. only need to really read it in from memory the first time after I take a

Re: question on semantics

2005-05-04 Thread Chris Friesen
Diego Novillo wrote: On Wed, May 04, 2005 at 02:47:14PM -0600, Chris Friesen wrote: In multiple messages to comp.programming.threads he has stated that volatile is not necessary between threads if you use the posix locking functions, and in fact that one of the main purposes of the posix locks

Re: question on semantics

2005-05-04 Thread Diego Novillo
On Wed, May 04, 2005 at 02:47:14PM -0600, Chris Friesen wrote: > In multiple messages to comp.programming.threads he has stated that > volatile is not necessary between threads if you use the posix locking > functions, and in fact that one of the main purposes of the posix locks > is to ensure

Re: question on semantics

2005-05-04 Thread Chris Friesen
Diego Novillo wrote: On Wed, May 04, 2005 at 01:47:20PM -0600, Chris Friesen wrote: Also, what about threads and pthread locking? Do I need to use volatile there? If not, then what about using pthread locking between processes? Things will only break for you when GCC pulls in function bodies a

Re: question on semantics

2005-05-04 Thread David Daney
Chris Friesen wrote: Mike Stump wrote: It is safer to. People might compile your whole app at once for better optimization, and the compiler might be just smart enough to optimize it away. One problem with using volatile is that it can destroy performance. I only need to really read it in

Re: question on semantics

2005-05-04 Thread Diego Novillo
On Wed, May 04, 2005 at 04:15:41PM -0400, Diego Novillo wrote: > Same reply I gave you before. As long as the address of your > shared memory is outside of the function and the pointer is > itself a global variable or gets its value from the heap, then > calls to functions that cannot be inlined

Re: question on semantics

2005-05-04 Thread Diego Novillo
On Wed, May 04, 2005 at 01:47:20PM -0600, Chris Friesen wrote: > Also, what about threads and pthread locking? Do I need to use volatile > there? If not, then what about using pthread locking between processes? > Same reply I gave you before. As long as the address of your shared memory is ou

Re: question on semantics

2005-05-04 Thread Chris Friesen
Mike Stump wrote: On May 4, 2005, at 10:59 AM, Chris Friesen wrote: If I share memory between two processes, and protect access to the memory using standard locking (fcntl(), for instance), do I need to specify that the memory is volatile? It is safer to. People might compile your whole app

Re: question on semantics

2005-05-04 Thread Mike Stump
On May 4, 2005, at 10:59 AM, Chris Friesen wrote: I'm not sure who I should address this to...I hope this is correct. If I share memory between two processes, and protect access to the memory using standard locking (fcntl(), for instance), do I need to specify that the memory is volatile? It is

Re: question on semantics

2005-05-04 Thread chris jefferson
Chris Friesen wrote: I'm not sure who I should address this to...I hope this is correct. If I share memory between two processes, and protect access to the memory using standard locking (fcntl(), for instance), do I need to specify that the memory is volatile? Or is the fact that I'm using fcnt

Re: question on semantics

2005-05-04 Thread Diego Novillo
On Wed, May 04, 2005 at 11:59:49AM -0600, Chris Friesen wrote: > Without the locks, the compiler is free to only load *b once (and in > fact gcc does so). Is the addition of the locks sufficient to force *b > to be re-read each time, or do I need to declare it as > As long as you keep 'b' poin