cross-thread locking

Dag-ErlingSmørgrav des at des.no
Fri Feb 20 08:02:57 PST 2004


Daniel Eischen <eischen at vigrid.com> writes:
> POSIX differentiates between spinlocks and mutexes, and that is
> why there is a pthread_spinlock_t instead of using pthread_mutex_t
> for both lock operations.  I believe the implementation is allowed
> to spin indefinitely or schedule another thread if the lock is
> busy.

In other words, the semantics for the two are identical?

BTW, I looked at the libpthread sources, and it seems to me that a
spinlock is just a wrapper around a mutex, though the comments
contradict this.

Going off on a tangent, is there a value one can assign to a pthread_t
to make it unambiguously invalid?  Obviously, NULL or 0 will work in
FreeBSD since our pthread_t is a pointer to a struct pthread, but I'm
looking for something more portable.

DES
-- 
Dag-Erling Smørgrav - des at des.no


More information about the freebsd-threads mailing list