[ntp:hackers] [Gpsd-dev] ntpd shm changes

Jon Schlueter jon.schlueter at gmail.com
Sun Mar 20 17:42:12 UTC 2011


On Sun, Mar 20, 2011 at 10:17 AM, tz <thomas at mich.com> wrote:
> On Sun, Mar 20, 2011 at 8:39 AM, Jon Schlueter <jon.schlueter at gmail.com> wrote:
>
>> I would tend to agree, the "Double checked locking is broken" debate would
>> hold in the realm as well.
>>
>> http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html
>
> I don't think double-checking can give any advantage over single-checking.
> You either need a locking mechanism, a way to disable interrupts
> (across all cores!), or use some kind of queuing/serialization
> mechanism.

I reference it since there has been a decent amount of information about what
can go wrong if you don't use some sort of locking to share a resource

http://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf

The following are places shared access without the use of a
synchronization mechanism will break
 * Instruction Ordering (compiler may do things with what you wrote to
change the ordering)
    code generation/ compiler optimization/ hardware optimization
 * volatile keyword may/may not do what you want it to do...  see
section 5 of the above document
 * memory caches on with a multi core processor

If you have not read this article or are familiar with this issue I
recommend taking the time to read
through Scott Meyers article before dismissing this as not being an
issue for working with a
shared memory segment between two apps wanting to exchange information.

Jon


More information about the hackers mailing list