summaryrefslogtreecommitdiffstats
path: root/lib/librthread/rthread.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Oops, on a.out architectures __cerror() is called _cerror(). Fixmatthew2012-08-151-3/+9
| | | | | | accordingly so vax can build again. ok deraadt
* Add explicit references from rthread.o to all of the weak symbolmatthew2012-08-131-1/+71
| | | | | | | | | | | overrides provided by libpthread.a. This ensures that statically linked threaded programs use (e.g.) __cerror() from libpthread.a instead of libc.a. (Same idea previously used by libuthread.) Thanks to fgsch@ for pointing out libuthread's solution to the static linking problem. ok guenther@, tedu@;
* __tfork() needs to set the stack address of the new thread in the kernel,guenther2012-06-211-6/+4
| | | | | | | | | so that it can't get a signal while still running on the parent thread's stack. Also, pass in sizeof(struct __tfork) to provide forward compat when more members are added. This is an ABI change, so switch syscall numbers and bump lib majors this time. ok deraadt@ matthew@
* pthread_setcanceltype() shouldn't be a cancelation pointguenther2012-04-101-2/+1
| | | | ok kurt@
* Remove pthread_suspend* and related functions. This is part of thekurt2012-03-221-2/+1
| | | | rthreads major library bump from last night. okay kettenis@
* Permit recursive locking in _rthread_dl_lock(), as an so's destructorguenther2012-03-201-2/+42
| | | | | | may need to call dlclose(). problem observed by Antti Harri (iku at openbsd.fi), ok kurt@
* Force sched_yield() to be resolved before calling dlctl(DL_SET*LCK) withguenther2012-03-141-1/+2
| | | | | | a function that can call sched_yield(), to avoid recursion ok kurt@ kettenis@
* Add sem_timewait() and fix sem_wait()'s handling of signals, soguenther2012-03-031-5/+6
| | | | | | | that it resumes waiting unless the thread was canceled. As part of this, change the internal _sem_wait() function to return zero on success and an errno value on failure instead of 1 on success and zero on failure.
* for readability, put the label on it's own line.fgsch2012-03-021-2/+3
|
* sched_yield() is the standard name while pthread_yield() is theguenther2012-02-241-2/+2
| | | | non-standard alias, so prefer the former
* Use a form of designated initializer that works with gcc2guenther2012-02-191-2/+7
| | | | lint doesn't understand designated initializers, so hide them from it
* Fix previous commit: _rthread_init() was static.guenther2012-02-181-2/+2
| | | | Improve consistency of error naming
* Fix the handling of the stackaddr, stacksize, and guardsize attributes:guenther2012-02-181-8/+18
| | | | | | | | | | | don't try to merge values, round the sizes separately, and don't try to unmap application-supplied stacks. Copy from uthread the caching of default-sized stacks. Have pthread_attr_init() and pthread_create() get the default attributes from staticly allocated pthread_attr_t. Cache the pagesize in _rthread_init() and provide a macro for rounding to it based on suggestions from kettenis@ and tedu@, ok kettenis@
* Set __isthreaded in pthread_create() instead of _rthread_init() such that itkettenis2012-02-161-3/+4
| | | | | | | | properly represents whether a process is multi-threaded or not. This fixes a bug where if a forked child would create a new thread we would not set __isthreaded. ok guenther@
* Reimplement mutexes, condvars, and rwlocks to eliminate bugs,guenther2012-01-171-16/+43
| | | | | | | | | | | | | 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.
* pthread_self() may be much cheaper and never more expensive than getthrid()guenther2011-12-281-2/+3
| | | | so prefer it for identifying the current thread
* On failure, pthread_kill() should return the errno, not -1guenther2011-12-271-2/+2
|
* Mark sigthr()'s sig argument as __unusedguenther2011-12-051-2/+2
|
* Implement cancelation for the basic syscall cancelation points,guenther2011-12-051-4/+40
| | | | | | using previously allocated SIGTHR to interrupt in-process syscalls and fixing the spelling of "cancelled" along the way. Modeled on FreeBSD's libthr
* Oh yeah, with TLS-lite we can get the thread handle without walking theguenther2011-11-091-23/+2
| | | | | | thread list reminded by dhill@
* Move <machine/spinlock.h> into rthread.h; strip out unnecessary #includesguenther2011-11-061-9/+2
|
* Use __tfork, __get_tcb, and __set_tcb to have a real TCB and per-threadguenther2011-10-171-29/+60
| | | | | errno. The ASM bits for _cerror are sketchy or missing for some archs but that can be corrected in-tree.
* Convert thrsleep() to an absolute timeout with clockid to eliminate aguenther2009-11-271-2/+2
| | | | | | race condition and prep for later support of pthread_condattr_setclock() "get it in" deraadt@, tedu@, cheers by others
* Change threxit() to take a pointer to a pid_t to zero out from theguenther2009-11-271-22/+38
| | | | | | | | | | 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
* Fix a race in the reaper discovered by Tobias Ulmer. kevents are identified by pid,tedu2009-02-201-2/+3
| | | | | | | | so in the event that two threads get the same pid in a row, as the second is dying it will update (not add) the kevent for the previous thread with its own stack, which it will then unmap soon after, which is bad. Doing the reaping first guarantees that there are no kevents with the same pid as the exiting thread when it registers itself. ok guenther kurt
* use calloc() instead of malloc() and memset()kevlo2008-10-131-5/+3
| | | | "look good" tedu@
* Match libpthread's behavior and make pthread_join(NULL, whatever) failguenther2008-08-141-2/+4
| | | | | | | instead of crashing ok kurt@ first observed by Jung <moorang at gmail.com>
* Fix 5771/library: in pthread_exit(), delay the call to _sem_post() thatguenther2008-08-141-4/+4
| | | | | | | | | unblocks the pthread_join() for this thread until the exiting thread is completely done with its thread structure, as the joining thread will free it once unblocked. Also, don't bother to call _sem_post() if the thread is detached. ok kurt@
* If the initial thread calls pthread_exit(), don't overwrite its threadguenther2008-08-141-3/+5
| | | | | structure, as the 'tid' member there is used by other parts of librthread to determine whether the current thread is the initial thread
* - Add fork/vfork wrapper functions to reset state in the child process.kurt2008-06-051-18/+23
| | | | | | | | | | | - 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@
* Register the locking hooks with ld.so.art2007-05-181-1/+45
| | | | drahn@ ok (long time ago)
* Initialize thread debug in _rthread_init. The debug verbositymarc2006-01-061-1/+3
| | | | | can be set in the environment using RTHREAD_DEBUG. ok, tedu@
* guess it's time to remove the init printf; sturm found a port thattedu2006-01-061-3/+1
| | | | didn't like it.
* In pthread_join(), check if we create a deadlock trying to joinotto2006-01-051-7/+9
| | | | with ourself and only free thread after a succesful join. ok marc@
* move malloc lock to libc interface filetedu2006-01-051-23/+1
|
* add -Wstrict-prototypes -Wmissing-prototypes -Wsign-comparemarc2006-01-051-4/+5
| | | | | | Minor tweaks to compile with the above, primarily in fixing the conflicts between semaphore.h and rthread.h "i like the additional warnings" tedu@
* Cleanup struct pthread and stack after thread exits. This version doesotto2006-01-041-20/+73
| | | | not use a separate reaper thread. ok tedu@ marc@
* allow threads to be created in a detached statemarc2006-01-041-5/+13
| | | | | do not allow a join to a detached thread "it looks good" otto@
* thread stack handling changes. Add guard zones and allow stackmarc2006-01-011-36/+7
| | | | | | | | 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@
* Implement suspend/resume and creation of initially suspended threads.otto2005-12-311-6/+16
| | | | | With this, java seems to be operational. Also make threads_ready non-static, which is needed for an upcoming diff. ok tedu@
* Remove exitinng thread from the list of threads. ok tedu@otto2005-12-301-1/+4
|
* use queue.h macros for thread house keeping; make some vars non-staticotto2005-12-301-20/+19
| | | | and fix a bug in thread creation error path. ok tedu@
* __aligned__ isn't really necessary on the struct, an aligned membertedu2005-12-301-2/+2
| | | | will make the right thing happen. verified by kettenis and drahn
* prototype all the thread syscalls in rthread.h for now.tedu2005-12-301-3/+1
| | | | update for new thrwakeup that takes a count argument
* Put the existing _np functions into separate file; introduceotto2005-12-291-26/+3
| | | | | pthread_stackseg_np(), from existing pthread lib. discussed with tedu@ ok marc@
* implement pthread_main_np(); ok tedu@otto2005-12-291-1/+13
|
* for reasons that do not make any sense whatsoever, _rthread_alloc_stacktedu2005-12-231-9/+9
| | | | must be called with the thread_lock held, or we crash in rfork_thread
* more consistently use _rthread prefix for all not meant to be exportedtedu2005-12-221-15/+15
| | | | interfaces that aren't static, and a few that are but which will change
* change init code to handle failure. (actually, make it impossible to fail,tedu2005-12-221-13/+14
| | | | | but still have the callers check for good measure). prompted by miod "err() in a library???"
* Bad commit, breaks hppa64. Prompted by deraadt@marco2005-12-221-3/+2
|