System-wide mutexes and pthreads

Robert Collins
Wed Jun 12 13:19:00 GMT 2002

> -----Original Message-----
> From: 
> [] On Behalf Of Conrad Scott
> Sent: Thursday, 13 June 2002 4:28 AM
> To:;
> Subject: System-wide mutexes and pthreads
> Looking at the current pthread implementation on cygwin, it 
> seems that it
> doesn't support any system-wide synchronization mechanisms 
> (i.e. none of the
> synchronization primitives allow PTHREAD_PROCESS_SHARED and 
> there are no
> named semaphores). Before I go and use win32 semaphores in 
> the cygserver, is
> there something I'm missing?

You're missing nothing, but I can help a little here:

Cygserver coding guidelines:
1) Trust nothing. Don't trust Process ID's, access rights or anything
else. Always check via an alternate path if you are able to. 
2) Use pure win32 code wherever possible. I used pthread_once because I
could :}, but other than that you'll find it's all native objects. The
only other big exception being using domain sockets, and that's because
they are so dang useful for LPC.
3) The cygserver needs to be robust. It should never need to wait on a
user owned mutex or event, and if it absolutely has to wait on such a
thing should always use a timed wait call.
4) Latency. Try to get the most bang for each cygserver LPC call. It's
better to spend a few cycles setting up several parameters than to wear
the overhead of (say) access checks multiple times.

Hope that helps,

More information about the Cygwin-developers mailing list