summaryrefslogtreecommitdiff
path: root/lib/libpthread/thread/thr_cancel.c
Commit message (Collapse)AuthorAgeFilesLines
* Deliver signals posted via an upcall to the appropriate thread.Jonathan Mini2003-02-171-0/+2
| | | | Notes: svn path=/head/; revision=111035
* Make libpthread KSE aware.Jonathan Mini2002-09-161-10/+0
| | | | | | | | Reviewed by: deischen, julian Approved by: -arch Notes: svn path=/head/; revision=103419
* Make the changes needed for libpthread to compile in its new home.Jonathan Mini2002-09-161-1/+1
| | | | | | | | | | | The new libpthread will provide POSIX threading support using KSE. These files were previously repo-copied from src/lib/libc_r. Reviewed by: deischen Approved by: -arch Notes: svn path=/head/; revision=103388
* Revamp suspend and resume. While I'm here add pthread_suspend_all_np()Daniel Eischen2002-05-241-15/+1
| | | | | | | | | | | | | | | | and pthread_resume_all_np(). These suspend and resume all threads except the current thread, respectively. The existing functions pthread_single_np() and pthread_multi_np(), which formerly had no effect, now exhibit the same behaviour and pthread_suspend_all_np() and pthread_resume_all_np(). These functions have been added mostly for the native java port. Don't allow the uthread kernel pipe to use the same descriptors as stdio. Mostily submitted by Oswald Buddenhagen <ossi@kde.org>. Correct some minor style nits. Notes: svn path=/head/; revision=97204
* Make sure calls to pthread_cancel() do not take effect if the targetArchie Cobbs2002-05-021-2/+4
| | | | | | | | | | | thread is already exiting. PR: bin/37614 Reviewed by: deischen MFC after: 1 week Notes: svn path=/head/; revision=95947
* Properly clear the status of a join operation if the joining thread isDaniel Eischen2002-03-061-0/+1
| | | | | | | canceled or the joinee is detached. Notes: svn path=/head/; revision=91762
* When cancelling a thread while in a join operation, do not detachDaniel Eischen2001-12-161-4/+1
| | | | | | | | | | | the target thread of the join operation. This allows the cancelled thread to detach the target thread in its cancellation handler. This bug was found by Butenhof's cancel_subcontract test. Reviewed by: jasone Notes: svn path=/head/; revision=88015
* Pull the target thread of a join operation from the correct placeDaniel Eischen2001-12-151-3/+4
| | | | | | | when cancelling a thread. Notes: svn path=/head/; revision=87988
* Fix a bug in canceling joining threads.Jason Evans2001-08-161-2/+14
| | | | | | | | | | Do not detach canceled threads. Reported by: Arno Klaassen <arno@heho.snv.jussieu.fr> Collaboration with: deischen Notes: svn path=/head/; revision=81750
* Instead of using a join queue for each thread, use a single pointer toJason Evans2001-05-201-1/+3
| | | | | | | | | | | | | | keep track of a joiner. POSIX only supports a single joiner, so this simplification is acceptable. At the same time, make sure to mark a joined thread as detached so that its resources can be freed. Reviewed by: deischen PR: 24345 Notes: svn path=/head/; revision=76909
* To be consistent, use the __weak_reference macro from <sys/cdefs.h>Daniel Eischen2001-04-101-4/+4
| | | | | | | | | instead of #pragma weak to create weak definitions. Suggested by: bde Notes: svn path=/head/; revision=75369
* Add weak definitions for wrapped system calls. In general:Daniel Eischen2001-01-241-20/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | _foo - wrapped system call foo - weak definition to _foo and for cancellation points: _foo - wrapped system call __foo - enter cancellation point, call _foo(), leave cancellation point foo - weak definition to __foo Change use of global _thread_run to call a function to get the currently running thread. Make all pthread_foo functions weak definitions to _pthread_foo, where _pthread_foo is the implementation. This allows an application to provide its own pthread functions. Provide slightly different versions of pthread_mutex_lock and pthread_mutex_init so that we can tell the difference between a libc mutex and an application mutex. Threads holding mutexes internal to libc should never be allowed to exit, call signal handlers, or cancel. Approved by: -arch Notes: svn path=/head/; revision=71581
* pthread_mutex_lock(), pthread_cond_trywait(), and pthread_cond_wait() areJason Evans2000-06-141-9/+14
| | | | | | | | | | | | | not allowed to return EINTR, but use of pthread_suspend_np() could cause EINTR to be returned. To fix this, restructure pthread_suspend_np() so that it does not interrupt a thread that is waiting on a mutex or condition, and keep enough state around that pthread_resume_np() can fix things up afterwards. Reviewed by: deischen Notes: svn path=/head/; revision=61681
* Fix pthread_suspend_np/pthread_resume_np. For the record, suspending aDaniel Eischen2000-03-151-1/+9
| | | | | | | | | | | | | | | | | thread waiting on an event (I/O, condvar, etc) will, when resumed using pthread_resume_np, return with EINTR. For example, suspending and resuming a thread blocked on read() will not requeue the thread for the read, but will return -1 with errno = EINTR. If the suspended thread is in a critical region, the thread is suspended as soon as it leaves the critical region. Fix a bogon in pthread_kill() where a signal was being delivered twice to threads waiting in sigwait(). Reported by (suspend/resume bug): jdp Reviewed by: jasone Notes: svn path=/head/; revision=58094
* Implement continuations to correctly handle [sig|_]longjmp() inside of aJason Evans2000-01-191-4/+18
| | | | | | | | | | | | | | | | | | | | | | | | | signal handler. Explicitly check for jumps to anywhere other than the current stack, since such jumps are undefined according to POSIX. While we're at it, convert thread cancellation to use continuations, since it's cleaner than the original cancellation code. Avoid delivering a signal to a thread twice. This was a pre-existing bug, but was likely unexposed until these other changes were made. Defer signals generated by pthread_kill() so that they can be delivered on the appropriate stack. deischen claims that this is unnecessary, which is likely true, but without this change, pthread_kill() can cause undefined priority queue states and/or PANICs in [sig|_]longjmp(), so I'm leaving this in for now. To compile this code out and exercise the bug, define the _NO_UNDISPATCH cpp macro. Defining _PTHREADS_INVARIANTS as well will cause earlier crashes. PR: kern/14685 Collaboration with: deischen Notes: svn path=/head/; revision=56277
* Fix problems with cancellation while in critical regions.Daniel Eischen1999-12-171-5/+14
| | | | | | | | | | | | | | o Cancellation flags were not getting properly set/cleared. o Loops waiting for internal locks were not being exited correctly by a cancelled thread. o Minor spelling (cancelation -> cancellation) and formatting corrections (missing tab). Found by: tg Reviewed by: jasone Notes: svn path=/head/; revision=54708
* add pthread_cancel, obtained from OpenBSD.Alfred Perlstein1999-11-281-0/+179
eischen (Daniel Eischen) added wrappers to protect against cancled threads orphaning internal resources. the cancelability code is still a bit fuzzy but works for test programs of my own, OpenBSD's and some examples from ORA's books. add readdir_r to both libc and libc_r add some 'const' attributes to function parameters Reviewed by: eischen, jasone Notes: svn path=/head/; revision=53812