[comp.sys.sequent] parallel file open

phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) (11/13/90)

I have run into what looks like a bug in UNIX or Dynix.  Can anyone tell me
if they have seen this before?

I start up two processes in parallel.  Each process is supposed to open the
same file for writing with truncation.  However the results are inconsistent.
Consider this csh command:

( echo 1 >! test ) & ( echo 2 >! test ) &

What should I expect to happen?  I usually see only the number 2 written
to the file, but sometimes I see BOTH 1 and 2 written.  It seems as if
what is happening is that the file is being truncated and then appended,
and that there is only one distinct file position instead of two separate
ones.  This happens only about 4% of the time, which is consistent with
mere timing.

I could only get this problem to occur on the Sequent here, but not on
Convex or VAX (but I only tried the above command as a test 100 times).
If this is an expected behaviour of UNIX, then I really need not bother
with any more testing.

I would like to find a way to syncronize two or more processes in the
following way.  I only want one of the processes to run.  The others
should detect that they don't need to run, should they happen to get
started up in parallel.
-- 

--Phil Howard, KA9WGN-- | Individual CHOICE is fundamental to a free society
<phil@ux1.cso.uiuc.edu> | no matter what the particular issue is all about.