Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Nov 2002 22:05:34 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Brian Smith <dbsoft@technologist.com>
Cc:        Daniel Eischen <eischen@pcnet1.pcnet.com>, "current@freebsd.org" <current@FreeBSD.ORG>
Subject:   Re: Are SysV semaphores thread-safe on CURRENT?
Message-ID:  <3DD9D4AE.41752FF8@mindspring.com>
References:  <20021119043130.WWGB397.mail1-0.chcgil.ameritech.net@bbs>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3DD9D4AE.41752FF8>