From owner-freebsd-current@FreeBSD.ORG Mon Jun 18 10:34:38 2007 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id F25C216A421 for ; Mon, 18 Jun 2007 10:34:38 +0000 (UTC) (envelope-from alexander@leidinger.net) Received: from redbull.bpaserver.net (redbullneu.bpaserver.net [213.198.78.217]) by mx1.freebsd.org (Postfix) with ESMTP id AD37413C469 for ; Mon, 18 Jun 2007 10:34:38 +0000 (UTC) (envelope-from alexander@leidinger.net) Received: from outgoing.leidinger.net (p54A5E4EA.dip.t-dialin.net [84.165.228.234]) by redbull.bpaserver.net (Postfix) with ESMTP id D69DC2E13F for ; Mon, 18 Jun 2007 12:34:31 +0200 (CEST) Received: from webmail.leidinger.net (webmail.Leidinger.net [192.168.1.102]) by outgoing.leidinger.net (Postfix) with ESMTP id E74E45B49F3 for ; Mon, 18 Jun 2007 12:34:13 +0200 (CEST) Received: (from www@localhost) by webmail.leidinger.net (8.13.8/8.13.8/Submit) id l5IAYD0E009552 for current@freebsd.org; Mon, 18 Jun 2007 12:34:13 +0200 (CEST) (envelope-from Alexander@Leidinger.net) Received: from pslux.cec.eu.int (pslux.cec.eu.int [158.169.9.14]) by webmail.leidinger.net (Horde MIME library) with HTTP; Mon, 18 Jun 2007 12:34:13 +0200 Message-ID: <20070618123413.3xh05qfuo0kk4ww4@webmail.leidinger.net> X-Priority: 3 (Normal) Date: Mon, 18 Jun 2007 12:34:13 +0200 From: Alexander Leidinger To: current@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable User-Agent: Internet Messaging Program (IMP) H3 (4.1.4) / FreeBSD-7.0 X-BPAnet-MailScanner-Information: Please contact the ISP for more information X-BPAnet-MailScanner: Found to be clean X-BPAnet-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-0.085, required 8, BAYES_40 -0.18, DKIM_POLICY_SIGNSOME 0.00, RDNS_DYNAMIC 0.10) X-BPAnet-MailScanner-From: alexander@leidinger.net X-Spam-Status: No Cc: Subject: Is someone aware of problem with SytemV semaphores? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jun 2007 10:34:39 -0000 Hi, a friend works on a benchmark program for IPC. One kind of IPC he =20 tries is SystemV shm. He uses SystemV semaphores to build mutexes and =20 condition variables for process synchronisation. He had a problem with =20 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 =20 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 =20 (other values are ruled out, as there are only increases by one or =20 decreases by one and it is not increased if it is already 1) have a =20 value of 2. As a workaround he switched to setting the value (semvcl with SETVAL) =20 instead of doing a semop with +1. This seems to work so far, but =20 doesn't explain why we see this strange behavior. I tested this on -current with gcc 4.2. The test program is available =20 on request. Bye, Alexander. --=20 http://www.Leidinger.net Alexander @ Leidinger.net: PGP ID =3D B0063FE7 http://www.FreeBSD.org netchild @ FreeBSD.org : PGP ID =3D 72077137