summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/sem.c
Commit message (Collapse)AuthorAgeFilesLines
* In revision 231989, we pass a 16-bit clock ID into kernel, howeverdavidxu2012-02-251-10/+16
| | | | | | | | | | | | according to POSIX document, the clock ID may be dynamically allocated, it unlikely will be in 64K forever. To make it future compatible, we pack all timeout information into a new structure called _umtx_time, and use fourth argument as a size indication, a zero means it is old code using timespec as timeout value, but the new structure also includes flags and a clock ID, so the size argument is different than before, and it is non-zero. With this change, it is possible that a thread can sleep on any supported clock, though current kernel code does not have such a POSIX clock driver system.
* Insert read memory barriers.davidxu2012-01-161-1/+1
|
* To support stack unwinding for cancellation points, add -fexceptions flagdavidxu2010-09-251-22/+9
| | | | | | | for them, two functions _pthread_cancel_enter and _pthread_cancel_leave are added to let thread enter and leave a cancellation point, it also makes it possible that other functions can be cancellation points in libraries without having to be rewritten in libthr.
* Reapply r201145 to lib/libc/gen/sem.cantoine2010-01-231-1/+1
|
* forgot to remove SYM_FBP10. ;-)davidxu2010-01-051-1/+0
|
* Remove unused macros.davidxu2010-01-051-5/+0
|
* Use umtx to implement process sharable semaphore, to make this work,davidxu2010-01-051-58/+174
| | | | | | | | | | | | | | | | | | | | | | 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@
* (S)LIST_HEAD_INITIALIZER takes a (S)LIST_HEAD as an argument.antoine2009-12-281-1/+1
| | | | | | | | | Fix some wrong usages. Note: this does not affect generated binaries as this argument is not used. PR: 137213 Submitted by: Eygene Ryabinkin (initial version) MFC after: 1 month
* Make __sem_timedwait() consistent with the sem_timedwait() prototype.stefanf2005-10-181-1/+1
|
* Include <sys/types.h> and <limits.h> ourselves, don't assume they are includedstefanf2005-08-201-0/+1
| | | | | | | | | | through <pthread.h>. gen/sem.c: Prerequisite for <_semaphore.h> net/getprotoent.c: USHRT_MAX net/getservent.c: USHRT_MAX stdio/ungetwc.c: MB_LEN_MAX stdio/vfwscanf.c: MB_LEN_MAX
* Prevent memory leak on sem_destroy() by destroying the semaphore'sdeischen2004-02-061-1/+4
| | | | internal mutex and CV.
* Only allow the semaphore to be taken when the value is positive.deischen2004-02-061-2/+1
| | | | | | Don't decrement it twice when it is taken. Reported by: kris
* Correct check for invalid semaphore on sem_destroy() (s/==/!=/).deischen2004-02-051-1/+1
| | | | Reported by: kris
* Correct the weak reference for sem_unlink.deischen2004-02-051-1/+1
|
* Allow libc's version of sem_trywait() to work for non-pshared mutexes.deischen2004-02-041-2/+17
|
* Modify the implementation of libc semaphores so that they can bedeischen2004-02-031-146/+132
| | | | | | | | | | | | overridden by the threads library to provide a userland version of non-pshared semaphores and cancellation points. Also add a sem_timedwait(). The libc version of semaphores always uses kernel semaphores regardless of whether pshared is set or not. When threads are not present, it is difficult to get sem_wait() or sem_timedwait() to do the right thing (since pthread_cond_timedwait() and pthread_cond_wait() are stubs in libc and just return immediately).
* Backout revision 1.6, because some stub functions not in libc, anddavidxu2004-01-171-18/+2
| | | | | non-threaded won't build. The cancellation point support should be further discussed.
* Enable cancellation point in sem_wait, it is required by POSIX.davidxu2004-01-171-2/+18
| | | | | | For pshared semaphore, this commit still does not enable cancellation point, I think there should be a pthread_enter_cancellation_point_np for libc to implement a safe cancellation point.
* Eliminate 61 warnings emitted at WARNS=2 (leaving 53 to go).nectar2003-02-161-0/+2
| | | | | | | Only warnings that could be fixed without changing the generated object code and without restructuring the source code have been handled. Reviewed by: /sbin/md5
* Add the newly created semaphore to the named semaphore list in sem_open()tjr2003-01-141-1/+2
| | | | | | so that multiple opens of the same semaphore without an intervening sem_close() return the same object, and so that sem_close() does not segfault while trying to remove the item from the list.
* Add restrict type-qualifier to sem_getvalue().mike2002-10-041-1/+1
|
* Welcome the sem_ API to libc!alfred2002-09-191-0/+354
OpenPOWER on IntegriCloud