summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/thread/Makefile.inc
Commit message (Collapse)AuthorAgeFilesLines
* Repo copy libpthreads to libkse.obrien2007-10-091-117/+0
| | | | | | This introduces the WITHOUT_LIBKSE nob, and changes WITHOUT_LIBPTHREADS to mean with neither threading libs. Approved by: re(kensmith)
* Include files thr_condattr_pshared.c and thr_mattr_pshare.c.davidxu2005-10-241-0/+2
|
* Add a wrapper for execve(). The exec'd process must be started withdeischen2004-09-261-0/+1
| | | | | | | | | | | | | | the signal mask and pending signals of the calling thread. These are stored in userland in libpthread. There is a small race condition in this patch which could cause problems if a signal arrives after setting the (kernel) signal mask and before exec'ing. The thread's set of pending signals also are not yet installed in the exec'd process. Both of these will be corrected with the addition of a special syscall. Reported & Tested by: Joost Bekkers <joost at jodocus dot org> Reviewed by: julian, davidxu
* 1. Add macro DTV_OFFSET to calculate dtv offset in tcb.davidxu2004-08-161-0/+1
| | | | 2. Export symbols needed by debugger.
* Implement sigaltstack() as per-threaded. Current only scope process threaddavidxu2003-12-291-0/+1
| | | | | | | | is supported, for scope system process, kernel signal bits need to be changed. Reviewed by: deischen Tested on : i386 amd64 ia64
* Add cancellation points for accept() and connect().deischen2003-12-091-0/+2
|
* Add an implementation for pthread_atfork().deischen2003-11-041-1/+2
| | | | | | | | Aside from the POSIX requirements for pthread_atfork(), when fork()ing, take the malloc lock to keep malloc state consistent in the child. Reviewed by: davidxu
* Add code to support pthread spin lock.davidxu2003-09-091-0/+1
| | | | Reviewed by: deischen
* Add code to support barrier synchronous object and implementdavidxu2003-09-041-0/+2
| | | | | | pthread_mutex_timedlock(). Reviewed by: deischen
* Override libc function raise(), in threading mode, raise() willdavidxu2003-07-191-0/+1
| | | | | | send signal to current thread. Reviewed by: deischen
* Attempt to eliminate PLT relocations from rwlock aquire/releasekan2003-05-301-0/+1
| | | | | | | | | | | path, making them suitable for direct use by the dynamic loader. Register libpthread-specific locking API with rtld on startup. This still has some rough edges with signals which should be addresses later. Approved by: re (scottl)
* Add a working pthread_[gs]etconcurrency. Initial null implementationdeischen2003-04-221-0/+1
| | | | | | | | | provided by Sergey A. Osokin <osa@freebsd.org.ru>. In order to test this on a single CPU machine, you need to: sysctl kern.threads.debug=1 sysctl kern.threads.virtual_cpu=2
* Revamp libpthread so that it has a chance of working in an SMPdeischen2003-04-181-2/+3
| | | | | | | | | | | | | | | | | | | environment. This includes support for multiple KSEs and KSEGs. The ability to create more than 1 KSE via pthread_setconcurrency() is in the works as well as support for PTHREAD_SCOPE_SYSTEM threads. Those should come shortly. There are still some known issues which davidxu and I are working on, but it'll make it easier for us by committing what we have. This library now passes all of the ACE tests that libc_r passes with the exception of one. It also seems to work OK with KDE including konqueror, kwrite, etc. I haven't been able to get mozilla to run due to lack of java plugin, so I'd be interested to see how it works with that. Reviewed by: davidxu
* MFlibc_r: add and document pthread_attr_get_np() function.phantom2003-03-031-0/+1
|
* Add signal logic to the build.mini2003-02-231-0/+2
|
* Actually link in the attr_{set,get}stack.alfred2003-02-111-0/+2
|
* Use KSE to schedule threads.mini2002-10-301-0/+1
|
* Make the changes needed for libpthread to compile in its new home.mini2002-09-161-133/+92
| | | | | | | | The new libpthread will provide POSIX threading support using KSE. These files were previously repo-copied from src/lib/libc_r. Reviewed by: deischen Approved by: -arch
* Add a wrapper for pselect() in order to make it a cancellation point.deischen2002-06-281-0/+1
| | | | Prompted by: wollman
* Missed in earlier commit -- I did cvs commit src/lib/libc. Oops.rwatson2002-06-141-2/+0
|
* Use GCC's __attribute__ ((constructor)) mechanism to invoke the pthreadalfred2002-05-111-1/+1
| | | | | | | startup code rather than a static C++ object since c++ seems to be broken. This doesn't seem to work for staticically linked program just yet, I'll give that some more work when I get a chance.
* Removed:ru2001-10-261-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | - uthread_signal.c; libc_r does not wrap signal() since 1998/04/29. - uthread_attr_setprio.c; it was never connected to the build, and pthread_attr_setprio() does not exist in POSIX. - uthread_sigblock.c and uthread_sigsetmask.c; these were no-ops bloating libc_r's space. pthread_private.h: - Removed prototypes of non-syscalls: send(). - Removed prototypes of unused syscalls: sigpending(), sigsuspend(), and select(). - Fixed prototype of fork(). - MFS: Fixed prototypes of <sys/socket.h> syscalls. Reviewed by: deischen Approved by: deischen, jasone
* Implement pthread_attr_[gs]etguardsize(). Non-default-size stacks used tojasone2001-07-201-0/+3
| | | | | | | | be malloc()ed, but they are now allocated using mmap(), just as the default-size stacks are. A separate cache of stacks is kept for non-default-size stacks. Collaboration with: deischen
* Activate build of posix1e extensions in libc and libc_r that have beentmm2001-04-041-0/+6
| | | | | | | | moved in from libposix1e, and deactivate build of the soon-to-be-removed libposix1e. Approved by: rwatson Obtained from: TrustedBSD Project
* Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) andalfred2001-03-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | associated changes that had to happen to make this possible as well as bugs fixed along the way. Bring in required TLI library routines to support this. Since we don't support TLI we've essentially copied what NetBSD has done, adding a thin layer to emulate direct the TLI calls into BSD socket calls. This is mostly from Sun's tirpc release that was made in 1994, however some fixes were backported from the 1999 release (supposedly only made available after this porting effort was underway). The submitter has agreed to continue on and bring us up to the 1999 release. Several key features are introduced with this update: Client calls are thread safe. (1999 code has server side thread safe) Updated, a more modern interface. Many userland updates were done to bring the code up to par with the recent RPC API. There is an update to the pthreads library, a function pthread_main_np() was added to emulate a function of Sun's threads library. While we're at it, bring in NetBSD's lockd, it's been far too long of a wait. New rpcbind(8) replaces portmap(8) (supporting communication over an authenticated Unix-domain socket, and by default only allowing set and unset requests over that channel). It's much more secure than the old portmapper. Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded to support TI-RPC and to support IPV6. Umount(8) is also fixed to unmount pathnames longer than 80 chars, which are currently truncated by the Kernel statfs structure. Submitted by: Martin Blapp <mb@imp.ch> Manpage review: ru Secure RPC implemented by: wpaul
* Add thread-safe wrapper for fpathconf(2) syscall.sobomax2000-09-191-0/+1
| | | | Reviewed by: jlemon
* Add wrapper for kevent() syscalljlemon2000-08-071-0/+1
| | | | Noted as missing by: nicolas.leonard@animaths.com
* Add a wrapper for the sendfile() system call.jasone2000-04-271-0/+1
| | | | PR: bin/17366
* Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(),jasone2000-01-271-0/+8
| | | | | | | | | | | | | | | | | just use _foo() <-- foo(). In the case of a libpthread that doesn't do call conversion (such as linuxthreads and our upcoming libpthread), this is adequate. In the case of libc_r, we still need three names, which are now _thread_sys_foo() <-- _foo() <-- foo(). Convert all internal libc usage of: aio_suspend(), close(), fsync(), msync(), nanosleep(), open(), fcntl(), read(), and write() to _foo() instead of foo(). Remove all internal libc usage of: creat(), pause(), sleep(), system(), tcdrain(), wait(), and waitpid(). Make thread cancellation fully POSIX-compliant. Suggested by: deischen
* Add sem_*() functions. Named semaphores and process-shared semaphoresjasone2000-01-201-0/+1
| | | | | | | are not supported by this implementation, and the error return values from sem_init(), sem_open(), sem_close(), and sem_unlink() reflect this. Approved by: jkh
* Implement continuations to correctly handle [sig|_]longjmp() inside of ajasone2000-01-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | signal handler. Explicitly check for jumps to anywhere other than the current stack, since such jumps are undefined according to POSIX. While we're at it, convert thread cancellation to use continuations, since it's cleaner than the original cancellation code. Avoid delivering a signal to a thread twice. This was a pre-existing bug, but was likely unexposed until these other changes were made. Defer signals generated by pthread_kill() so that they can be delivered on the appropriate stack. deischen claims that this is unnecessary, which is likely true, but without this change, pthread_kill() can cause undefined priority queue states and/or PANICs in [sig|_]longjmp(), so I'm leaving this in for now. To compile this code out and exercise the bug, define the _NO_UNDISPATCH cpp macro. Defining _PTHREADS_INVARIANTS as well will cause earlier crashes. PR: kern/14685 Collaboration with: deischen
* add pthread_cancel, obtained from OpenBSD.alfred1999-11-281-0/+3
| | | | | | | | | | | | | | eischen (Daniel Eischen) added wrappers to protect against cancled threads orphaning internal resources. the cancelability code is still a bit fuzzy but works for test programs of my own, OpenBSD's and some examples from ORA's books. add readdir_r to both libc and libc_r add some 'const' attributes to function parameters Reviewed by: eischen, jasone
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* In the words of the author:jb1999-06-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o The polling mechanism for I/O readiness was changed from select() to poll(). In additon, a wrapped version of poll() is now provided. o The wrapped select routine now converts each fd_set to a poll array so that the thread scheduler doesn't have to perform a bitwise search for selected fds each time file descriptors are polled for I/O readiness. o The thread scheduler was modified to use a new queue (_workq) for threads that need work. Threads waiting for I/O readiness and spinblocks are added to the work queue in addition to the waiting queue. This reduces the time spent forming/searching the array of file descriptors being polled. o The waiting queue (_waitingq) is now maintained in order of thread wakeup time. This allows the thread scheduler to find the nearest wakeup time by looking at the first thread in the queue instead of searching the entire queue. o Removed file descriptor locking for select/poll routines. An application should not rely on the threads library for providing this locking; if necessary, the application should use mutexes to protect selecting/polling of file descriptors. o Retrieve and use the kernel clock rate/resolution at startup instead of hardcoding the clock resolution to 10 msec (tested with kernel running at 1000 HZ). o All queues have been changed to use queue.h macros. These include the queues of all threads, dead threads, and threads waiting for file descriptor locks. o Added reinitialization of the GC mutex and condition variable after a fork. Also prevented reallocation of the ready queue after a fork. o Prevented the wrapped close routine from closing the thread kernel pipes. o Initialized file descriptor table for stdio entries at thread init. o Provided additional flags to indicate to what queues threads belong. o Moved TAILQ initialization for statically allocated mutex and condition variables to after the spinlock. o Added dispatching of signals to pthread_kill. Removing the dispatching of signals from thread activation broke sigsuspend when pthread_kill was used to send a signal to a thread. o Temporarily set the state of a thread to PS_SUSPENDED when it is first created and placed in the list of threads so that it will not be accidentally scheduled before becoming a member of one of the scheduling queues. o Change the signal handler to queue signals to the thread kernel pipe if the scheduling queues are protected. When scheduling queues are unprotected, signals are then dequeued and handled. o Ensured that all installed signal handlers block the scheduling signal and that the scheduling signal handler blocks all other signals. This ensures that the signal handler is only interruptible for and by non-scheduling signals. An atomic lock is used to decide which instance of the signal handler will handle pending signals. o Removed _lock_thread_list and _unlock_thread_list as they are no longer used to protect the thread list. o Added missing RCS IDs to modified files. o Added checks for appropriate queue membership and activity when adding, removing, and searching the scheduling queues. These checks add very little overhead and are enabled when compiled with _PTHREADS_INVARIANTS defined. Suggested and implemented by Tor Egge with some modification by me. o Close a race condition in uthread_close. (Tor Egge) o Protect the scheduling queues while modifying them in pthread_cond_signal and _thread_fd_unlock. (Tor Egge) o Ensure that when a thread gets a mutex, the mutex is on that threads list of owned mutexes. (Tor Egge) o Set the kernel-in-scheduler flag in _thread_kern_sched_state and _thread_kern_sched_state_unlock to prevent a scheduling signal from calling the scheduler again. (Tor Egge) o Don't use TAILQ_FOREACH macro while searching the waiting queue for threads in a sigwait state, because a change of state destroys the TAILQ link. It is actually safe to do so, though, because once a sigwaiting thread is found, the loop ends and the function returns. (Tor Egge) o When dispatching signals to threads, make the thread inherit the signal deferral flag of the currently running thread. (Tor Egge) Submitted by: Daniel Eischen <eischen@vigrid.com> and Tor Egge <Tor.Egge@fast.no>
* [ The author's description... ]jb1999-03-231-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o Runnable threads are now maintained in priority queues. The implementation requires two things: 1.) The priority queues must be protected during insertion and removal of threads. Since the kernel scheduler must modify the priority queues, a spinlock for protection cannot be used. The functions _thread_kern_sched_defer() and _thread_kern_sched_undefer() were added to {un}defer kernel scheduler activation. 2.) A thread (active) priority change can be performed only when the thread is removed from the priority queue. The implementation uses a threads active priority when inserting it into the queue. A by-product is that thread switches are much faster. A separate queue is used for waiting and/or blocked threads, and it is searched at most 2 times in the kernel scheduler when there are active threads. It should be possible to reduce this to once by combining polling of threads waiting on I/O with the loop that looks for timed out threads and the minimum timeout value. o Functions to defer kernel scheduler activation were added. These are _thread_kern_sched_defer() and _thread_kern_sched_undefer() and may be called recursively. These routines do not block the scheduling signal, but latch its occurrence. The signal handler will not call the kernel scheduler when the running thread has deferred scheduling, but it will be called when running thread undefers scheduling. o Added support for _POSIX_THREAD_PRIORITY_SCHEDULING. All the POSIX routines required by this should now be implemented. One note, SCHED_OTHER, SCHED_FIFO, and SCHED_RR are required to be defined by including pthread.h. These defines are currently in sched.h. I modified pthread.h to include sched.h but don't know if this is the proper thing to do. o Added support for priority protection and inheritence mutexes. This allows definition of _POSIX_THREAD_PRIO_PROTECT and _POSIX_THREAD_PRIO_INHERIT. o Added additional error checks required by POSIX for mutexes and condition variables. o Provided a wrapper for sigpending which is marked as a hidden syscall. o Added a non-portable function as a debugging aid to allow an application to monitor thread context switches. An application can install a routine that gets called everytime a thread (explicitly created by the application) gets context switched. The routine gets passed the pthread IDs of the threads that are being switched in and out. Submitted by: Dan Eischen <eischen@vigrid.com> Changes by me: o Added a PS_SPINBLOCK state to deal with the priority inversion problem most often (I think) seen by threads calling malloc/free/realloc. o Dispatch signals to the running thread directly rather than at a context switch to avoid the situation where the switch never occurs.
* Move the cleanup code that frees memory allocated for a dead thread fromjb1998-09-301-1/+2
| | | | | | | | | | | | | | the thread kernel into a garbage collector thread which is started when the fisrt thread is created (other than the initial thread). This removes the window of opportunity where a context switch will cause a thread that has locked the malloc spinlock, to enter the thread kernel, find there is a dead thread and try to free memory, therefore trying to lock the malloc spinlock against itself. The garbage collector thread acts just like any other thread, so instead of having a spinlock to control accesses to the dead thread list, it uses a mutex and a condition variable so that it can happily wait to be signalled when a thread exists.
* In libc_r, rename vfork syscall to _thread_sys_vfork and make vfork an aliasdt1998-09-121-1/+2
| | | | | | | to fork. It is difficult to do real vfork in libc_r, since almost every operation with file descriptsor changes _thread_fd_table and friends. popen(3) works much better with this change.
* Implement pthread read/write locks as defined by Version 2 of the Singlealex1998-09-071-1/+3
| | | | | | | UNIX Specification. As with our standard mutexes, process shared locks are not supported at this time.
* I shouldn't do things early in the morning.jb1998-06-011-3/+1
| | | | | | I shouldn't do things early in the morning. [...] I shouldn't do things early in the morning.
* Add some missing syscall wrappers.jb1998-05-311-1/+5
|
* Change signal model to match POSIX (i.e. one set of signal handlersjb1998-04-291-5/+4
| | | | | | | | | | | | | | | | | | | | for the process, not a separate set for each thread). By default, the process now only has signal handlers installed for SIGVTALRM, SIGINFO and SIGCHLD. The thread kernel signal handler is installed for other signals on demand. This means that SIG_IGN and SIG_DFL processing is now left to the kernel, not the thread kernel. Change the signal dispatch to no longer use a signal thread, and call the signal handler using the stack of the thread that has the signal pending. Change the atomic lock method to use test-and-set asm code with a yield if blocked. This introduces separate locks for each type of object instead of blocking signals to prevent a context switch. It was this blocking of signals that caused the performance degradation the people have noted. This is a *big* change!
* Added missing source file uthread_sigwait.c.alex1997-11-241-1/+2
| | | | Submitted by: Daniel M. Eischen <deischen@iworks.InterWorks.org>
* Bye bye CPLUSPLUSLIB hack! It's not needed any more.jdp1997-05-061-3/+1
| | | | | Don't merge this into -2.2 unless you understand the dependencies on c++rt0, bsd.lib.mk, and gcc -shared. I.e., let me do it.
* Revert $FreeBSD$ to $Id$peter1997-02-221-1/+1
|
* Submitted by: John Birrelljulian1997-02-051-0/+10
| | | | uthreads update from the author.
* Make the long-awaited change from $Id$ to $FreeBSD$jkh1997-01-141-1/+1
| | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
* Added uthread_attr_destroy.c to SRCS.alex1996-12-291-1/+2
| | | | Submitted by: John Birrell <jb@cimlogic.com.au>
* Add uthread_attr_init.c, uthread_attr_setstacksize.c, uthread_mattr_init.c,hsu1996-11-111-1/+7
| | | | uthread_mattr_kind_np.c, uthread_multi_np.c, and uthread_single_np.c.
* Submitted by: John Birrell <cimaxp1!jb@werple.net.au>julian1996-08-201-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Here are the diffs for libc_r to get it one step closer to P1003.1c These make most of the thread/mutex/condvar structures opaque to the user. There are three functions which have been renamed with _np suffixes because they are extensions to P1003.1c (I did them for JAVA, which needs to suspend/resume threads and also start threads suspended). I've created a new header (pthread_np.h) for the non-POSIX stuff. The egrep tags stuff in /usr/src/lib/libc_r/Makefile that I uncommented doesn't work. I think its best to delete it. I don't think libc_r needs tags anyway, 'cause most of the source is in libc which does have tags. also: Here's the first batch of man pages for the thread functions. The diff to /usr/src/lib/libc_r/Makefile removes some stuff that was inherited from /usr/src/lib/libc/Makefile that should only be done with libc. also: I should have sent this diff with the pthread(3) man page. It allows people to type make -DWANT_LIBC_R world to get libc_r built with the rest of the world. I put this in the pthread(3) man page. The default is still not to build libc_r. also: The diff attached adds a pthread(3) man page to /usr/src/share/man/man3. The idea is that without libc_r installed, this man page will give people enough info to know that they have to build libc_r.
* Added a new module "uthread_autoinit.cc". This is a small C++ module.jdp1996-02-171-1/+4
| | | | | | | | | | | | | | It uses a static constructor to call _thread_init() at program start-up time. That eliminates the need for any initialization hooks in crt0.o. Added a symbol reference in "uthread_init.c", to ensure that the new module will always be pulled in when the archive version of the library is used. In "Makefile.inc", defined CPLUSPLUSLIB, so that the constructor will be properly invoked in the shared library. Suggested by: Christopher Provenzano, Peter Wemm, and others.
OpenPOWER on IntegriCloud