History log of /freebsd-10.0-release/lib/libkse/thread/Makefile.inc
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 259065 07-Dec-2013 gjb

- Copy stable/10 (r259064) to releng/10.0 as part of the
10.0-RELEASE cycle.
- Update __FreeBSD_version [1]
- Set branch name to -RC1

[1] 10.0-CURRENT __FreeBSD_version value ended at '55', so
start releng/10.0 at '100' so the branch is started with
a value ending in zero.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 172491 09-Oct-2007 obrien

Repo copy libpthreads to libkse.
This introduces the WITHOUT_LIBKSE nob,
and changes WITHOUT_LIBPTHREADS to mean with neither threading libs.
Approved by: re(kensmith)


# 151616 24-Oct-2005 davidxu

Include files thr_condattr_pshared.c and thr_mattr_pshare.c.


# 135809 26-Sep-2004 deischen

Add a wrapper for execve(). The exec'd process must be started with
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


# 133801 16-Aug-2004 davidxu

1. Add macro DTV_OFFSET to calculate dtv offset in tcb.
2. Export symbols needed by debugger.


# 123974 29-Dec-2003 davidxu

Implement sigaltstack() as per-threaded. Current only scope process thread
is supported, for scope system process, kernel signal bits need to be
changed.

Reviewed by: deischen
Tested on : i386 amd64 ia64


# 123355 09-Dec-2003 deischen

Add cancellation points for accept() and connect().


# 122075 04-Nov-2003 deischen

Add an implementation for pthread_atfork().

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


# 119909 09-Sep-2003 davidxu

Add code to support pthread spin lock.

Reviewed by: deischen


# 119736 04-Sep-2003 davidxu

Add code to support barrier synchronous object and implement
pthread_mutex_timedlock().

Reviewed by: deischen


# 117758 19-Jul-2003 davidxu

Override libc function raise(), in threading mode, raise() will
send signal to current thread.

Reviewed by: deischen


# 115399 29-May-2003 kan

Attempt to eliminate PLT relocations from rwlock aquire/release
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)


# 113871 22-Apr-2003 deischen

Add a working pthread_[gs]etconcurrency. Initial null implementation
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


# 113658 18-Apr-2003 deischen

Revamp libpthread so that it has a chance of working in an SMP
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


# 111846 03-Mar-2003 phantom

MFlibc_r: add and document pthread_attr_get_np() function.


# 111359 23-Feb-2003 mini

Add signal logic to the build.


# 110677 11-Feb-2003 alfred

Actually link in the attr_{set,get}stack.


# 106191 30-Oct-2002 mini

Use KSE to schedule threads.


# 103388 16-Sep-2002 mini

Make the changes needed for libpthread to compile in its new home.
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


# 98975 28-Jun-2002 deischen

Add a wrapper for pselect() in order to make it a cancellation point.

Prompted by: wollman


# 98205 14-Jun-2002 rwatson

Missed in earlier commit -- I did cvs commit src/lib/libc. Oops.


# 96401 11-May-2002 alfred

Use GCC's __attribute__ ((constructor)) mechanism to invoke the pthread
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.


# 85557 26-Oct-2001 ru

Removed:

- 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


# 80021 20-Jul-2001 jasone

Implement pthread_attr_[gs]etguardsize(). Non-default-size stacks used to
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


# 75188 04-Apr-2001 tmm

Activate build of posix1e extensions in libc and libc_r that have been
moved in from libposix1e, and deactivate build of the soon-to-be-removed
libposix1e.

Approved by: rwatson
Obtained from: TrustedBSD Project


# 74462 19-Mar-2001 alfred

Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
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


# 66074 19-Sep-2000 sobomax

Add thread-safe wrapper for fpathconf(2) syscall.

Reviewed by: jlemon


# 64346 07-Aug-2000 jlemon

Add wrapper for kevent() syscall

Noted as missing by: nicolas.leonard@animaths.com


# 59671 26-Apr-2000 jasone

Add a wrapper for the sendfile() system call.

PR: bin/17366


# 56698 27-Jan-2000 jasone

Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(),
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


# 56320 20-Jan-2000 jasone

Add sem_*() functions. Named semaphores and process-shared semaphores
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


# 56277 19-Jan-2000 jasone

Implement continuations to correctly handle [sig|_]longjmp() inside of a
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


# 53812 28-Nov-1999 alfred

add pthread_cancel, obtained from OpenBSD.

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


# 50476 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 48046 20-Jun-1999 jb

In the words of the author:

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>


# 44963 23-Mar-1999 jb

[ The author's description... ]

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.


# 39807 30-Sep-1998 jb

Move the cleanup code that frees memory allocated for a dead thread from
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.


# 39118 12-Sep-1998 dt

In libc_r, rename vfork syscall to _thread_sys_vfork and make vfork an alias
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.


# 38919 07-Sep-1998 alex

Implement pthread read/write locks as defined by Version 2 of the Single
UNIX Specification.

As with our standard mutexes, process shared locks are not supported at
this time.


# 36553 01-Jun-1998 jb

I shouldn't do things early in the morning.
I shouldn't do things early in the morning.
[...]
I shouldn't do things early in the morning.


# 36550 31-May-1998 jb

Add some missing syscall wrappers.


# 35509 29-Apr-1998 jb

Change signal model to match POSIX (i.e. one set of signal handlers
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!


# 31400 24-Nov-1997 alex

Added missing source file uthread_sigwait.c.

Submitted by: Daniel M. Eischen <deischen@iworks.InterWorks.org>


# 25501 05-May-1997 jdp

Bye bye CPLUSPLUSLIB hack! It's not needed any more.

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.


# 22993 22-Feb-1997 peter

Revert $FreeBSD$ to $Id$


# 22315 05-Feb-1997 julian

Submitted by: John Birrell
uthreads update from the author.


# 21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

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.


# 21003 29-Dec-1996 alex

Added uthread_attr_destroy.c to SRCS.

Submitted by: John Birrell <jb@cimlogic.com.au>


# 19632 11-Nov-1996 hsu

Add uthread_attr_init.c, uthread_attr_setstacksize.c, uthread_mattr_init.c,
uthread_mattr_kind_np.c, uthread_multi_np.c, and uthread_single_np.c.


# 17706 20-Aug-1996 julian

Submitted by: John Birrell <cimaxp1!jb@werple.net.au>

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.


# 14117 17-Feb-1996 jdp

Added a new module "uthread_autoinit.cc". This is a small C++ module.
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.


# 13546 21-Jan-1996 julian

Reviewed by: julian
Submitted by: john birrel

One version of the pthreads library
another will follow with differnt actions under some cases..
not QUITE complete