From owner-freebsd-current  Mon Nov 18 20:31:39 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 6FE2537B401
	for <current@FreeBSD.ORG>; Mon, 18 Nov 2002 20:31:38 -0800 (PST)
Received: from mail1-0.chcgil.ameritech.net (mail1-0.chcgil.ameritech.net [206.141.192.68])
	by mx1.FreeBSD.org (Postfix) with ESMTP id B06E843E77
	for <current@FreeBSD.ORG>; Mon, 18 Nov 2002 20:31:37 -0800 (PST)
	(envelope-from dbsoft@technologist.com)
Received: from bbs ([67.39.182.225]) by mail1-0.chcgil.ameritech.net
          (InterMail vM.4.01.02.17 201-229-119) with ESMTP
          id <20021119043130.WWGB397.mail1-0.chcgil.ameritech.net@bbs>;
          Mon, 18 Nov 2002 22:31:30 -0600
From: "Brian Smith" <dbsoft@technologist.com>
To: "Daniel Eischen" <eischen@pcnet1.pcnet.com>
Cc: "current@freebsd.org" <current@FreeBSD.ORG>
Date: Mon, 18 Nov 2002 22:31:28 -0600
X-Mailer: PMMail 2000 Standard (2.20.2661) For Windows 2000 (5.1.2600)
In-Reply-To: <Pine.GSO.4.10.10211182130110.12758-100000@pcnet1.pcnet.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Subject: Re: Are SysV semaphores thread-safe on CURRENT?
Message-Id: <20021119043130.WWGB397.mail1-0.chcgil.ameritech.net@bbs>
Sender: owner-freebsd-current@FreeBSD.ORG
Precedence: bulk
List-ID: <freebsd-current.FreeBSD.ORG>
List-Archive: <http://docs.freebsd.org/mail/> (Web Archive)
List-Help: <mailto:majordomo@FreeBSD.ORG?subject=help> (List Instructions)
List-Subscribe: <mailto:majordomo@FreeBSD.ORG?subject=subscribe%20freebsd-current>
List-Unsubscribe: <mailto:majordomo@FreeBSD.ORG?subject=unsubscribe%20freebsd-current>
X-Loop: FreeBSD.ORG

On Mon, 18 Nov 2002 21:33:38 -0500 (EST), Daniel Eischen wrote:

>[ I assume you mean semop, semctl, not sema_* or sem_* ]

Yes ... semop() specifically is causing the problems...

>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?

(the SysV semaphore is protecting shared memory accessed by
multiple processes).

Thanks for the info... it explains alot!

Brian Smith




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message