summaryrefslogtreecommitdiff
path: root/lib/libpthread/thread
Commit message (Collapse)AuthorAgeFilesLines
* Increase the size of private thread flags so that the test for aJohn Birrell1999-01-151-1/+1
| | | | | | | | | | thread trying to call pthread_exit() from a cleanup handler actually works. Submitted by: David Leonard <david.leonard@csee.uq.edu.au> OpenBSD Notes: svn path=/head/; revision=42681
* Fix a minor security problem in libc_r.Warner Losh1999-01-111-4/+25
| | | | | | | | | Submitted by: Alexandre Snarskii <snar@paranoia.ru> Approved by: John Birrell Reminded me that I'd been sitting on this too long: snar@paranoia.ru Notes: svn path=/head/; revision=42500
* Add support for pthread_mutexattr_settype(). As a side effect ofEivind Eklund1998-11-282-20/+61
| | | | | | | testing this, fix MUTEX_TYPE_COUNTING_FAST. Recursive locks now work. Notes: svn path=/head/; revision=41390
* Interrupt threads waiting in select etc.John Birrell1998-11-151-0/+20
| | | | | | | Submitted by: Alec Wolman <wolman@cs.washington.edu> Notes: svn path=/head/; revision=41165
* Close a window between unlocking a spinlock and changing the thread state.John Birrell1998-11-154-21/+31
| | | | Notes: svn path=/head/; revision=41164
* Don't call pthread_mutex_lock with _SPINLOCK held.Dmitrij Tejblum1998-11-061-21/+30
| | | | | | | | | Made pthread_cond_wait() more similar to pthread_cond_timedwait(). PR: 8375 Notes: svn path=/head/; revision=40974
* Fix some bugs in pthread scheduler:Dmitrij Tejblum1998-10-092-6/+12
| | | | | | | | | | | make pthread_yield() more reliable, threads always (I hope) preempted at least every 0.1 sec, as intended. PR: bin/7744 Submitted by: "Richard Seaman, Jr." <dick@tar.com> Notes: svn path=/head/; revision=40127
* Debug when an environment variable set, no when it is unset.Dmitrij Tejblum1998-09-301-2/+2
| | | | Notes: svn path=/head/; revision=39826
* Cosmetic cleansing. This code requires extra work to keep the garbageJohn Birrell1998-09-301-2/+3
| | | | | | | collector thread running after a fork. Notes: svn path=/head/; revision=39808
* Move the cleanup code that frees memory allocated for a dead thread fromJohn Birrell1998-09-307-130/+324
| | | | | | | | | | | | | | | | | the thread kernel into a garbage collector thread which is started when the fisrt thread is created (other than the initial thread). This removes the window of opportunity where a context switch will cause a thread that has locked the malloc spinlock, to enter the thread kernel, find there is a dead thread and try to free memory, therefore trying to lock the malloc spinlock against itself. The garbage collector thread acts just like any other thread, so instead of having a spinlock to control accesses to the dead thread list, it uses a mutex and a condition variable so that it can happily wait to be signalled when a thread exists. Notes: svn path=/head/; revision=39807
* Use snprintf instead of sprintf to avoid long source file paths fromJohn Birrell1998-09-301-12/+31
| | | | | | | | | | launching an application into space when someone tries to debug it. The dead thread list now has it's own link pointer, so use that when reporting the grateful dead. Notes: svn path=/head/; revision=39806
* Implementation of an additional state called SIGWAIT (with the previousJohn Birrell1998-09-304-68/+116
| | | | | | | | | one renamed to SIGSUSPEND) to fix sigwait(). Submitted by: Daniel M. Eischen <eischen@vigrid.com> Notes: svn path=/head/; revision=39805
* NULL a pointer after it is freed to avoid trying to free it again.John Birrell1998-09-301-0/+2
| | | | Notes: svn path=/head/; revision=39804
* - Fix the debug macros.John Birrell1998-09-301-4/+21
| | | | | | | | | | | | | | - Add support of a thread being listed in the dead thread list as well as the thread list. - Add a new thread state to make sigwait work properly. (Submitted by Daniel M. Eischen <eischen@vigrid.com>) - Add global variable for the garbage collector mutex and condition variable. - Delete a couple of prototypes that are no longer required. - Add a prototype for the garbage collector thread. Notes: svn path=/head/; revision=39803
* In libc_r, rename vfork syscall to _thread_sys_vfork and make vfork an aliasDmitrij Tejblum1998-09-122-1/+11
| | | | | | | | | | to fork. It is difficult to do real vfork in libc_r, since almost every operation with file descriptsor changes _thread_fd_table and friends. popen(3) works much better with this change. Notes: svn path=/head/; revision=39118
* Removed unused variables.Alexander Langer1998-09-076-11/+2
| | | | Notes: svn path=/head/; revision=38925
* Removed some variable initializations which were unnecessary and divergentAlexander Langer1998-09-071-6/+6
| | | | | | | from style(9). Notes: svn path=/head/; revision=38923
* -Wall clean.Alexander Langer1998-09-072-2/+5
| | | | Notes: svn path=/head/; revision=38921
* Implement pthread read/write locks as defined by Version 2 of the SingleAlexander Langer1998-09-074-1/+445
| | | | | | | | | | UNIX Specification. As with our standard mutexes, process shared locks are not supported at this time. Notes: svn path=/head/; revision=38919
* Don't automatically restart syscalls for the signals that the threadJohn Birrell1998-08-261-1/+1
| | | | | | | kernel needs. Notes: svn path=/head/; revision=38564
* Back out most of the last commit. It created problems with sigpause.John Birrell1998-08-261-26/+1
| | | | Notes: svn path=/head/; revision=38563
* Fix for sigwait problem.John Birrell1998-08-253-17/+99
| | | | | | | | Submitted by: Daniel M. Eischen <eischen@vigrid.com> PR: misc/7039 Notes: svn path=/head/; revision=38539
* Add extra initialisation code that is required for processes thatJohn Birrell1998-08-101-1/+29
| | | | | | | | | | are started instead of init (pid = 1). This allows an embedded implementation quite like VxWorks, with (possibly) a single threaded program running instead of init. The neat thing is that the same threaded process can run in a multi-user workstation environment too. Notes: svn path=/head/; revision=38208
* A style fix for my previous commit.Alexander Langer1998-08-021-1/+1
| | | | Notes: svn path=/head/; revision=38027
* Fixed a race condition during the first lock/trylock of a staticallyAlexander Langer1998-08-021-4/+21
| | | | | | | | | | | | initialized mutex. Statically initialized mutexes are actually initialized at first use (pthread_mutex_lock/pthread_mutex_trylock). To prevent concurrent initialization by multiple threads, all static initializations are now serialized by a spinlock. Reviewed by: jb Notes: svn path=/head/; revision=38025
* Fixed a printf format error. Didn't fix assumption that sigset_t isBruce Evans1998-06-301-1/+1
| | | | | | | integral. Notes: svn path=/head/; revision=37302
* Add the missing {} that caused the function to return ESRCH if itJohn Birrell1998-06-251-1/+2
| | | | | | | | had to wait for the thread to exit and if the caller didn't want the thread exit status. Notes: svn path=/head/; revision=37146
* Don't allow a SIGCHLD to wake up a thread if the process has the defaultJohn Birrell1998-06-171-6/+9
| | | | | | | | signal handler installed for SIGCHLD. The ACE MT_SOCK_Test was hanging as the result of being interrupted when it didn't expect to be. Notes: svn path=/head/; revision=37045
* If a thread is waiting on a child process to complete, the SIGCHLDJohn Birrell1998-06-171-1/+20
| | | | | | | | | signal can arrive before the thread is woken from it's wait4. In this case, don't return an EINTR, just set the thread state to running and the wait4 wrapper will loop and get the exit status of the process. Notes: svn path=/head/; revision=37021
* If a short write, only loop if no error.John Birrell1998-06-142-4/+4
| | | | Notes: svn path=/head/; revision=36965
* Update the caller's descriptor masks even if there are none ready forJohn Birrell1998-06-121-1/+1
| | | | | | | | I/O for those applications that don't believe the return value of zero as meaning that THERE ARE *NO* DESCRIPTORS READY. Notes: svn path=/head/; revision=36904
* Check the access mode in the flags before waiting on a read or a writeJohn Birrell1998-06-104-4/+52
| | | | | | | | that might never be possible if the file was not opened in the corrent mode. This prevents a hang for bad programs. Why do people code like that? Notes: svn path=/head/; revision=36877
* Remove SA_RESTART from the signal dispatch in user-space since thisJohn Birrell1998-06-101-92/+39
| | | | | | | seems to be tripping up a lot of applications. Notes: svn path=/head/; revision=36876
* When doing a F_SETFL, read the flags back so that the ones storedJohn Birrell1998-06-101-3/+31
| | | | | | | | in the file descriptor table are exactly what the kernel knows subject to the O_NONBLOCK flag being requested by the user. Notes: svn path=/head/; revision=36875
* Implement compile time debug support instead of tracking file name andJohn Birrell1998-06-0913-87/+94
| | | | | | | | | | line number every time a file descriptor is locked. This looks like a big change but it isn't. It should reduce the size of libc_r and make it run slightly faster. Notes: svn path=/head/; revision=36830
* Add support for compile time debug. This is enabled if libc_r is builtJohn Birrell1998-06-091-20/+52
| | | | | | | | | | | | | with -D_LOCK_DEBUG. This adds the file name and line number to each lock call and these are stored in the spinlock structure. When using debug mode, the lock function will check if the thread is trying to lock something it has already locked. This is not supposed to happen because the lock will be freed too early. Without lock debug, libc_r should be smaller and slightly faster. Notes: svn path=/head/; revision=36828
* POSIX says that pthread_exit() is not allowed to be called from aJohn Birrell1998-06-091-0/+10
| | | | | | | | | | | cleanup destructor, so trap this case to prevent me from being being burnt again by applications that try to do this. With this change, an application (like one using a mis-configured ACE) will exit the process after displaying a message quoting the POSIX section that the application has violated. Notes: svn path=/head/; revision=36827
* Add compile time thread lock debug support.John Birrell1998-06-091-6/+21
| | | | | | | | Add a thread specific flag to trap the case where pthread_exit() is called from a destructor in violation of the Posix standard. Notes: svn path=/head/; revision=36826
* Add a warning message for a thread locking against itself. This isJohn Birrell1998-06-061-3/+14
| | | | | | | | not supposed to happen, but I have seen bogus g++ code that causes it. Notes: svn path=/head/; revision=36698
* Simplify the handling of thread specific data. Only track if a keyJohn Birrell1998-06-061-45/+33
| | | | | | | | | is allocated or not, rather than keeping a count and attempting to know it it is in-use. POSIX says that once a key is deleted, using the key again results in undefined behaviour. Notes: svn path=/head/; revision=36697
* Re-design the thread specific key structure.John Birrell1998-06-061-3/+2
| | | | Notes: svn path=/head/; revision=36696
* I got the last commit back to front.John Birrell1998-06-061-3/+3
| | | | Notes: svn path=/head/; revision=36694
* Fix the signal behaviour for internal states which set the threadJohn Birrell1998-06-051-6/+51
| | | | | | | | state to running despite the SA_RESTART flag which is really just for syscalls. Notes: svn path=/head/; revision=36680
* I shouldn't do things early in the morning.John Birrell1998-06-011-3/+1
| | | | | | | | | I shouldn't do things early in the morning. [...] I shouldn't do things early in the morning. Notes: svn path=/head/; revision=36553
* Add some missing syscall wrappers.John Birrell1998-05-311-1/+5
| | | | Notes: svn path=/head/; revision=36550
* Remove some stale code.John Birrell1998-05-311-1/+1
| | | | | | | Pointed out by: Amancio Notes: svn path=/head/; revision=36549
* Don't restart a syscall when a SIGCHLD is received by a thread waitingJohn Birrell1998-05-311-1/+6
| | | | | | | on a child process. Notes: svn path=/head/; revision=36548
* Make a copy of the caller's iovec array, mallocing if necessary,John Birrell1998-05-271-14/+62
| | | | | | | | and modify that if the writev() syscall does not completely write all bytes in a single call. Notes: svn path=/head/; revision=36402
* When doing a blocking write, keep looping until all the bytes areJohn Birrell1998-05-252-20/+106
| | | | | | | | | | written without returning to the caller. This only occurs on pipes where either the number of bytes written is greater than the pipe buffer or if there is insufficient space in the pipe buffer because the reader is reading slower than the writer is writing. Notes: svn path=/head/; revision=36382
* Treat the lock value as volatile.John Birrell1998-05-051-2/+2
| | | | Notes: svn path=/head/; revision=35754