]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
_pthread_cancel() breaks the normal lock order of first locking the
authorMike Makonnen <mtm@FreeBSD.org>
Sun, 25 May 2003 08:48:11 +0000 (08:48 +0000)
committerMike Makonnen <mtm@FreeBSD.org>
Sun, 25 May 2003 08:48:11 +0000 (08:48 +0000)
commitd39d651258abd53821436a4c34c176ecfaedae6c
tree79da265fb53834aa5475bf10c54f9f58202ebf91
parent4393f2c4ecb1499c83e5a9a9bac0c0ada2871abf
_pthread_cancel() breaks the normal lock order of first locking the
joined and then the joiner thread. There isn't an easy (sane?) way
to make it use the correct order without introducing races involving
the target thread and finding which (active or dead) list it is on. So,
after locking the canceled thread it will try to lock the joined thread
and if it fails release the first lock and try again from the top.

Introduce a new function, _spintrylock, which is simply a wrapper arround
umtx_trylock(), to help accomplish this.

Approved by: re/blanket libthr
lib/libthr/thread/thr_cancel.c
lib/libthr/thread/thr_private.h
lib/libthr/thread/thr_spinlock.c