Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Aug 2000 08:23:49 -0400 (EDT)
From:      Peter Dufault <dufault@hda.com>
To:        hackers@FreeBSD.ORG
Subject:   Re: IPC, shared memory, syncronization AND threads...
Message-ID:  <200008161223.IAA42181@hda.hda.com>
In-Reply-To: <200008152113.RAA39184@hda.hda.com> from Peter Dufault at "Aug 15, 2000 05:13:44 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
I've looked at the POSIX spec to find the right way to portably
implement low overhead process synchronization.

I think the right way is to add _POSIX_THREAD_PROCESS_SHARED support
so that mutexes can be shared between processes.

There is something vague about the spec.  I don't see that you can
reject "pthread_mutexattr_setpshared()" with EINVAL, and I don't
clearly see that the mutexes in existence after a fork are defined
to be a new set of mutexes with identical existing values.  I have
to assume they are as mutexes can be statically allocated and there
is no way to ensure they are in a shared region without sharing
pages happening to contain mutexes with that attribute of the new
process space with the old one.

Assuming unique mutexes after a fork unless they happen to be in
a shared region, you could create a mutex in shared memory, apply
pthread_mutexattr_setpshared() to it, and then have the usual
pthread_mutex_lock()/pthread_mutex_unlock() interface support the
high performance synchronization.

Peter

--
Peter Dufault (dufault@hda.com)   Realtime development, Machine control,
HD Associates, Inc.               Fail-Safe systems, Agency approval


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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200008161223.IAA42181>