Is someone aware of problem with SytemV semaphores?

From: Alexander Leidinger <Alexander_at_Leidinger.net>
Date: Mon, 18 Jun 2007 12:34:13 +0200
Hi,

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  
on request.

Bye,
Alexander.

-- 
http://www.Leidinger.net    Alexander _at_ Leidinger.net: PGP ID = B0063FE7
http://www.FreeBSD.org       netchild _at_ FreeBSD.org  : PGP ID = 72077137
Received on Mon Jun 18 2007 - 08:34:38 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:12 UTC