summaryrefslogtreecommitdiffstats
path: root/lib/librthread/Makefile
AgeCommit message (Collapse)AuthorFilesLines
2020-02-06Instead of opting in to futexes on archs with atomics opt out on archsjsg1-10/+7
without atomics, a smaller list. ok mpi@ visa@
2019-02-13New futex(2) based rwlock implementation based on the mutex code.mpi1-4/+6
This implementation reduces contention because threads no longer need to spin calling sched_yield(2) before going to sleep. Tested by many, thanks! ok visa@, pirofti@
2019-01-12Move sigwait(3) from libpthread to libcjca1-2/+1
POSIX wants it in libc, that's where the function can be found on other systems. Reported by naddy@, input from naddy@ and guenther@. "looks ok" guenther@, ok deraadt@ Note: riding the libc/libpthread major cranks earlier today.
2018-10-21Switch alpha to futex(2) based condvars, mutexes and semaphores.visa1-5/+6
From Brad, tested by Miod, OK kettenis@
2018-10-15Switch powerpc to futex(2) based condvars, mutexes and semaphores.visa1-2/+2
From Brad, OK mpi@ kettenis@
2018-09-24enable futex(2) based mutexes on armv7 and use futex based semaphores injsg1-3/+3
librthread on armv7 as well from brad ok visa@ kettenis@ mpi@
2018-06-08New semaphore implementation making sem_post async-safe.pirofti1-2/+11
POSIX dictates that sem_post() needs to be async-safe here[0] and is thus included in the list of safe functions to call from within a signal handler here[1]. The old semaphore implementation is using spinlocks and __thrsleep to synchronize between threads. Let's say there are two threads: T0 and T1 and the semaphore has V=0. T1 calls sem_wait() and it will now sleep (spinlock) until someone else sem_post()'s. Let's say T0 sends a signal to T1 and exits. The signal handler calls sem_post() which is meant to unblock T1 by incrementing V. With the old semaphore implementation we we are now in a deadlock as sem_post spinlocks on the same lock. The new implementation does not suffer from this defect as it uses futexes to resolve locking and thus sem_post does not need to spin. Besides fixing this defect and making us POSIX compliant, this should also improve performance as there should be less context switching and thus less time spent in the kernel. For architectures that do not provied futexes and atomic operations, the old implementation will be used and it is now being renamed to rthread_sem_compat as discussed with mpi@. [0] -- http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_post.html [1] -- http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html OK visa@, mpi@, guenther@
2017-10-15Move the thread-related .h files to /usr/src/include/, since theguenther1-2/+1
implementation is now spread between libc and librthread. No changes to the content ok mpi@
2017-09-05Move mutex, condvar, and thread-specific data routes, pthread_once, andguenther1-18/+1
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@
2017-07-04Enable the use of futex(2) in librthread on mips64.visa1-2/+3
OK mpi@, deraadt@
2017-06-01Re-enabled futex based condvar & mutexes, they are not the cause ofmpi1-2/+9
vmd(8)'s regression.
2017-06-01New condvar introduced a regression with vmd(8), revert until it is found.mpi1-9/+2
Reported by Gregor Best.
2017-05-29Enable futex-based mutex and condvar.mpi1-2/+9
ok everybody
2016-06-01implicit function declaration is the error we really want, not thetedu1-2/+2
annoying strict prototypes
2016-05-07Use a Thread Information Block in both single and multi-threaded programs.guenther1-4/+5
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@
2016-04-02Wrap <pthread.h> and <pthread_np.h> to eliminate PLT entries for internalguenther1-2/+5
references. Use _thread_pagesize for the semaphore mmap size instead of calling getpagesize() each time. ok beck@
2015-05-19Instead of testing for __ELF__ and/or vax, leave out the bits for interfacingguenther1-1/+5
with ld.so locking whenever building NOPIC pointless use of __ELF__ noted by brad@ ok miod@
2014-07-16zap trailing newlines; "go for it" deraadtokan1-2/+1
2014-07-10__tfork_thread is in libc, so move the manpage over tooguenther1-4/+1
ok deraadt@
2013-08-06Remove support for COMPILER_VERSION == gcc2.miod1-8/+2
Change the logic depending upon COMPILER_VERSION everywhere, to assume gcc4 is the norm and to explicitely test for gcc3 when a different behaviour is required. No functional change intended. Be sure to `make install' in share/mk before attempting to do anything.
2013-07-05ELF_TOOLCHAIN bye bye.miod1-4/+3
2013-06-17Add support for the _POSIX_CPUTIME and _POSIX_THREAD_CPUTIME options,guenther1-1/+2
including CLOCK_{PROCESS,THREAD}_CPUTIME_ID constants and {clock,pthread}_getcpuclockid() functions. Worked out at t2k13 with help from tedu@ and matthew@ and testing by aja@ ok matthew@
2012-11-22Do not pass -Wmissing-prototypes when building on a non-ELF platform withmiod1-3/+4
gcc 3 as the compiler. The way constructors are built triggers this warning, which is fatal because of -Werror. ok espie@ guenther@
2012-09-12Define empty CDIAGFLAGS for programs that use Werror.haesbaert1-1/+2
Makes "make build" build with WARNINGS=Yes on amd64. ok espie
2012-08-15A couple small but long anticipated changes:matthew1-2/+2
- Link libpthread.so with -znodlopen. Because libpthread overrides the weak symbols in libc, we can't allow it to be dynamically loaded or else libc's weak symbols might have already been resolved by ld.so. (Also, major bump because this is technically a backwards incompat change in behavior, although dlopen()ing libpthread never really worked.) - Link libc.so with -nodefaultlibs -lgcc. This ensures that libc doesn't try to link against itself (which ld.so wouldn't like). - Change GCC 4 to link shared objects with -lpthread and -lc as appropriate, now that there's no issues with doing so. This means that it's no longer necessary to patch software to use -pthread instead of -lpthread. (Ports tree rejoice!) Also, to preemptively answer this question: No, this does not eliminate the need for LD_PRELOAD=libpthread.so. That's a separate issue that won't be resolved until we eliminate libc's weak symbols. Discussed extensively on email and icb over the past few months. ok deraadt
2012-08-02remove leftover NOLINT, WANTLINT, LINTFLAGS, LOBJ vars and lint targets.okan1-3/+1
ok guenther@
2012-05-03Add pthread spinlock support.pirofti1-1/+2
Implementation, documentation and naive regression tests for: - pthread_spin_init() - pthread_spin_destroy() - pthread_spin_lock() - pthread_spin_trylock() - pthread_spin_unlock() Implementation okay guenther@, documentation okay jmc@.
2012-04-11Add pthread barrier support.pirofti1-1/+3
Implementation and documentation for: - pthread_barrier_init() - pthread_barrier_destroy() - pthread_barrier_wait() - pthread_barrierattr_init() - pthread_barrierattr_destroy() - pthread_barrierattr_getpshared() - pthread_barrierattr_setpshared() Currently only private barriers are supported. Okay guenther@.
2012-03-22Move __tfork_thread() from rthreads (libpthread) to libc so thatguenther1-2/+2
it can be used for not-strictly-threading purposes ok matthew@ kurt@
2012-02-23Add pthread_condattr_{get,set}clock(), requested by aja@guenther1-7/+22
Add pthread_mutex_timedlock(), requested by dcoppa@
2012-02-19Extend miod's fix CFLAGS fix to all gcc2 platforms (suggested by Tobiasguenther1-3/+5
Ulmer). Only pull in bsd.lib.mk once to avoid linking objects twice
2012-02-18Work around compiler confusion while building rthread.o on vax.miod1-2/+6
2012-02-15Nothing important, just switching from pthreads to rthreadsguenther1-2/+7
2012-01-04Split out the semaphore functions.mpi1-2/+3
ok guenther@
2011-12-22Add pthread_mutex_{get,set}prioceiling()guenther1-2/+2
2011-12-21Split out the pthread_rwlock* and pthread_once() functions from rthread_sync.cguenther1-2/+3
to new files rthread_rwlock.c, rthread_rwlockattr.c, and rthread_once.c
2011-12-21Split out the pthread_mutexattr_* functions from rthread_sync.c toguenther1-2/+2
new file rthread_mutexattr.c. Add basic implementations of pthread_mutexattr_{set,get}{protocol,prioceiling} Requested by aja
2011-12-05Implement cancelation for the basic syscall cancelation points,guenther1-2/+3
using previously allocated SIGTHR to interrupt in-process syscalls and fixing the spelling of "cancelled" along the way. Modeled on FreeBSD's libthr
2011-11-27Set the initfirst and nodelete flags on the shared library, in anticipationguenther1-1/+2
of support in ld.so
2011-11-06Copy support for sched_get_priority_{min,max} from libpthread.guenther1-2/+2
Requested by many to ease substitution of librthread for libpthread
2011-10-17Use __tfork, __get_tcb, and __set_tcb to have a real TCB and per-threadguenther1-3/+6
errno. The ASM bits for _cerror are sketchy or missing for some archs but that can be corrected in-tree.
2010-02-03Use MACHINE_CPU instead of MACHINE_ARCH to pick the correct machine dependentmiod1-2/+2
files or directories when applicable. The inspiration and name of MACHINE_CPU come from NetBSD, although the way to provide it to Makefiles is completely different. ok kettenis@
2009-11-27Change threxit() to take a pointer to a pid_t to zero out from theguenther1-2/+2
kernel so that librthread can detect when a thread is completely done with its stack without need a kqueue. The dying thread moves itself to a GC list, other threads scan the GC list on pthread_create() and pthread_join() and free the stack and handle once the thread's thread id is zeroed. "get it in" deraadt@, tedu@, cheers by others
2009-10-21Add f*lockfile() routines to librthreadguenther1-2/+2
ok kurt@
2009-02-20apparently all the other libraries get linted, so I'll just have to live with ittedu1-2/+2
2009-02-20the lint warnings are more annoying than anything else. we already have a full set of warnings from the compilertedu1-2/+2
2008-06-05- Add fork/vfork wrapper functions to reset state in the child process.kurt1-2/+2
- Make an effort to protect important libc and ld.so critical areas during the fork(2)/vfork(2) sys call. - Add pthread_atfork(3) implementation based on Daniel Eischen's code. Original diff by Philip Guenther <guenther at gmail.com> with some additions and refinements by me. Positive test report from brad@ with many kde apps. fork(2) and pthread_atfork(3) pthread regresses pass. okay tedu@, kettenis@, marc@
2006-01-05add -Wstrict-prototypes -Wmissing-prototypes -Wsign-comparemarc1-2/+6
Minor tweaks to compile with the above, primarily in fixing the conflicts between semaphore.h and rthread.h "i like the additional warnings" tedu@
2006-01-04Cleanup struct pthread and stack after thread exits. This version doesotto1-2/+3
not use a separate reaper thread. ok tedu@ marc@
2006-01-01thread stack handling changes. Add guard zones and allow stackmarc1-2/+2
size (and guard zone size) to be set using pthread_attr. Guard zones are specified in bytes, but implemented in terms of a page size. OK Otto@