summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread/thr_init.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Increase the default stacksizes:marcus2005-03-061-6/+16
| | | | | | | | | 32-bit 64-bit main thread 2 MB 4 MB other threads 1 MB 2 MB Approved by: mtm Adapted from: libpthread
* Don't include sys/user.h merely for its side-effect of recursivelydas2004-11-271-1/+0
| | | | including other headers.
* Implement pthread_atfork in libthr. This is mostly from deichen'smtm2004-06-271-0/+4
| | | | | | work in libpthread. Submitted by: Dan Nelson <dnelson@allantgroup.com>
* In the case that the global thread list is being re-initialized aftermtm2004-06-271-4/+4
| | | | | | a fork, make sure that the current thread isn't detached and freed. As a consequence the thread should be inserted into the head of the active list only once (in the beginning).
* Make libthr async-signal-safe without costly signal masking. The guidlines Imtm2004-05-201-18/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | followed are: Only 3 functions (pthread_cancel, pthread_setcancelstate, pthread_setcanceltype) are required to be async-signal-safe by POSIX. None of the rest of the pthread api is required to be async-signal-safe. This means that only the three mentioned functions are safe to use from inside signal handlers. However, there are certain system/libc calls that are cancellation points that a caller may call from within a signal handler, and since they are cancellation points calls have to be made into libthr to test for cancellation and exit the thread if necessary. So, the cancellation test and thread exit code paths must be async-signal-safe as well. A summary of the changes follows: o Almost all of the code paths that masked signals, as well as locking the pthread structure now lock only the pthread structure. o Signals are masked (and left that way) as soon as a thread enters pthread_exit(). o The active and dead threads locks now explicitly require that signals are masked. o Access to the isdead field of the pthread structure is protected by both the active and dead list locks for writing. Either one is sufficient for reading. o The thread state and type fields have been combined into one three-state switch to make it easier to read without requiring a lock. It doesn't need a lock for writing (and therefore for reading either) because only the current thread can write to it and it is an integer value. o The thread state field of the pthread structure has been eliminated. It was an unnecessary field that mostly duplicated the flags field, but required additional locking that would make a lot more code paths require signal masking. Any truly unique values (such as PS_DEAD) have been reborn as separate members of the pthread structure. o Since the mutex and condvar pthread functions are not async-signal-safe there is no need to muck about with the wait queues when handling a signal ... o ... which also removes the need for wrapping signal handlers and sigaction(2). o The condvar and mutex async-cancellation code had to be revised as a result of some of these changes, which resulted in semi-unrelated changes which would have been difficult to work on as a separate commit, so they are included as well. The only part of the changes I am worried about is related to locking for the pthread joining fields. But, I will take a closer look at them once this mega-patch is committed.
* o Remove more references to SIGTHRmtm2004-03-291-51/+0
| | | | o Remove clock resolution information left over from libc_r
* Remove the garbage collector thread. All resources are freedmtm2004-03-281-4/+2
| | | | | in-line. If the exiting thread cannot release a resource, then the next thread to exit will release it.
* Move the initialization of thread priority to a common function.mtm2004-02-181-5/+3
|
* Preparations to make libthr work in multi-threaded fork()ing applications.mtm2003-12-261-39/+78
| | | | | | | | | | | | | o Remove some code duplication between _thread_init(), which is run once to initialize libthr and the intitial thread, and pthread_create(), which initializes newly created threads, into a new function called from both places: init_td_common() o Move initialization of certain parts of libthr into a separate function. These include: - Active threads list and it's lock - Dead threads list and it's lock & condition variable - Naming and insertion of the initial thread into the active threads list.
* When _PTHREADSINVARIANTS is defined SIGABRT is not includedmtm2003-07-081-0/+3
| | | | | | in the set of signals to block. Also, make the PANIC macro call abort() instead of simply exiting.
* Make _thread_suspend work with both the old broken sigtimedwaitjdp2003-06-291-0/+26
| | | | | | implementation and the new improved one. We now precompute the signal set passed to sigtimedwait, using an inverted set when necessary for compatibility with older kernels.
* Make C applications statically compiled with libthr work. Previously,mtm2003-06-041-0/+6
| | | | | | an application compiled -static with libthr would dump core in malloc(3) because the stub thread initialization routine in libc would be used instead of the libthr supplied one.
* Return gracefully, rather than aborting, when the maximum concurrentmtm2003-05-251-1/+2
| | | | | | threads per process has been reached. Return EAGAIN, as per spec. Approved by: re/blanket libthr
* Start locking up the active and dead threads lists. The active threadsmtm2003-05-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | list is protected by a spinlock_t, but the dead list uses a pthread_mutex because it is necessary to synchronize other threads with the garbage collector thread. Lock/Unlock macros are used so it's easier to make changes to the locks in the future. The 'dead thread list' lock is intended to replace the gc mutex. This doesn't have any practical ramifications. It simply makes it clearer what the purpose of the lock is. The gc will use this lock, instead of the gc mutex, to synchronize access to the dead list with other threads. Modify _pthread_exit() to use these two new locks instead of GIANT_LOCK, and also to properly lock and protect thread state changes, especially with respect to a joining thread. The gc thread was also re-arranged to be more organized and less nested. _pthread_join() was also modified to use the thread list locks. However, locking and unlocking here needs special care because a thread could find itself in a position where it's joining an exiting thread that is waiting on the dead list lock, which this thread (joiner) holds. If the joiner doesn't take care to lock *and* unlock in the same order they (the joiner and the joinee) could deadlock against each other. Approved by: re/blanket libthr
* Make WARNS2 clean. The fixes mostly included:mtm2003-05-231-2/+1
| | | | | | | | o removed unused variables o explicit inclusion of header files o prototypes for externally defined functions Approved by: re/blanket libthr
* The thread id was being set *before* zeroing out the thread. Reversemtm2003-05-211-2/+3
| | | | | | the order. Approved by: markm/mentor, re/blanket libthr
* - Pass a ucontext_t to _set_curthread. If non-NULL the new thread is setjake2003-04-031-1/+1
| | | | | | | | as curthread in the new context, so that it will be set automatically when the thread is switched to. This fixes a race where we'd run for a little while with curthread unset in _thread_start. Reviewed by: jeff
* - Define curthread as _get_curthread() and remove all direct calls tojeff2003-04-021-16/+0
| | | | | | | _get_curthread(). This is similar to the kernel's curthread. Doing this saves stack overhead and is more convenient to the programmer. - Pass the pointer to the newly created thread to _thread_init(). - Remove _get_curthread_slow().
* - Add libthr but don't hook it up to the regular build yet. This is anjeff2003-04-011-0/+363
adaptation of libc_r for the thr system call interface. This is beta quality code.
OpenPOWER on IntegriCloud