Hi,
I got a problem trying to organize simple mutual exclusion for an arbitrary
number of processes using a semaphore, on HPUX and SunOS/Solaris it works fine.
The first process opens a file gets a semaphore using semget, initializes it
semctl operation SETVAL to 1, and forks 10 children (as a test), which write
into that file.
Before writing, the children perform operation -1 on the semaphore without
UNDO or NOWAIT. After writing, they perform op 1 (without UNDO again) and
exit.
To my knowledge, this should ensure that only one process at a time writes to
that file.
Under Linux, I get the contents of the test file (fopened with mode a+) messed
up. Any idea why it works under HPUX, SunOS, Solaris and not under Linux, too?
Thanks a lot in advance,
Lutz.
--
-------------------------------------------