freebsd-nq/lib/libc_r/uthread
Daniel Eischen fbeb36e4bf Implement zero system call thread switching. Performance of
thread switches should be on par with that under scheduler
activations.

  o Timing is achieved through the use of a fixed interval
    timer (ITIMER_PROF) to count scheduling ticks instead
    of retrieving the time-of-day upon every thread switch
    and calculating elapsed real time.

  o Polling for I/O readiness is performed once for each
    scheduling tick instead of every thread switch.

  o The non-signal saving/restoring versions of setjmp/longjmp
    are used to save and restore thread contexts.  This may
    allow the removal of _THREAD_SAFE macros from setjmp()
    and longjmp() - needs more investigation.

Change signal handling so that signals are handled in the
context of the thread that is receiving the signal.  When
signals are dispatched to a thread, a special signal handling
frame is created on top of the target threads stack.  The
frame contains the threads saved state information and a new
context in which the thread can run.  The applications signal
handler is invoked through a wrapper routine that knows how
to restore the threads saved state and unwind to previous
frames.

Fix interruption of threads due to signals.  Some states
were being improperly interrupted while other states were
not being interrupted.  This should fix several PRs.

Signal handlers, which are invoked as a result of a process
signal (not by pthread_kill()), are now called with the
code (or siginfo_t if SA_SIGINFO was set in sa_flags) and
sigcontext_t as received from the process signal handler.

Modify the search for a thread to which a signal is delivered.
The search algorithm is now:

  o First thread found in sigwait() with signal in wait mask.
  o First thread found sigsuspend()'d on the signal.
  o Current thread if signal is unmasked.
  o First thread found with signal unmasked.

Collapse machine dependent support into macros defined in
pthread_private.h.  These should probably eventually be moved
into separate MD files.

Change the range of settable priorities to be compliant with
POSIX (0-31).  The threads library uses higher priorities
internally for real-time threads (not yet implemented) and
threads executing signal handlers.  Real-time threads and
threads running signal handlers add 64 and 32, respectively,
to a threads base priority.

Some other small changes and cleanups.

PR:		17757 18559 21943
Reviewed by:	jasone
2000-10-13 22:12:32 +00:00
..
Makefile.inc Add thread-safe wrapper for fpathconf(2) syscall. 2000-09-19 18:01:03 +00:00
pthread_private.h Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_accept.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_aio_suspend.c Change my email address in the copyright notices for the sake of consistency 2000-07-18 01:38:19 +00:00
uthread_attr_destroy.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_attr_getdetachstate.c Fixed missing consts for function parameters, so that the code matches 2000-05-11 15:57:17 +00:00
uthread_attr_getinheritsched.c add pthread_cancel, obtained from OpenBSD. 1999-11-28 05:38:13 +00:00
uthread_attr_getschedparam.c add pthread_cancel, obtained from OpenBSD. 1999-11-28 05:38:13 +00:00
uthread_attr_getschedpolicy.c add pthread_cancel, obtained from OpenBSD. 1999-11-28 05:38:13 +00:00
uthread_attr_getscope.c add pthread_cancel, obtained from OpenBSD. 1999-11-28 05:38:13 +00:00
uthread_attr_getstackaddr.c Fixed missing consts for function parameters, so that the code matches 2000-05-11 15:57:17 +00:00
uthread_attr_getstacksize.c Fixed missing consts for function parameters, so that the code matches 2000-05-11 15:57:17 +00:00
uthread_attr_init.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_attr_setcreatesuspend_np.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_attr_setdetachstate.c Track libc's three-tier symbol naming. libc_r must currently implement 2000-01-12 09:28:58 +00:00
uthread_attr_setinheritsched.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_attr_setprio.c Track libc's three-tier symbol naming. libc_r must currently implement 2000-01-12 09:28:58 +00:00
uthread_attr_setschedparam.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_attr_setschedpolicy.c Add missing man pages. Fix various compliance bugs, mostly having to do with 2000-05-02 06:51:40 +00:00
uthread_attr_setscope.c Add missing man pages. Fix various compliance bugs, mostly having to do with 2000-05-02 06:51:40 +00:00
uthread_attr_setstackaddr.c Track libc's three-tier symbol naming. libc_r must currently implement 2000-01-12 09:28:58 +00:00
uthread_attr_setstacksize.c Track libc's three-tier symbol naming. libc_r must currently implement 2000-01-12 09:28:58 +00:00
uthread_autoinit.cc Change REGENTS -> AUTHOR in the copyright. 2000-01-06 12:16:16 +00:00
uthread_bind.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_cancel.c pthread_mutex_lock(), pthread_cond_trywait(), and pthread_cond_wait() are 2000-06-14 17:17:41 +00:00
uthread_clean.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_close.c Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(), 2000-01-27 23:07:25 +00:00
uthread_cond.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_condattr_destroy.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_condattr_init.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_connect.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_creat.c Change my email address in the copyright notices for the sake of consistency 2000-07-18 01:38:19 +00:00
uthread_create.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_detach.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_dup2.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_dup.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_equal.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_execve.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_exit.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_fchflags.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_fchmod.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_fchown.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_fcntl.c Use _fcntl() (not fcntl()) inside of fcntl(). 2000-01-28 22:10:27 +00:00
uthread_fd.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_file.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_find_thread.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_flock.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_fork.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_fpathconf.c Add thread-safe wrapper for fpathconf(2) syscall. 2000-09-19 18:01:03 +00:00
uthread_fstat.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_fstatfs.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_fsync.c Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(), 2000-01-27 23:07:25 +00:00
uthread_gc.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_getdirentries.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_getpeername.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_getprio.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_getschedparam.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_getsockname.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_getsockopt.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_info.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_init.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_ioctl.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_jmp.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_join.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_kern.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_kevent.c kevent() is not a POSIX cancellation point, so _kevent() need not be 2000-08-08 00:12:35 +00:00
uthread_kill.c Fixes for signal handling: 1999-12-17 00:56:36 +00:00
uthread_listen.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_mattr_init.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_mattr_kind_np.c Add missing man pages. Fix various compliance bugs, mostly having to do with 2000-05-02 06:51:40 +00:00
uthread_msync.c Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(), 2000-01-27 23:07:25 +00:00
uthread_multi_np.c Track libc's three-tier symbol naming. libc_r must currently implement 2000-01-12 09:28:58 +00:00
uthread_mutex_prioceiling.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_mutex_protocol.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_mutex.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_mutexattr_destroy.c Track libc's three-tier symbol naming. libc_r must currently implement 2000-01-12 09:28:58 +00:00
uthread_nanosleep.c Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(), 2000-01-27 23:07:25 +00:00
uthread_once.c Call _thread_init() from pthread_once() if it has not already been called. 2000-07-21 09:31:13 +00:00
uthread_open.c Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(), 2000-01-27 23:07:25 +00:00
uthread_pause.c Change my email address in the copyright notices for the sake of consistency 2000-07-18 01:38:19 +00:00
uthread_pipe.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_poll.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_priority_queue.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_read.c Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(), 2000-01-27 23:07:25 +00:00
uthread_readv.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_recvfrom.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_recvmsg.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_resume_np.c pthread_mutex_lock(), pthread_cond_trywait(), and pthread_cond_wait() are 2000-06-14 17:17:41 +00:00
uthread_rwlock.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_rwlockattr.c Track libc's three-tier symbol naming. libc_r must currently implement 2000-01-12 09:28:58 +00:00
uthread_select.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_self.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_sem.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_sendfile.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_sendmsg.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_sendto.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_seterrno.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_setprio.c Implement continuations to correctly handle [sig|_]longjmp() inside of a 2000-01-19 07:04:50 +00:00
uthread_setschedparam.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_setsockopt.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_shutdown.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_sig.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_sigaction.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_sigblock.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_sigmask.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_signal.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_sigpending.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_sigprocmask.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_sigsetmask.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_sigsuspend.c Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(), 2000-01-27 23:07:25 +00:00
uthread_sigwait.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_single_np.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_sleep.c Change my email address in the copyright notices for the sake of consistency 2000-07-18 01:38:19 +00:00
uthread_socket.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_socketpair.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_spec.c -Wall and minor style(9) cleanups. 1999-12-28 18:13:04 +00:00
uthread_spinlock.c Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(), 2000-01-27 23:07:25 +00:00
uthread_suspend_np.c pthread_mutex_lock(), pthread_cond_trywait(), and pthread_cond_wait() are 2000-06-14 17:17:41 +00:00
uthread_switch_np.c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
uthread_system.c Change my email address in the copyright notices for the sake of consistency 2000-07-18 01:38:19 +00:00
uthread_tcdrain.c Change my email address in the copyright notices for the sake of consistency 2000-07-18 01:38:19 +00:00
uthread_vfork.c In libc_r, rename vfork syscall to _thread_sys_vfork and make vfork an alias 1998-09-12 22:03:20 +00:00
uthread_wait4.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_wait.c Change my email address in the copyright notices for the sake of consistency 2000-07-18 01:38:19 +00:00
uthread_waitpid.c Change my email address in the copyright notices for the sake of consistency 2000-07-18 01:38:19 +00:00
uthread_write.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00
uthread_writev.c Use __strong_reference() instead of __weak_reference() to assure that the 2000-01-29 22:53:55 +00:00
uthread_yield.c Implement zero system call thread switching. Performance of 2000-10-13 22:12:32 +00:00