From owner-freebsd-hackers Wed Oct 7 07:43:23 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id HAA01756 for freebsd-hackers-outgoing; Wed, 7 Oct 1998 07:43:23 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from pcnet1.pcnet.com (pcnet1.pcnet.com [204.213.232.3]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id HAA01743 for ; Wed, 7 Oct 1998 07:43:20 -0700 (PDT) (envelope-from eischen@vigrid.com) Received: (from eischen@localhost) by pcnet1.pcnet.com (8.8.7/PCNet) id KAA12225; Wed, 7 Oct 1998 10:43:10 -0400 (EDT) Date: Wed, 7 Oct 1998 10:43:10 -0400 (EDT) From: Daniel Eischen Message-Id: <199810071443.KAA12225@pcnet1.pcnet.com> To: dbeck@freesoft.hu, freebsd-hackers@FreeBSD.ORG Subject: Re: pthreads and semctl problem Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > This is the first time I post to this list. > Big hello to everyone :) > > I started to port an application from DEC Unix to FreeBSD and > an unexpected problem cropped out. The app runs on 3 threads > and uses system V semaphores for synchronizing access to a > shared memory block between unrelated processes. (It > communicates with unrelated processes using that shared > memory block.) There are a couple of other reasons for why > I couldn't use pthread mutexes in this case. > > The problem is I found that when I block one thread with the > semop call, all the other threads will be blocked. Why ? Is it > a problem in the C library or the kernel ? > > I compiled the program with the -pthread flag. Maybe I missed > some other flags or switches ? > > The same code works under DEC and Linux :( FreeBSD pthreads currently doesn't wrap semop(), so any attempt to wait for the semaphore will hang. It doesn't look hard to fix the threads library for semop; I might try implementing this when I get some free time. You can add a hack to your application to make it work by using the IPC_NOWAIT flag on the semop call, and then if the thread doesn't get the semaphore, issue a pthread_yield() which will let other threads run. Someone else reported this problem also. Search the GNATS problem database to see if it's there. If not, submit a PR so it doesn't get lost. Dan Eischen eischen@vigrid.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message