summaryrefslogtreecommitdiffstats
path: root/lib/libthr
Commit message (Collapse)AuthorAgeFilesLines
* Fix inverted #ifdef that I added. Who had the pointy hat last?peter2004-12-061-1/+1
| | | | Submitted by: kan
* Don't include sys/user.h merely for its side-effect of recursivelydas2004-11-273-2/+5
| | | | including other headers.
* Use the recently exposed fs/gs set functions when compiling libthr topeter2004-11-061-0/+12
| | | | | | | run as a 32 bit support library for an amd64 kernel. 32 bit consumers of libthr have zero chance of running on an amd64 kernel since we don't implement the i386_set_ldt() family of functions. Note that this commit doesn't make it actually work, it just removes one more obstacle.
* For variables that are only checked with defined(), don't provideru2004-10-241-1/+1
| | | | any fake value.
* 1. Now that it's a thread's state is changed from within the kernel, wheremtm2004-10-132-4/+10
| | | | | | | | | | | | | | no userland locks are heald, the dead thread lock can no longer protect access to it. Therefore, instead of using an if (!dead)...else clause after walking the active threads list test the thread pointer before deciding not to walk the dead threads list. If the thread pointer is null it means it was not found in the active threads list and the dead threads list should be checked. 2. Do not free the stack of a thread that is not marked dead. This is the 2nd and final part of eliminating the race to free a thread's stack. MFC after: 3 days
* Remove a reference to a non-existent syscall: _thr_exit(). Themtm2004-10-081-4/+1
| | | | actual name is thr_exit(). How this ever worked is beyond me.
* Close a race between a thread exiting and the freeing of it's stack.mtm2004-10-061-3/+2
| | | | | | | | | After some discussion the best option seems to be to signal the thread's death from within the kernel. This requires that thr_exit() take an argument. Discussed with: davidxu, deischen, marcel MFC after: 3 days
* Remove vestiges of libthr's signal mangling past. This fixes that lastmtm2004-09-221-14/+1
| | | | known problem with mysql on libthr: not being able to kill mysqld.
* The SUSv3 function say that the affected functions MAY FAIL, if themtm2004-09-221-27/+6
| | | | | | | | | | | | specified mutex is invalid. In spec parlance 'MAY FAIL' means it's up to the implementor. So, remove the check for NULL pointers for two reasons: 1. A mutex may be invalid without necessarily being NULL. 2. If the pointer to the mutex is NULL core-dumping in the vicinity of the problem is much much much better than failing in some other part of the code (especially when the application doesn't check the return value of the function that you oh so helpfully set to EINVAL).
* Implement cancellation points in libc interfaces, as specified by POSIX.mtm2004-09-162-0/+314
|
* Adjust code to support AMD64, on AMD64, thread needs to set fsbase bydavidxu2004-08-193-7/+31
| | | | | itself before it can execute any other code, so new thread should be created with all signals are masked until after fsbase is set.
* Add AMD64 support code.davidxu2004-08-192-0/+106
|
* Add rtld-elf to the include path for the rtld to pthread TLS interface.dfr2004-08-151-0/+1
|
* Add TLS support for libthr on i386.dfr2004-08-152-74/+29
|
* o Assertions to catch that stuff that shouldn't happen is not happening.mtm2004-07-303-20/+19
| | | | | | | | | | o In the rwlock code: move a duplicated check inside an if..else to after the if...else clause. o When initializing a static rwlock move the initialization check inside the lock. o In thr_setschedparam.c: When breaking out of the trylock...retry if busy loop make sure to reset the mtx pointer to null if the mutex is nolonger in a queue.
* Define _libthr_debug for use by libthread_db.marcel2004-07-181-0/+9
|
* Record the offset of thr_id in the thread structure. Required formarcel2004-07-041-0/+1
| | | | debugging.
* Change the thread ID (thr_id_t) used for 1:1 threading from being amarcel2004-07-024-19/+9
| | | | | | | | | | | | | | | | | | | | pointer to the corresponding struct thread to the thread ID (lwpid_t) assigned to that thread. The primary reason for this change is that libthr now internally uses the same ID as the debugger and the kernel when referencing to a kernel thread. This allows us to implement the support for debugging without additional translations and/or mappings. To preserve the ABI, the 1:1 threading syscalls, including the umtx locking API have not been changed to work on a lwpid_t. Instead the 1:1 threading syscalls operate on long and the umtx locking API has not been changed except for the contested bit. Previously this was the least significant bit. Now it's the most significant bit. Since the contested bit should not be tested by userland, this change is not expected to be visible. Just to be sure, UMTX_CONTESTED has been removed from <sys/umtx.h>. Reviewed by: mtm@ ABI preservation tested on: i386, ia64
* When a thread is created suspended have libthr suspend it explicitlymtm2004-06-301-10/+3
| | | | instead of asking the kernel to do it when we create the thread.
* Implement pthread_atfork in libthr. This is mostly from deichen'smtm2004-06-275-0/+133
| | | | | | 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-2015-622/+320
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* q§mtm2004-05-201-7/+5
|
* Unconditionaly initialize any spin lock passed to pthread_spin_init(). Whilemtm2004-04-241-4/+0
| | | | | | makeing sure the spinlock isn't already in use might be a nice feature to have in theory, it's hard to implement in practice since the passed in pointer may not be NULL, but still be an invalid value (i.e. 1..2..3.. etc).
* o Also check that the mutex type is not less than the minimum allowable value.mtm2004-03-291-2/+3
| | | | o Don't check attribute for NULL. It's the callers responsibility.
* Make the minimum implementation of pthread_kill conform to themtm2004-03-291-0/+13
| | | | | | | functionality spelled out in SUSv3. o Signal of 0 means do everything except send the signal o Check that the signal is not invalid o Check that the target thread is not dead/invalid
* o Don't explicitly check the thread for NULL. That is the caller'smtm2004-03-291-6/+10
| | | | | responsibility. o If a thread is not joinable, the correct return value is EINVAL.
* o If a thread is marked as detached AND on the dead threads listmtm2004-03-291-3/+3
| | | | | | the correct return value is ESRCH. o Don't check the attribute for NULL. It's the caller's responsibility. o Make the bitwise comparison explicit.
* If a condition variable is statically initialized don't returnmtm2004-03-291-2/+6
| | | | an error. Return successfully without doing anything.
* The thread suspend function now returns ETIMEDOUT, not EAGAIN.mtm2004-03-292-3/+2
|
* o Remove more references to SIGTHRmtm2004-03-292-58/+0
| | | | o Remove clock resolution information left over from libc_r
* Remove the garbage collector thread. All resources are freedmtm2004-03-287-244/+44
| | | | | in-line. If the exiting thread cannot release a resource, then the next thread to exit will release it.
* o Since we're not using signals for thread synchronization anymore,mtm2004-03-272-34/+17
| | | | | | | | sigprocmask no longer needs to be wrapped. o raise(3) is applied to the calling thread in a threaded program. o In the sigaction wrapper reference the correct structure. o Don't treat SIGTHR especially anymore (infact it won't exist in a little while).
* Stop using signals for synchronizing threads. The performance penaltymtm2004-03-275-24/+9
| | | | was too much.
* o The mutex locking functions aren't normally cancellation points. But,mtm2004-03-261-3/+12
| | | | | | | we still have to DTRT when an asynchronously cancellable thread is cancelled while waiting for a mutex. o While dequeueing a waiting mutex don't skip a thread if it has a cancel pending. Only skip it if it is also async cancellable.
* o Initialize a local variable before referencing it. This was notmtm2004-03-261-1/+4
| | | | | | | | | the cause of any bugs because it is *always* indirectly set in the for...loop, but better to be explicit about it. o Check the magic number of the passed in thread only after it has been found in the active thread list. Otherwise, if the check is done at the very beginning we may end up pointing to garbage if the thread was once a valid thread, but has now been destroyed.
* Make NULL a (void*)0 whereever possible, and fix the warnings(-Werror)markm2004-03-051-1/+1
| | | | | | | | | | | | | | | that this provokes. "Wherever possible" means "In the kernel OR NOT C++" (implying C). There are places where (void *) pointers are not valid, such as for function pointers, but in the special case of (void *)0, agreement settles on it being OK. Most of the fixes were NULL where an integer zero was needed; many of the fixes were NULL where ascii <nul> ('\0') was needed, and a few were just "other". Tested on: i386 sparc64
* libthr powerpc support.grehan2004-03-022-0/+63
| | | | | Submitted by: Suleiman Souhlal <refugee@segfaulted.com> Tested with: most libpthread tests, Apache 'worker' MDM
* Implement PThreads barriers and barrier attributes.mtm2004-02-196-1/+236
|
* Don't wake up the thread after the signal handlermtm2004-02-191-1/+1
| | | | | | | | has been executed. On return from the signal handler the call will either be restarted or EINTR will be returned, but it will not go back to its previous state. So, it is sufficient to simply change the state to 'running' without actually trying to wake up the thread.
* Remove thr_getschedparam.c since it's contents have been moved intomtm2004-02-181-1/+0
| | | | thr_setschedparam.c
* There are consumers of rwlocks, inluding our own libc, that depend onmtm2004-02-181-96/+24
| | | | | | | | | | a PTHREAD_RWLOCK_INITIALIZER to do for rwlocks what a similarly named symbol does for statically initialized mutexes. This symbol was dropped in The Open Group Base Specifications Issue 6 and does not exist in IEEE Std 1003.1, 2003, but it should still be supported for backwards compatibility. Pointy hat: mtm
* o Catch up with the mutex priority protocol fixes.mtm2004-02-182-121/+65
| | | | | o Move pthread_getschedparam() into the same file with it's pthread_set* counterpart. Copyright on both files is identical.
* o Stylemtm2004-02-182-48/+39
| | | | | | o Instead of checking both the passed in pointer and its value for NULL, only check the latter. Any caller that passes in a NULL pointer is obviously wrong.
* o Refactor and, among other things, get rid of insane nesting levels.mtm2004-02-182-811/+305
| | | | | | | 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.
* Move the initialization of thread priority to a common function.mtm2004-02-182-6/+3
|
* Move the weak references to the top of the file to conformmtm2004-02-181-43/+22
| | | | to the format of other similar files in libthr.
* style cleanup: Remove duplicate $FreeBSD$ tags.cperciva2004-02-101-2/+0
| | | | | | | | These files had tags after the copyright notice, inside the comment block (incorrect, removed), and outside the comment block (correct). Approved by: rwatson (mentor)
* Remove the band-aid (#include <time.h>).deischen2004-02-031-1/+0
|
* Add <time.h> -- bandaid to unbreak world in <semaphore.h>.deischen2004-02-031-0/+1
|
OpenPOWER on IntegriCloud