summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread/thr_sem.c
Commit message (Collapse)AuthorAgeFilesLines
* Use umtx to implement process sharable semaphore, to make this work,davidxu2010-01-051-217/+41
| | | | | | | | | | | | | | | | | | | | | | now type sema_t is a structure which can be put in a shared memory area, and multiple processes can operate it concurrently. User can either use mmap(MAP_SHARED) + sem_init(pshared=1) or use sem_open() to initialize a shared semaphore. Named semaphore uses file system and is located in /tmp directory, and its file name is prefixed with 'SEMD', so now it is chroot or jail friendly. In simplist cases, both for named and un-named semaphore, userland code does not have to enter kernel to reduce/increase semaphore's count. The semaphore is designed to be crash-safe, it means even if an application is crashed in the middle of operating semaphore, the semaphore state is still safely recovered by later use, there is no waiter counter maintained by userland code. The main semaphore code is in libc and libthr only has some necessary stubs, this makes it possible that a non-threaded application can use semaphore without linking to thread library. Old semaphore implementation is kept libc to maintain binary compatibility. The kernel ksem API is no longer used in the new implemenation. Discussed on: threads@
* Use UMTX_OP_WAIT_UINT_PRIVATE and UMTX_OP_WAKE_PRIVATE to savedavidxu2008-04-291-4/+4
| | | | time in kernel(avoid VM lookup).
* If a thread is cancelled, it may have already consumed a umtx_wake,davidxu2008-03-111-0/+2
| | | | check waiter and semphore counter to see if we may wake up next thread.
* sem_post() requires to return -1 on error.davidxu2008-01-071-2/+2
|
* Simplify code, fix a thread cancellation bug in sem_wait and sem_timedwait.davidxu2007-11-231-21/+15
|
* Reuse nwaiter member field to record number of waiters, in sem_post(),davidxu2007-11-211-7/+31
| | | | | this should reduce the chance having to do a syscall when there is no waiter in the semaphore.
* Remove umtx_t definition, use type long directly, add wrapper functiondavidxu2007-11-211-3/+3
| | | | | _thr_umtx_wait_uint() for umtx operation UMTX_OP_WAIT_UINT, use the function in semaphore operations, this fixed compiler warnings.
* Eliminate atomic operations in thread cancellation functions, it shoulddavidxu2006-11-241-10/+10
| | | | reduce overheads of cancellation points.
* Replace internal usage of struct umtx with umutex which can supportsdavidxu2006-09-061-1/+1
| | | | real-time if we want, no functionality is changed.
* Fix prototype mismatch.des2006-03-281-1/+2
|
* Include needed headers that were obtained through <pthread.h>. Sort headersstefanf2005-09-011-0/+1
| | | | while here.
* Import my recent 1:1 threading working. some features improved includes:davidxu2005-04-021-159/+173
| | | | | | | | | | | | | | | | 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 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
|
* - Define curthread as _get_curthread() and remove all direct calls tojeff2003-04-021-2/+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/+257
adaptation of libc_r for the thr system call interface. This is beta quality code.
OpenPOWER on IntegriCloud