RE: File descriptors and Clones.

From: David Schwartz (davids@webmaster.com)
Date: Wed May 24 2000 - 16:02:30 EST


> > If you absolutely need things to happen in a particular
> > order, you must
> > take steps to enforce it. Otherwise, all bets are off.

> for example barrier(); !?!
>
> Can that happen in user mode too? If yes, is there a barrier() function
> in user mode?
>
> Reto

        As it happens, on x86, the compiler is the only thing that can break strict
sequencing of memory accesses. So all you need is a 'barrier' between the
two writes, and all the barrier has to do is force the compiler to issue one
write to memory before the other.

        On other hardware platforms, this may not be enough. There may exist write
buffers or prefetches that need to be flushed or invalidated to make sure
that the writes aren't visibile out of order on another CPU.

        Safest thing to do in user space is just use the pthreads interface since
this takes care of all these details for you -- assuming you use it
properly. Least safe thing to do, but one that usually works until you try
to port your code to architectures other than x86, is to throw a bunch of
'volatile's around.

        DS

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed May 31 2000 - 21:00:12 EST