lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Let A and B be two sig_atomic_t values, each initialised to 0.
> 
> The reader of hook:
>   repeat {
>     read A
>     read hook
>     read B
>   } until (A == B);
> 
> The writer of hook:
>   let C = B + 1
>   B = C
>   write hook
>   A = C
> 
> This works as long as the writer is called no more than 2^16 times  
> between any read A and read B of a reader and as long as memory is  
> ordered (which it is for all uniprocessor systems).

Are you sure? Can't the compiler (not the processor) delay the actual
access in "read hook" until it needs it? Or maybe we can solve this with
a non-voodoo volatile in "hook"?

-- Roberto