summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread/thr_private.h
Commit message (Collapse)AuthorAgeFilesLines
* Use umtx to implement process sharable semaphore, to make this work,davidxu2010-01-051-0/+17
| | | | | | | | | | | | | | | | | | | | | | 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@
* Make openat(2) a cancellation point.jilles2009-10-111-0/+1
| | | | | | | This is required by POSIX and matches open(2). Reviewed by: kib, jhb MFC after: 1 month
* Make pthread_cleanup_push() and pthread_cleanup_pop() as a pair of macros,davidxu2008-06-091-6/+9
| | | | | | | use stack space to keep cleanup information, this eliminates overhead of calling malloc() and free() in thread library. Discussed on: thread@
* - Reduce function call overhead for uncontended case.davidxu2008-05-291-10/+0
| | | | | - Remove unused flags MUTEX_FLAGS_* and their code. - Check validity of the timeout parameter in mutex_self_lock().
* Use UMTX_OP_WAIT_UINT_PRIVATE and UMTX_OP_WAKE_PRIVATE to savedavidxu2008-04-291-1/+1
| | | | time in kernel(avoid VM lookup).
* put THR_CRITICAL_LEAVE into do .. while statement.davidxu2008-04-031-2/+4
|
* add __hidden suffix to _umtx_op_err, this eliminates PLT.davidxu2008-04-031-1/+1
|
* Add pthread_setaffinity_np and pthread_getaffinity_np to libc namespace.davidxu2008-04-021-2/+0
|
* Remove unused functions.davidxu2008-04-021-2/+0
|
* Replace function _umtx_op with _umtx_op_err, the later function directlydavidxu2008-04-021-0/+2
| | | | | | returns errno, because errno can be mucked by user's signal handler and most of pthread api heavily depends on errno to be correct, this change should improve stability of the thread library.
* Replace userland rwlock with a pure kernel based rwlock, the newdavidxu2008-04-021-6/+1
| | | | | | implementation does not switch pointers when it resumes waiters. Asked by: jeff
* Rewrite rwlock to user atomic operations to change rwlock state, thisdavidxu2008-03-311-1/+5
| | | | | | | eliminates internal mutex lock contention when most rwlock operations are read. Orignal patch provided by: jeff
* Use cpuset defined in pthread_attr for newly created thread, for now,davidxu2008-03-051-0/+5
| | | | | | | we set scheduling parameters and cpu binding fully in userland, and because default scheduling policy is SCHED_RR (time-sharing), we set default sched_inherit to PTHREAD_SCHED_INHERIT, this saves a system call.
* If a new thread is created, it inherits current thread's signal masks,davidxu2008-03-041-0/+6
| | | | | | | | however if current thread is executing cancellation handler, signal SIGCANCEL may have already been blocked, this is unexpected, unblock the signal in new thread if this happens. MFC after: 1 week
* Include cpuset.h, unbreak compiling.davidxu2008-03-041-0/+2
|
* implement pthread_attr_getaffinity_np and pthread_attr_setaffinity_np.davidxu2008-03-041-0/+2
|
* 1. Add function pthread_mutex_setspinloops_np to turn a mutex's spindavidxu2007-12-141-0/+2
| | | | | | | | loop count. 2. Add function pthread_mutex_setyieldloops_np to turn a mutex's yield loop count. 3. Make environment variables PTHREAD_SPINLOOPS and PTHREAD_YIELDLOOPS to be only used for turnning PTHREAD_MUTEX_ADAPTIVE_NP mutex.
* Remove umtx_t definition, use type long directly, add wrapper functiondavidxu2007-11-211-1/+1
| | | | | _thr_umtx_wait_uint() for umtx operation UMTX_OP_WAIT_UINT, use the function in semaphore operations, this fixed compiler warnings.
* Add my recent work of adaptive spin mutex code. Use two environments variabledavidxu2007-10-301-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | to tune pthread mutex performance: 1. LIBPTHREAD_SPINLOOPS If a pthread mutex is being locked by another thread, this environment variable sets total number of spin loops before the current thread sleeps in kernel, this saves a syscall overhead if the mutex will be unlocked very soon (well written application code). 2. LIBPTHREAD_YIELDLOOPS If a pthread mutex is being locked by other threads, this environment variable sets total number of sched_yield() loops before the currrent thread sleeps in kernel. if a pthread mutex is locked, the current thread gives up cpu, but will not sleep in kernel, this means, current thread does not set contention bit in mutex, but let lock owner to run again if the owner is on kernel's run queue, and when lock owner unlocks the mutex, it does not need to enter kernel and do lots of work to resume mutex waiters, in some cases, this saves lots of syscall overheads for mutex owner. In my practice, sometimes LIBPTHREAD_YIELDLOOPS can massively improve performance than LIBPTHREAD_SPINLOOPS, this depends on application. These two environments are global to all pthread mutex, there is no interface to set them for each pthread mutex, the default values are zero, this means spinning is turned off by default.
* Output error message to STDERR_FILENO.davidxu2007-08-071-1/+1
| | | | Approved by: re (bmah)
* Check environment variable PTHREAD_ADAPTIVE_SPIN, if it is set, usedavidxu2006-12-201-0/+1
| | | | it as a default spin cycle count.
* - Remove variable _thr_scope_system, all threads are system scope.davidxu2006-12-151-2/+1
| | | | | - Rename _thr_smp_cpus to boolean variable _thr_is_smp. - Define CPU_SPINWAIT macro for each arch, only X86 supports it.
* Use ucond to implement barrier.davidxu2006-12-051-4/+5
|
* Use kernel provided userspace condition variable to implement pthreaddavidxu2006-12-041-6/+6
| | | | condition variable.
* Eliminate atomic operations in thread cancellation functions, it shoulddavidxu2006-11-241-18/+22
| | | | reduce overheads of cancellation points.
* Use type pthread_state for thread state.davidxu2006-10-131-1/+1
|
* use rtprio_thread system call to get or set thread priority.davidxu2006-09-211-0/+6
|
* Replace internal usage of struct umtx with umutex which can supportsdavidxu2006-09-061-21/+21
| | | | real-time if we want, no functionality is changed.
* Use umutex APIs to implement pthread_mutex, member pp_mutexq is addeddavidxu2006-08-281-18/+14
| | | | | | into pthread structure to keep track of locked PTHREAD_PRIO_PROTECT mutex, no real mutex code is changed, the mutex locking and unlocking code should has same performance as before.
* Axe unused member field.davidxu2006-08-081-10/+2
|
* Get number of CPUs and ignore spin count on single processor machine.davidxu2006-08-081-0/+2
|
* Use kernel facilities to support real-time scheduling.davidxu2006-07-121-28/+2
|
* Remove unused member.davidxu2006-06-031-1/+0
|
* Remove unused member field m_queue.davidxu2006-06-021-1/+0
|
* s/long/int.davidxu2006-04-271-2/+2
|
* - Use same priority range returned by kernel's sched_get_priority_min()davidxu2006-04-271-28/+21
| | | | | and sched_get_priority_max() syscalls. - Remove unused fields from structure pthread_attr.
* Do not check validity of timeout if a mutex can be acquired immediately.davidxu2006-04-081-2/+2
| | | | | Completly drop recursive mutex in pthread_cond_wait and restore recursive after resumption. Reorganize code to make gcc to generate better code.
* WARNS level 4 cleanup.davidxu2006-04-041-89/+11
|
* Remove priority mutex code because it does not work correctly,davidxu2006-03-271-30/+10
| | | | | | | | | to make it work, turnstile like mechanism to support priority propagating and other realtime scheduling options in kernel should be available to userland mutex, for the moment, I just want to make libthr be simple and efficient thread library. Discussed with: deischen, julian
* Add locking support for rtld.davidxu2006-03-251-0/+7
|
* Rework last change of pthread_once, create a function _thr_once_init todavidxu2006-02-151-2/+1
| | | | reinitialize its internal locks.
* After fork(), reinitialize internal locks for pthread_once().davidxu2006-02-151-0/+2
|
* Now, thread name is stored in kernel, userland no longer has to keep it.davidxu2006-02-051-1/+0
|
* Use macro STATIC_LIB_REQUIRE to declare a symbol should be linked intodavidxu2006-01-101-0/+6
| | | | static binary.
* Tweak macro THR_LOCK_RELEASE a bit for non-PTHREAD_INVARIANTS case.davidxu2006-01-091-7/+14
|
* Refine thread suspension code, now thread suspension is a blockabledavidxu2006-01-051-3/+16
| | | | | | | operation, the caller is blocked util target threads are really suspended, also avoid suspending a thread when it is holding a critical lock. Fix a bug in _thr_ref_delete which tests a never set flag.
* Hide umtx API symbols as well.davidxu2005-12-211-1/+4
|
* 1. Retire macro SCLASS, instead simply use language keyword anddavidxu2005-12-211-109/+72
| | | | | put variables in thr_init.c. 2. Hide all global symbols which won't be exported.
* Update copyright.davidxu2005-12-171-18/+15
|
* Add code to handle timer_delete(). The timer wrapper code is completelydavidxu2005-11-011-2/+3
| | | | | | rewritten, now timers created with same sigev_notify_attributes will run in same thread, this allows user to organize which timers can run in same thread to save some thread resource.
OpenPOWER on IntegriCloud