summaryrefslogtreecommitdiffstats
path: root/lib/libthr
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* Bump up the maximum number concurrent threads on x86.mtm2004-02-011-1/+1
|
* I update the rwlock code in libthr to be more standards compliant andmtm2004-01-291-12/+119
| | | | | | | | | | what do I get for my troubles? libc breaks offcourse! Reimplement a hack (in libthr) that allows libc to use rwlocks without initializing them first. The hack was reimplemented so that only a private libc version of the rwlock locking functions initializes an uninitialized rwlock. The application version will correctly fail.
* When suspending a thread if the timeout was very short ormtm2004-01-291-0/+11
| | | | | | | | | | | | | the system call got interrupted and the absolute timeout is converted to a relative timeout, it may happen that we get a negative number. In such a case, simply set the timeout to zero so that if the event that the thread wants to wait for has happened it can still return successfully, but if it hasn't happened then the thread doesn't suspend indefinitely. This should fix certain applications (including mozilla) that seem to hang indefinitely sometimes. Noticed and debugged by: Morten Johansen <root@morten-johansen.net>
* o Implement the pthread_spin_* functions in libthr.mtm2004-01-222-0/+91
| | | | o Man pages
* Refactor _pthread_mutex_initmtm2004-01-191-125/+64
| | | | | | | | | | | | o Simplify the logic by removing a lot of unnecesary nesting o Reduce the amount of local variables o Zero-out the allocated structure and get rid of all the unnecessary setting to 0 and NULL; Refactor _pthread_mutex_destroy o Simplify the logic by removing a lot of unnecesary nesting o No need to check pointer that the mutex attributes points to. Checking passed in pointer is enough.
* Implement reference counting of read-write locks. This usesmtm2004-01-193-8/+155
| | | | | | | | | | | | | | | | | 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 ]
* Add an implementation of pthread_rwlock_timed{rd,wr}lock() to libthr withmtm2004-01-161-11/+54
| | | | attendant documentation.
* o We are not required to initialize an invalid rwlock. So axe all thatmtm2004-01-161-160/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | code and simply return EINVAL (which is allowed by the standard) in all those pthread functions that previously initialized it. o Refactor the pthread_rwlock_[try]rdlock() and pthread_rwlock_[try]wrlock() functions. They are now completeley condensed into rwlock_rdlock_common() and rwlock_wrlock_common(), respectively. o If the application tries to destroy an rwlock that is currently held by a thread return EBUSY where it previously went ahead and freed all resources associated with the lock. o Refactor _pthread_rwlock_init() to make it look (relatively) sane. o When obtaining a read lock on an rwlock the check for whether it would exceed the maximum allowed read locks should happen *before* we obtain the lock. o The pthread_rwlock_* functions shall *never* return EINTR, so make sure to requeue/resuspend the thread if it encounters such an error. o Make a note that pthread_rwlock_unlock() needs to ensure it holds a lock on an rwlock it tries to unlock. It will be implemented in a separate commit because it requires some additional rwlock infrastructure.
* Return ENOTSUP instead of -1.ru2004-01-151-1/+1
|
* o Implement pthread_mutex_timedlock(), which does not block indefinitely onmtm2003-12-301-0/+32
| | | | | a mutex locked by another thread. o document it: pthread_mutex_timedlock(3)
* Make it possible for the library to specify a timeout value whenmtm2003-12-303-22/+49
| | | | | | | | | | 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.
* Don't block SIGTRAP - it makes it hard to debug programs with gdb.dfr2003-12-261-0/+1
| | | | Reviewed by: mtm
* Preparations to make libthr work in multi-threaded fork()ing applications.mtm2003-12-263-63/+81
| | | | | | | | | | | | | 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-152-85/+0
|
* Comment out most of pthread_setschedparam. Pthread priorities didn'tmtm2003-12-151-1/+4
| | | | | | work before anyways, and I didn't want to fix broken code I had no way of testing. It was necessary however, in order to get rid of GIANT_LOCK. Pthread priorities will have to wait a little longer to get fixed.
* When creating a pthread in the suspended state their were twomtm2003-12-151-2/+4
| | | | | | | | problems: (1) The wrong flag was being checked for in the attribute (2) The pthread's state was not being set to indicate it was suspended. Noticed by: Igor Sysoev <is@rambler-co.ru>
* Doh! Lock the thread passed in by the caller, not the current thread.mtm2003-12-121-2/+2
|
* Remove uses of GIANT_LOCK and replace with appropriate threadmtm2003-12-111-7/+12
| | | | and thread list locks.
* 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-095-58/+57
| | | | | thread on one of the mutex or condition variable queues is removed from those queues before the real signal handler is called.
* Ugghh, cvs add the functions necessary to lock the global signal actionmtm2003-12-091-0/+91
| | | | table.
* o Add a wrapper around sigaction(2), so we can insert our own wrappermtm2003-12-093-0/+62
| | | | | around signals. o Lock the process global signal action table.
* Enable cancellation points around some syscalls.mtm2003-12-091-28/+28
|
* Use dynamic instead of static LDT allocation.mtm2003-12-021-5/+4
| | | | Approved by: re (scottl)
OpenPOWER on IntegriCloud