summaryrefslogtreecommitdiffstats
path: root/lib/librthread/rthread_fork.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Replace the malloc spinlock with a mutex. This lock is held over system callskettenis2016-01-271-2/+5
| | | | | | | | | | | | | which run for many cycles and may even sleep. This leads to other threads spinning for a long time waiting on the lock. Using a mutex means those threads go to sleep and get woken up when the lock is released, which results in a lot less CPU usage. More work is needed to improve the performance of threaded code that suffers from malloc lock contention, but this diff makes ports like Firefox significantly more usable. Tested by many. ok mpi@, guenther@, tedu@, jca@
* ld.so no longer needs or uses a bind lock, so stop setting it. Thisguenther2015-10-181-23/+3
| | | | | eliminates a chunk of complexity from the libpthread init and the fork wrapper, as it was the bind lock that needed prebinding before use.
* Instead of testing for __ELF__ and/or vax, leave out the bits for interfacingguenther2015-05-191-8/+8
| | | | | | | with ld.so locking whenever building NOPIC pointless use of __ELF__ noted by brad@ ok miod@
* In the child after fork, the dl lock has to be forced as its inner spinlockguenther2015-05-101-5/+9
| | | | | | may have been grabbed by another thread in the parent before the fork problem report from dcoppa@, ok kettenis@
* Make pthread_atfork() track the DSO that called it like atexit() does,guenther2015-04-071-52/+4
| | | | | | | | | | unregistering callbacks if the DSO is unloaded. Move the callback handling from libpthread to libc, though libpthread still overrides the inner call to handle locking and thread-library reinitialization. Major version bump for both libc and libpthread. verification that this fixes various ports ajacoutot@ asm assistance miod@; ok millert@ deraadt@
* Don't try to reuse _initial_thread in the fork() wrapper, as theguenther2013-11-291-3/+3
| | | | | | | | | thread's existing handle must continue to be valid and it didn't fully 'change' the thread handle anyway. For pthread_main_np(), use a new flag, THREAD_ORIGINAL, to indicate that the flagged thread is the original thread for *this* process. Fixes some ConsoleKit failures according to aja@
* nmask and omask only used on ELF. Noted by todd@guenther2013-06-251-1/+3
|
* The bind lock must only be grabbed with all signals masked.guenther2013-06-211-3/+10
| | | | | backtrace of example case from sthen@ ok kettenis@ millert@
* cleanup and consolidate the spinlock_lock (what a name!) code.tedu2013-06-011-5/+5
| | | | | | | | | | 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)
* We want to check that the dynamic linker is available at run-time, somatthew2012-08-221-9/+19
| | | | | | | | we should actually check for _DYNAMIC at run-time rather than checking for __PIC__ at compile time, since the two are actually independent. Problem and solution identified by guenther; minor tweaks by me. ok guenther
* Test for __PIC__ instead of PIC in preparation for eliminating -DPICmatthew2012-08-221-5/+5
| | | | | | from bsd.lib.mk for C source files. ok deraadt, pascal
* Move <machine/spinlock.h> into rthread.h; strip out unnecessary #includesguenther2011-11-061-5/+1
|
* Change threxit() to take a pointer to a pid_t to zero out from theguenther2009-11-271-4/+1
| | | | | | | | | | 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
* After forking, the child is single threaded, so tell libc that. Thisguenther2009-10-211-1/+4
| | | | | | is needed to avoid deadlocks in popen() on FILE locking. ok kurt@
* - Add fork/vfork wrapper functions to reset state in the child process.kurt2008-06-051-0/+177
- 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@