summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread/thr_mutex.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove unused _get_curthread() call.davidxu2005-12-121-2/+0
|
* - Prefix MUTEX_TYPE_MAX with PTHREAD_ to avoid namespace pollution.stefanf2005-08-191-1/+1
| | | | | | - Remove the macros MUTEX_TYPE_FAST and MUTEX_TYPE_COUNTING_FAST. OK'ed by: deischen
* Import my recent 1:1 threading working. some features improved includes:davidxu2005-04-021-589/+1385
| | | | | | | | | | | | | | | | 1. fast simple type mutex. 2. __thread tls works. 3. asynchronous cancellation works ( using signal ). 4. thread synchronization is fully based on umtx, mainly, condition variable and other synchronization objects were rewritten by using umtx directly. those objects can be shared between processes via shared memory, it has to change ABI which does not happen yet. 5. default stack size is increased to 1M on 32 bits platform, 2M for 64 bits platform. As the result, some mysql super-smack benchmarks show performance is improved massivly. Okayed by: jeff, mtm, rwatson, scottl
* 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).
* o Assertions to catch that stuff that shouldn't happen is not happening.mtm2004-07-301-0/+2
| | | | | | | | | | 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.
* Change the thread ID (thr_id_t) used for 1:1 threading from being amarcel2004-07-021-4/+4
| | | | | | | | | | | | | | | | | | | | 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
* Make libthr async-signal-safe without costly signal masking. The guidlines Imtm2004-05-201-42/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
|
* The thread suspend function now returns ETIMEDOUT, not EAGAIN.mtm2004-03-291-1/+1
|
* Stop using signals for synchronizing threads. The performance penaltymtm2004-03-271-1/+1
| | | | 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 Refactor and, among other things, get rid of insane nesting levels.mtm2004-02-181-810/+300
| | | | | | | 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.
* 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.
* 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-301-20/+47
| | | | | | | | | | 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.
* Fix the wrapper function around signals so that a signal handlingmtm2003-12-091-25/+1
| | | | | thread on one of the mutex or condition variable queues is removed from those queues before the real signal handler is called.
* Change all instances of THR_LOCK/UNLOCK, etc to UMTX_*.mtm2003-07-061-2/+2
| | | | | It is a more acurate description of the locks they operate on.
* _pthread_mutex_trylock() is another internal libc function that must blockmtm2003-07-031-0/+8
| | | | signals.
* Begin making libthr async signal safe.mtm2003-07-021-2/+22
| | | | | | | | Create a private, single underscore, version of pthread_mutex_unlock for libc. pthread_mutex_lock already has one. These versions are different from the ones that applications will link against because they block all signals from the time a call to lock the mutex is made until it is successfully unlocked.
* Do not attempt to reque a thread on a mutex queue. It may be thatmtm2003-07-011-1/+1
| | | | | | | | | a thread receives a spurious wakeup from sigtimedwait(), so make sure that the call to the queueing code is called only once before entering the loop (not in the loop). This should fix some fatal errors people are seeing with messages stating the thread is already on the mutex queue. These errors may still be triggered from signal handlers; however, since that part of the code is not locked down yet.
* Catchup with _thread_suspend() changes.mtm2003-06-301-1/+5
|
* Sweep through pthread locking and use the new locking primitives formtm2003-06-291-2/+2
| | | | libthr.
* Consolidate static_init() and static_init_private into one function.mtm2003-06-021-17/+11
| | | | The behaviour of this function is controlled by the argument: private.
* I botched one of my committs in the last round. Fix it.mtm2003-05-311-10/+8
|
* Make the mutex static initializers look more like the one formtm2003-05-291-25/+19
| | | | | | | | | condition variables. Cosmetic. Explicitly compare against PTHREAD_MUTEX_INITIALIZER. We shouldn't encourage calls to the mutex functions with null pointers to mutexes. Approved by: re/jhb
* Make WARNS2 clean. The fixes mostly included:mtm2003-05-231-2/+4
| | | | | | | | o removed unused variables o explicit inclusion of header files o prototypes for externally defined functions Approved by: re/blanket libthr
* Insert a debugging aid:mtm2003-05-211-1/+9
| | | | | | | | When in either the mutex or cond queue we notice that the thread is already on one of the queues, don't just simply abort(). Print out the thread's identifiers and what queue it was on. Approved by: markm/mentor, re/blanket libthr
* msg1mtm2003-05-121-263/+129
|
* o Correct a debug message that refered to the wrong functionmtm2003-05-061-1/+1
| | | | | | | o Remove an unncecesary if clause Approved by: markm (mentor)(implicit) Reviewd by: jeff
* - Define curthread as _get_curthread() and remove all direct calls tojeff2003-04-021-8/+5
| | | | | | | _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-199/+1328
| | | | | | | 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/+432
adaptation of libc_r for the thr system call interface. This is beta quality code.
OpenPOWER on IntegriCloud