summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread/thr_private.h
Commit message (Collapse)AuthorAgeFilesLines
* Implement PThreads barriers and barrier attributes.mtm2004-02-191-1/+18
|
* o Refactor and, among other things, get rid of insane nesting levels.mtm2004-02-181-1/+5
| | | | | | | o Fix mutex priority protocols. Keep separate counts of priority inheritance and protection mutexes to make things easier. This will not have much affect since this is only the userland side, and the rest involves kernel scheduling.
* o Implement the pthread_spin_* functions in libthr.mtm2004-01-221-0/+5
| | | | o Man pages
* Implement reference counting of read-write locks. This usesmtm2004-01-191-0/+16
| | | | | | | | | | | | | | | | | a list in the thread structure to keep track of the locks and how many times they have been locked. This list is checked on every lock and unlock. The traversal through the list is O(n). Most applications don't hold so many locks at once that this will become a problem. However, if it does become a problem it might be a good idea to review this once libthr is off probation and in the optimization cycle. This fixes: o deadlock when a thread tries to recursively acquire a read lock when a writer is waiting on the lock. o a thread could previously successfully unlock a lock it did not own o deadlock when a thread tries to acquire a write lock on a lock it already owns for reading or writing [ this is admittedly not required by POSIX, but is nice to have ]
* Make it possible for the library to specify a timeout value whenmtm2003-12-301-1/+1
| | | | | | | | | | waiting on a locked mutex. This involves passing a struct timespec from the pthread mutex locking interfaces all the way down to the function that suspends the thread until the mutex is released. The timeout is assumed to be an absolute time (i.e. not relative to the current time). Also, in _thread_suspend() make the passed in timespec const.
* Preparations to make libthr work in multi-threaded fork()ing applications.mtm2003-12-261-0/+2
| | | | | | | | | | | | | 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.
* Remove _giant_mutex and its associated macros.mtm2003-12-151-16/+0
|
* Take a stab at fixing some of the macro-nightmare.mtm2003-12-091-46/+23
| | | | | | PTHREAD_NEW_STATE should work as expected now: a thread marked PS_RUNNING will get sent a SIGTHR. Still more cleanups necessary.
* Fix the wrapper function around signals so that a signal handlingmtm2003-12-091-0/+1
| | | | | thread on one of the mutex or condition variable queues is removed from those queues before the real signal handler is called.
* o Add a wrapper around sigaction(2), so we can insert our own wrappermtm2003-12-091-0/+3
| | | | | around signals. o Lock the process global signal action table.
* When _PTHREADSINVARIANTS is defined SIGABRT is not includedmtm2003-07-081-2/+13
| | | | | | in the set of signals to block. Also, make the PANIC macro call abort() instead of simply exiting.
* Change all instances of THR_LOCK/UNLOCK, etc to UMTX_*.mtm2003-07-061-3/+3
| | | | | It is a more acurate description of the locks they operate on.
* There's no need for _umtxtrylock to be a separate function.mtm2003-07-061-2/+6
| | | | Roll it into the pre-existing macro that's used to call it.
* Locking primitives and operations in libthr should use struct umtx,mtm2003-06-291-2/+20
| | | | | | | | | | | not spinlock_t. Spinlock_t and the associated functions and macros may require blocking signals in order for async-safe libc functions to behave appropriately in libthr. This is undesriable for libthr internal locking. So, this is the first step in completely separating libthr from libc's locking primitives. Three new macros should be used for internal libthr locking from now on: THR_LOCK, THR_TRYLOCK, THR_UNLOCK.
* In a critical section, separate the aquisition of the thread lockmtm2003-06-291-1/+3
| | | | | | | | | | | | and the disabling of signals. What we are really interested in is keeping track of recursive disabling of signals. We should not be recursively acquiring thread locks. Any such situations should be reorganized to not require a recursive lock. Separating the two out also allows us to block signals independent of acquiring thread locks. This will be needed in libthr in the near future when we put the pieces together to protect libc functions that use pthread mutexes and low level locks.
* Make _thread_suspend work with both the old broken sigtimedwaitjdp2003-06-291-0/+3
| | | | | | 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.
* The move to _retire() a thread in the GC instead of in the thread'smtm2003-06-291-2/+0
| | | | | | | exit function has invalidated the need for _spin[un]lock_pthread(). The _spin[un]lock() functions can now dereference curthread without the danger that the ldtentry containing the pointer to the thread has been cleared out from under them.
* Teach recent changes in the umtx structure in the kernel to the libthrmtm2003-06-031-1/+1
| | | | | | initialiazer. Found by: tinderbox
* Decouple the thread stack [de]allocating functions from the 'dead threads list'mtm2003-05-261-0/+8
| | | | | | | lock. It's not really necessary and we don't need the added complexity or potential for deadlocks. Approved by: re/blanket libthr
* Return gracefully, rather than aborting, when the maximum concurrentmtm2003-05-251-1/+1
| | | | | | threads per process has been reached. Return EAGAIN, as per spec. Approved by: re/blanket libthr
* _pthread_cancel() breaks the normal lock order of first locking themtm2003-05-251-0/+1
| | | | | | | | | | | | | 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
* Start locking up the active and dead threads lists. The active threadsmtm2003-05-251-6/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* The libthr code makes use of higher-level primitives (pthread_mutex_t andmtm2003-05-251-0/+1
| | | | | | | | | | | | | pthread_cond_t) internaly in addition to the low-level spinlock_t. The garbage collector mutex and condition variable are two such examples. This might lead to critical sections nested within critical sections. Implement a reference counting mechanism so that signals are masked only on the first entry and unmasked on the last exit. I'm not sure I like the idea of nested critical sections, but if the library is going to use the pthread primitives it might be necessary. Approved by: re/blanket libthr
* Add two functions: _spinlock_pthread() and _spinunlock_pthread()mtm2003-05-231-0/+2
| | | | | | | | | | that take the address of a struct pthread as their first argument. _spin[un]lock() just become wrappers arround these two functions. These new functions are for use in situations where curthread can't be used. One example is _thread_retire(), where we invalidate the array index curthread uses to get its pointer.. Approved by: re/blanket libthr
* EDOOFUSmtm2003-05-231-0/+1
| | | | | | | | Prevent one thread from messing up another thread's saved signal mask by saving it in struct pthread instead of leaving it as a global variable. D'oh! Approved by: re/blanket libthr
* Make WARNS2 clean. The fixes mostly included:mtm2003-05-231-1/+1
| | | | | | | | o removed unused variables o explicit inclusion of header files o prototypes for externally defined functions Approved by: re/blanket libthr
* msg1mtm2003-05-121-0/+2
|
* - Pass a ucontext_t to _set_curthread. If non-NULL the new thread is setjake2003-04-031-2/+2
| | | | | | | | 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-5/+9
| | | | | | | _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().
* - Restore old mutex code from libc_r. It is more standards compliant.jeff2003-04-011-6/+36
| | | | | | | This was changed because originally we were blocking on the umtx and allowing the kernel to do the queueing. It was decided that the lib should queue and start the threads in the order it decides and the umtx code would just be used like spinlocks.
* - Add libthr but don't hook it up to the regular build yet. This is anjeff2003-04-011-0/+804
adaptation of libc_r for the thr system call interface. This is beta quality code.
OpenPOWER on IntegriCloud