On Thu, Oct 22, 2009 at 11:08 PM, Andrew Gallatin <galla...@cs.duke.edu> wrote: > Hi, > > We're designing some software which has to lock access to > shared memory pages between several processes, and has to > run on Linux, Solaris, and FreeBSD. We were planning to > have the lock be a pthread_mutex_t residing in the > shared memory page. This works well on Linux and Solaris, > but FreeBSD (at least 7-stable) does not support > PTHREAD_PROCESS_SHARED mutexes. > > We then moved on to posix semaphores. Using sem_wait/sem_post > with the sem_t residing in a shared page seems to work on > all 3 platforms. However, the FreeBSD (7-stable) man page > for sem_init(3) has this scary text regarding the pshared > value: > > The sem_init() function initializes the unnamed semaphore pointed to by > sem to have the value value. A non-zero value for pshared specifies a > shared semaphore that can be used by multiple processes, which this > implementation is not capable of. > > Is this text obsolete? Or is my test just "getting lucky"? > > Is there recommended way to do this? > > Thanks, > > Drew
Hi Andrew, This works in Linux is because Linux defines sem_t as a struct type(or union, IIRC), while our sem_t is a pointer type (with more state kept in the pointed struct). SYSV semaphores seems the way to go... _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"