summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/sem_new.c
Commit message (Collapse)AuthorAgeFilesLines
* preserve errno when processing error cases.davidxu2010-01-181-1/+3
|
* Also call sem_module_init in sem_close to initialize mutexdavidxu2010-01-151-0/+2
| | | | with some attributes.
* Return SEM_FAILED instead of NULL, though there are same, but thedavidxu2010-01-131-2/+3
| | | | | SEM_FAILED is more suitable name. In function, sem_close(), always set errno on error.
* Don't forget to use fourth argument if O_CREAT is set in argument oflag.davidxu2010-01-071-1/+3
| | | | The fourth specifies initial value for the semaphore.
* More cleanup, remove _libc prefix because libthr no longer has stubsdavidxu2010-01-051-31/+21
| | | | referencing them.
* Don't check has_waiters twice, inline some small functions.davidxu2010-01-051-8/+5
| | | | | | performance result on my machine: mutex Elapsed: 902115 us; per iteration: 90 ns. semaphore Elapsed: 958780 us; per iteration: 95 ns.
* Use umtx to implement process sharable semaphore, to make this work,davidxu2010-01-051-0/+470
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@
OpenPOWER on IntegriCloud