Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Sep 2002 09:17:25 -0400 (EDT)
From:      Daniel Eischen <eischen@pcnet1.pcnet.com>
To:        Alfred Perlstein <bright@mu.org>
Cc:        standards@freebsd.org
Subject:   Re: sem_* API
Message-ID:  <Pine.GSO.4.10.10209170902240.4728-100000@pcnet1.pcnet.com>
In-Reply-To: <20020917061356.GH86737@elvis.mu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 16 Sep 2002, Alfred Perlstein wrote:
> * Daniel Eischen <eischen@pcnet1.pcnet.com> [020916 18:32] wrote:
> > [ switching to -standards if that's OK ]
> 
> That's fine, but please keep me on the cc list as I'm not subscribed
> to many lists right now.
> 
> > On Mon, 16 Sep 2002, Alfred Perlstein wrote:
> > 
> > > Does it make sense for these to actually be in libc?  This is
> > > because they can be used to inter-process syncronization, not
> > > just between threads...
> > 
> > Well, Solaris has them in librt (real-time) and not in libthread
> > or libpthread.  POSIX/Austin/SUSv3 define these to be part of the
> > real-time extensions also.
> > 
> > Since our other real-time stuff (sched_*) is in libc, I'd say they
> > really belong in libc.  There is an option for semaphores too
> > (_POSIX_SEMAPHORES); you probably want to define that if it isn't
> > already (<sys/unistd.h> I think).
> > 
> > Can they be implemented as standalone syscalls in libc, and then
> > wrapped by libc_r?  They needn't be wrapped at all in libpthread
> > unless we want to make them faster for the non-shared case.
> 
> Ok, so I'm going to put them into src/lib/libc/sys/sem.c. :)
> 
> Question, besideds removing the inclusion of pthread_private.h
> and axing the __weak_reference's, is any other special handling
> required?

Well, these should work without linking in libc_r/libpthread.
When in libc, there should be no references to pthread routines
unless it's really necessary, and in those cases it should only
be the stubbed routines.  All pthread references need to be
preceded with underscores for the reasons mentioned before
and because only the underscored versions exist as stubs in
libc (see libc/gen/_pthread_stubs.c).

For cancellation points, those at a minimum need to be in the
threaded libraries.

I'd implement the sem_* routines in libc as __sem_* with
weak references, so that the threaded libraries can use
_sem_* as the cancellation functions and override the
weak references (sem_* -> _sem_*).

So in libc:

	__weak_reference(sem_init, __sem_init);

	int
	__sem_init()...

and in libc_r:

	__weak_reference(sem_init, _sem_init);

	int
	_sem_init(...)
	{
		_thread_enter_cancellation_point();
		__sem_init(...);
		_thread_leave_cancellation_point();
	}


I'm not sure about whether or not to implement the non-shared
semaphores as library routines rather than keeping them as
system calls too.

-- 
Dan Eischen


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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.10.10209170902240.4728-100000>