Is someone aware of problem with SytemV semaphores?
Alexander at Leidinger.net
Mon Jun 18 10:34:39 UTC 2007
a friend works on a benchmark program for IPC. One kind of IPC he
tries is SystemV shm. He uses SystemV semaphores to build mutexes and
condition variables for process synchronisation. He had a problem with
it and I agreed to have a look at it.
The program is now in a state where I don't know why it is not
behaving as it is supposed to be. What is does:
- 2 processes, one generating messages, one consuming messages
- both lock a queue in shm (mutex via sysv-semaphore) when accessing it
- there is some signaling (via sysv-semaphore) in the edge cases
(queue full -> producer wants to add -> queue gets not full anymore,
and similar for the reading but empty case).
The problem is, at some point some semaphores which can only be 0 or 1
(other values are ruled out, as there are only increases by one or
decreases by one and it is not increased if it is already 1) have a
value of 2.
As a workaround he switched to setting the value (semvcl with SETVAL)
instead of doing a semop with +1. This seems to work so far, but
doesn't explain why we see this strange behavior.
I tested this on -current with gcc 4.2. The test program is available
http://www.Leidinger.net Alexander @ Leidinger.net: PGP ID = B0063FE7
http://www.FreeBSD.org netchild @ FreeBSD.org : PGP ID = 72077137
More information about the freebsd-current