summaryrefslogtreecommitdiffstats
path: root/lib/librthread/rthread_sync.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Move mutex, condvar, and thread-specific data routes, pthread_once, andguenther2017-09-051-693/+0
| | | | | | | | pthread_exit from libpthread to libc, along with low-level bits to support them. Major bump to both libc and libpthread. Requested by libressl team. Ports testing by naddy@ ok kettenis@
* not all the world is an i386. Back out breakage.deraadt2017-07-291-3/+1
|
* Use memory barriers to prevent pointer use before initialization.pirofti2017-07-291-1/+3
| | | | | | | | | | | This work was sparked by the topic posted on hn by wuch. I am still not sure that this fixes the defect he claims to have observed because I was not able to create a proper regress test for it to manifest. To that end, a proof of concept is more than welcomed! Thank you for the report! Discussed with and OK kettenis@, tedu@.
* Get rid of ticket support, replace "struct _spinlock" with "_atomic_lock_t".akfaew2016-09-041-9/+8
| | | | ok tedu@
* Remove _USING_TICKETS, it's defined as 0. No functional change.akfaew2016-09-031-8/+7
| | | | ok tedu@ mpi@
* Use a Thread Information Block in both single and multi-threaded programs.guenther2016-05-071-13/+20
| | | | | | | | | | | | | | | | | This stores errno, the cancelation flags, and related bits for each thread and is allocated by ld.so or libc.a. This is an ABI break from 5.9-stable! Make libpthread dlopen'able by moving the cancelation wrappers into libc and doing locking and fork/errno handling via callbacks that libpthread registers when it first initializes. 'errno' *must* be declared via <errno.h> now! Clean up libpthread's symbol exports like libc. On powerpc, offset the TIB/TCB/TLS data from the register per the ELF spec. Testing by various, particularly sthen@ and patrick@ ok kettenis@
* PROTO_NORMAL(pthread_cond_signal) requires DEF_STD(pthread_cond_signal)guenther2016-04-151-1/+2
|
* Wrap <pthread.h> and <pthread_np.h> to eliminate PLT entries for internalguenther2016-04-021-1/+9
| | | | | | | references. Use _thread_pagesize for the semaphore mmap size instead of calling getpagesize() each time. ok beck@
* something's not quite right yet. ticket locks result in more CPU usagetedu2013-06-011-9/+10
| | | | | | and spinning in kernel. partially back out, but in a way that makes going forward again easy. seen by ajacoutot
* cleanup and consolidate the spinlock_lock (what a name!) code.tedu2013-06-011-11/+11
| | | | | | | | | | it's now atomic_lock to better reflect its usage, and librthread now features a new spinlock that's really a ticket lock. thrlseep can handle both types of lock via a flag in the clock arg. (temp back compat hack) remove some old stuff that's accumulated along the way and no longer used. some feedback from dlg, who is concerned with all things ticket lock. (you need to boot a new kernel before installing librthread)
* fix wrong fn name in debugtedu2013-06-011-2/+2
|
* Add new mutex type, PTHREAD_MUTEX_STRICT_NP which checks for applicationkurt2012-04-141-3/+8
| | | | | | | | errors similar to PTHREAD_MUTEX_ERRORCHECK, however upon error it aborts. The rational is that many applications don't check the return values on pthread functions and will miss the errors that ERRORCHECK returns. PTHREAD_MUTEX_STRICT_NP will be our default mutex type for awhile okay guenther@ dcoppa@
* Use PTHREAD_MUTEX_DEFAULT in static init and mutexattr_init. If thekurt2012-04-131-5/+13
| | | | | | default mutex type changes to NORMAL, when there is an uninitialized mutex provided to unlock, allow it to succeed similar to an unlocked mutex. For other cases abort instead of segfault. okay guenther@
* Per POSIX, PTHREAD_MUTEX_NORMAL type mutexes have undefined behavior forkurt2012-04-131-7/+31
| | | | | | certain conditions. In the case of unlocking an unlocked mutex we will allow that to succeed, all other undefined behaviors will result in an immediate abort(). okay guenther@
* Our default mutex type is PTHREAD_MUTEX_ERRORCHECK, for which tryingguenther2012-02-281-1/+20
| | | | | | | | | | to unlock an uninitialized mutex is required to return EPERM, so add the necessary checks. For recursive mutexes, return an error from pthread_mutex_lock() if the count would overflow. problem observed in glib testing by aja@
* PTHREAD_MUTEX_NORMAL mutexes are supposed to self-deadlock, not abort.guenther2012-02-231-3/+16
| | | | | That deadlock can be exited via a timeout for pthread_mutex_timedlock(). Unwind all the state when pthread_mutex_timedlock() times out
* Add pthread_condattr_{get,set}clock(), requested by aja@guenther2012-02-231-36/+19
| | | | Add pthread_mutex_timedlock(), requested by dcoppa@
* @($*& Merging patches resulted in a line being duplicated instead ofguenther2012-01-251-2/+1
| | | | moved. Unlocking a spinlock twice is bad, mmkay?
* Reimplement mutexes, condvars, and rwlocks to eliminate bugs,guenther2012-01-171-44/+428
| | | | | | | | | | | | | particularly the "consume the signal you just sent" hang, and putting the wait queues in userspace. Do cancellation handling in pthread_cond_*wait(), pthread_join(), and sem_wait(). Add __ prefix to thr{sleep,wakeup,exit,sigdivert}() syscalls; add 'abort" argument to thrsleep to close cancellation race; make thr{sleep,wakeup} return errno values via *retval to avoid touching userspace errno.
* Split out the semaphore functions.mpi2012-01-041-178/+2
| | | | ok guenther@
* Split out the pthread_rwlock* and pthread_once() functions from rthread_sync.cguenther2011-12-211-275/+2
| | | | to new files rthread_rwlock.c, rthread_rwlockattr.c, and rthread_once.c
* Split out the pthread_mutexattr_* functions from rthread_sync.c toguenther2011-12-211-44/+9
| | | | | | | new file rthread_mutexattr.c. Add basic implementations of pthread_mutexattr_{set,get}{protocol,prioceiling} Requested by aja
* Move <machine/spinlock.h> into rthread.h; strip out unnecessary #includesguenther2011-11-061-10/+1
|
* Return the correct errno (EBUSY) when pthread_mutex_trylock() isguenther2011-09-221-2/+2
| | | | | called on an ERRORCHECK mutex that is locked by this thread. Problem observed by uwe@
* Add pthread_rwlock_timed{rd,wr}lock().guenther2010-04-121-3/+68
| | | | | | Avoid missed wakeups in pthread_rwlock_{rd,wr}lock() by linking the spinlocks. ok tedu@
* Convert thrsleep() to an absolute timeout with clockid to eliminate aguenther2009-11-271-26/+12
| | | | | | race condition and prep for later support of pthread_condattr_setclock() "get it in" deraadt@, tedu@, cheers by others
* pthread_rwlock_wrlock() should increment the count of writers justguenther2009-11-191-4/+3
| | | | | | once and not on every wakeup. ok kurt@
* use calloc() instead of malloc() and memset()kevlo2008-10-131-15/+8
| | | | "look good" tedu@
* fix rwlocks to work with the "initialized" form, from Philip Guenthertedu2008-02-221-3/+45
|
* _FD_LOCK/UNLOCK() is libpthread specific and not needed for librthread, sokurt2007-06-051-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | isolate its usage to libpthread only and replace with generic non-static mutex support in the one place it is needed: - remove _FD_LOCK/UNLOCK from lseek and ftruncate in libc and make the functions weak so that libpthread can override with its own new versions that do the locking. - remove _thread_fd_lock/unlock() weak functions from libc and adjust libpthread for the change. - add generic _thread_mutex_lock/unlock/destroy() weak functions in libc to support non-static mutexes in libc and add libpthread and librthread implementations for them. libc can utilize non-static mutexes via the new _MUTEX_LOCK/UNLOCK/DESTROY() macros. Actually these new macros can support both static and non-static mutexes but currently only using them for non-static. - make opendir/closedir/readdir/readdir_r/seekdir/telldir() thread-safe for both thread libraries by using a non-static mutex in the struct _dirdesc (typedef DIR), utilizing it in the *dir functions and remove remaining and incorrect _FD_LOCK/UNLOCK() use in libc. - add comments to both thread libraries to indicate libc depends on the current implementation of static mutex initialization. suggested by marc@ - major bump libc and libpthread due to function removal, structure change and weak symbol conversions. okay marc@, tedu@
* protect against races while initializing static mutexes. okay marc@ tedu@kurt2007-05-251-6/+13
|
* add -Wstrict-prototypes -Wmissing-prototypes -Wsign-comparemarc2006-01-051-2/+2
| | | | | | Minor tweaks to compile with the above, primarily in fixing the conflicts between semaphore.h and rthread.h "i like the additional warnings" tedu@
* add pthread_mutexattr_gettype.brad2005-12-311-1/+9
| | | | ok otto@
* prototype all the thread syscalls in rthread.h for now.tedu2005-12-301-7/+4
| | | | update for new thrwakeup that takes a count argument
* the story in pthread_rwlockattr_destory() shoudl be destroyedotto2005-12-291-2/+2
|
* more consistently use _rthread prefix for all not meant to be exportedtedu2005-12-221-4/+4
| | | | interfaces that aren't static, and a few that are but which will change
* update copyright to 2005tedu2005-12-191-2/+2
|
* initialize all spinlocks to _SPINLOCK_UNLOCKEDtedu2005-12-181-1/+5
|
* all is made clear: pthread_cond_timedwait takes absolute timeoutstedu2005-12-141-3/+17
|
* check for waiters when destroying a mutex or semaphoretedu2005-12-141-3/+15
|
* make the mutex unlock and sleep in pthread_cond_wait properly atomictedu2005-12-131-3/+11
|
* several silly bugs in pthread_cond_timedwait.tedu2005-12-131-5/+7
| | | | | | | 1. the time was off by a factor of 10 2. wouldn't return error code if timeout was reached 3. the big one. thrsleep syscall doesn't return EWOULDBLOCK. it returns -1 and puts the error in errno. doh.
* update thrsleep and thrwakeup - first arg changed from long to void *tedu2005-12-131-7/+7
|
* correct implementation of pthread_cond_signal. it doesn't raise the semtedu2005-12-131-4/+23
| | | | value if there are no waiters.
* add the posix semaphore functions. this lets vlc work.tedu2005-12-071-5/+89
| | | | ok brad
* add pthread_once. unfortunately, the public pthread.h headertedu2005-12-061-1/+14
| | | | defines the pthread_once_t internals, so we're stuck with them.
* add userland thread library. incomplete, but functionaltedu2005-12-031-0/+477