freebsd-dev/lib/libthr/thread
David Xu 635f917a9d In current implementation, thread cancellation is done in signal handler,
which does not know what is the state of interrupted system call, for
example, open() system call opened a file and the thread is still cancelled,
result is descriptor leak, there are other problems which can cause resource
leak or undeterminable side effect when a thread is cancelled. However, this
is no longer true in new implementation.

  In defering mode, a thread is canceled if cancellation request is pending and
later the thread enters a cancellation point, otherwise, a later
pthread_cancel() just causes SIGCANCEL to be sent to the target thread, and
causes target thread to abort system call, userland code in libthr then checks
cancellation state, and cancels the thread if needed. For example, the
cancellation point open(), the thread may be canceled at start,
but later, if it opened a file descriptor, it is not canceled, this avoids
file handle leak. Another example is read(), a thread may be canceled at start
of the function, but later, if it read some bytes from a socket, the thread
is not canceled, the caller then can decide if it should still enable cancelling
or disable it and continue reading data until it thinks it has read all
bytes of a packet, and keeps a protocol stream in health state, if user ignores
partly reading of a packet without disabling cancellation, then second iteration
of read loop cause the thread to be cancelled.
An exception is that the close() cancellation point always closes a file handle
despite whether the thread is cancelled or not.

  The old mechanism is still kept, for a functions which is not so easily to
fix a cancellation problem, the rough mechanism is used.

Reviewed by: kib@
2010-08-20 05:15:39 +00:00
..
Makefile.inc remove file thr_sem_new.c. 2010-01-05 07:50:31 +00:00
thr_affinity.c Avoid various shadowed variables. libthr is now almost WARNS=4 clean except 2008-04-23 21:06:51 +00:00
thr_atfork.c
thr_attr.c Avoid various shadowed variables. libthr is now almost WARNS=4 clean except 2008-04-23 21:06:51 +00:00
thr_autoinit.c
thr_barrier.c _thr_ucond_wait drops lock, we should pick it up again. 2006-12-05 23:46:11 +00:00
thr_barrierattr.c
thr_cancel.c In current implementation, thread cancellation is done in signal handler, 2010-08-20 05:15:39 +00:00
thr_clean.c Make pthread_cleanup_push() and pthread_cleanup_pop() as a pair of macros, 2008-06-09 01:14:10 +00:00
thr_concurrency.c
thr_cond.c In current implementation, thread cancellation is done in signal handler, 2010-08-20 05:15:39 +00:00
thr_condattr.c Coalesce one more broken line. 2010-05-24 13:44:39 +00:00
thr_create.c Use UMTX_OP_WAIT_UINT_PRIVATE and UMTX_OP_WAKE_PRIVATE to save 2008-04-29 03:58:18 +00:00
thr_detach.c
thr_equal.c Remove 3rd clause, renumber, ok per email 2007-01-12 07:26:21 +00:00
thr_event.c Allow psaddr_t to be widened by using thr_pread_{int,long,ptr}, 2008-09-14 16:07:21 +00:00
thr_exit.c Tweak code a bit to be POSIX compatible, when a cancellation request 2010-08-17 02:50:12 +00:00
thr_fork.c These are some cosmetic changes to improve the clarity of libthr's fork implementation. 2009-05-11 16:45:53 +00:00
thr_getcpuclockid.c Add POSIX pthread API pthread_getcpuclockid() to get a thread's cpu 2008-03-22 09:59:20 +00:00
thr_getprio.c Remove 3rd clause, renumber, ok per email 2007-01-12 07:26:21 +00:00
thr_getschedparam.c
thr_info.c If a thread who's name is being set is not the current thread, use macros 2007-04-05 07:20:31 +00:00
thr_init.c Use umtx to implement process sharable semaphore, to make this work, 2010-01-05 02:37:59 +00:00
thr_join.c In current implementation, thread cancellation is done in signal handler, 2010-08-20 05:15:39 +00:00
thr_kern.c
thr_kill.c Remove 3rd clause, renumber, ok per email 2007-01-12 07:26:21 +00:00
thr_list.c
thr_main_np.c
thr_multi_np.c Remove 3rd clause, renumber, ok per email 2007-01-12 07:26:21 +00:00
thr_mutex.c Add two commands to _umtx_op system call to allow a simple mutex to be 2008-06-24 07:32:12 +00:00
thr_mutexattr.c pthread_mutexattr_destroy() was accidentally broken in last revision, 2008-03-20 11:47:08 +00:00
thr_once.c Eliminate global mutex by using pthread_once's state field as 2008-05-30 00:02:59 +00:00
thr_printf.c
thr_private.h In current implementation, thread cancellation is done in signal handler, 2010-08-20 05:15:39 +00:00
thr_pspinlock.c Reverse the logic of UP and SMP. 2007-10-16 07:36:02 +00:00
thr_resume_np.c Use UMTX_OP_WAIT_UINT_PRIVATE and UMTX_OP_WAKE_PRIVATE to save 2008-04-29 03:58:18 +00:00
thr_rtld.c In the current code, rdlock_count is not correctly handled for some cases. 2009-07-06 09:31:04 +00:00
thr_rwlock.c In the current code, rdlock_count is not correctly handled for some cases. 2009-07-06 09:31:04 +00:00
thr_rwlockattr.c
thr_self.c Remove 3rd clause, renumber, ok per email 2007-01-12 07:26:21 +00:00
thr_sem.c Use umtx to implement process sharable semaphore, to make this work, 2010-01-05 02:37:59 +00:00
thr_setprio.c Remove 3rd clause, renumber, ok per email 2007-01-12 07:26:21 +00:00
thr_setschedparam.c
thr_sig.c In current implementation, thread cancellation is done in signal handler, 2010-08-20 05:15:39 +00:00
thr_single_np.c Remove 3rd clause, renumber, ok per email 2007-01-12 07:26:21 +00:00
thr_spec.c don't report error if key was deleted. 2009-09-25 00:15:30 +00:00
thr_spinlock.c Avoid various shadowed variables. libthr is now almost WARNS=4 clean except 2008-04-23 21:06:51 +00:00
thr_stack.c
thr_suspend_np.c Use UMTX_OP_WAIT_UINT_PRIVATE and UMTX_OP_WAKE_PRIVATE to save 2008-04-29 03:58:18 +00:00
thr_switch_np.c
thr_symbols.c Remove 3rd clause, renumber, ok per email 2007-01-12 07:26:21 +00:00
thr_syscalls.c In current implementation, thread cancellation is done in signal handler, 2010-08-20 05:15:39 +00:00
thr_umtx.c Work-around a race condition on ia64 while unlocking a contested lock. 2009-12-14 01:26:01 +00:00
thr_umtx.h rwlock implemented from libthr need to fall through the 'hard path' and 2009-09-23 21:38:57 +00:00
thr_yield.c Remove 3rd clause, renumber, ok per email 2007-01-12 07:26:21 +00:00