From owner-freebsd-current Mon Nov 18 22: 7: 6 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 39AF437B401 for ; Mon, 18 Nov 2002 22:07:05 -0800 (PST) Received: from pintail.mail.pas.earthlink.net (pintail.mail.pas.earthlink.net [207.217.120.122]) by mx1.FreeBSD.org (Postfix) with ESMTP id E721E43E75 for ; Mon, 18 Nov 2002 22:07:04 -0800 (PST) (envelope-from tlambert2@mindspring.com) Received: from pool0077.cvx21-bradley.dialup.earthlink.net ([209.179.192.77] helo=mindspring.com) by pintail.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 18E1XK-0003jH-00; Mon, 18 Nov 2002 22:07:02 -0800 Message-ID: <3DD9D4AE.41752FF8@mindspring.com> Date: Mon, 18 Nov 2002 22:05:34 -0800 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Brian Smith Cc: Daniel Eischen , "current@freebsd.org" Subject: Re: Are SysV semaphores thread-safe on CURRENT? References: <20021119043130.WWGB397.mail1-0.chcgil.ameritech.net@bbs> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Brian Smith wrote: > >Sure SysV semaphores are thread-safe. When a thread blocks on > >one, the entire process blocks (no threads run). You won't > >get any safer than that ;-) > > Yikes that isn't good. Is that only in STABLE? or does CURRENT > do that as well? I guess I'll have to protect the semop() call > with a pthread mutex to prevent two threads locking a single > semaphore by the same process (creating a deadlock situation). > > Is this the recommended method of preventing these problems? Yeah: don't make blocking system calls for which there are no asynchronous equivalents. Use the POSIX interfaces for use by pthreads, instead. > (the SysV semaphore is protecting shared memory accessed by > multiple processes). > > Thanks for the info... it explains alot! Use mmap of a backing-store file, and then use file locking to do record locking in the shared memory segment. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message