Date: Sat, 6 Dec 2003 13:24:39 -0500 (EST) From: Daniel Eischen <eischen@vigrid.com> To: Igor Sysoev <is@rambler-co.ru> Cc: threads@freebsd.org Subject: Re: pthread_mutex_trylock() should never block Message-ID: <Pine.GSO.4.10.10312061320510.17438-100000@pcnet5.pcnet.com> In-Reply-To: <Pine.BSF.4.21.0312062051100.45645-100000@is>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 6 Dec 2003, Igor Sysoev wrote: > The current pthread_mutex_trylock() implementation in both libpthread (libkse) > and libthr can block if mutex is locked by another thread. > > libphtread calls THR_LOCK_ACQUIRE() and it can be blocked. That's an implementation detail. Threads release the low-level lock (THR_LOCK_ACQUIRE/THR_LOCK_RELEASE) after they take the mutex. I don't believe we (libpthread) are conflicting with POSIX in this respect. > libthr's pthread_mutex_trylock() is too heavy - it calls 3 syscalls: > sigprocmask()/umtx_lock()/sigprocmask() and can be blocked too. > > > SUSv2 states: > [ http://www.opengroup.org/onlinepubs/007908799/xsh/pthread_mutex_lock.html ] > > -------- > The function pthread_mutex_trylock() is identical to pthread_mutex_lock() > except that if the mutex object referenced by mutex is currently locked > (by any thread, including the current thread), the call returns immediately. The low-level locks are necessary (at least in libpthread implementation) to safely test the mutex for ownership. -- Dan Eischen
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.10.10312061320510.17438-100000>