Subject: Re: semaphore
To: None <sommerfeld@orchard.arlington.ma.us, sommerfeld@netbsd.org>
From: Simon J. Gerraty <sjg@crufty.net>
List: tech-kern
Date: 03/21/2002 10:12:32
> I thought one purpose of the newlock branch was (among other things)
> about improving the API to our locking primitives.  At least for folks
> who don't speak dutch, semaphores typically have a *HORRID* API.
> Which operation is "p" and which one is "v" again?

Yep, so my implementation provides:

void	sema_init(sema_t *sp, int cnt, const char *wmesg, int flags);
void	sema_clear(sema_t *sp);		/* shutdown */
void	sema_setflags(sema_t *sp, int flags);
int	sema_signal(sema_t *sp);	/* V() */
int	sema_signal_n(sema_t *sp, int n); /* V() * n */
void	sema_spinwait(sema_t *sp, int n); /* spin version of P() * n */
void	sema_wait(sema_t *sp);		/* sleep version of P() */
void	sema_wait_n(sema_t *sp, int n);	/* sleep version of P() * n */

#define sema_signal(sp) sema_signal_n((sp), 1)

Thanks
--sjg