Commit Graph

291 Commits

Author SHA1 Message Date
Jason Evans
aa33517e94 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
2001-07-20 04:23:11 +00:00
Dima Dorfman
7ebcc426ef Remove whitespace at EOL. 2001-07-15 07:53:42 +00:00
Ruslan Ermilov
a307d59838 mdoc(7) police: removed HISTORY info from the .Os call. 2001-07-10 13:41:46 +00:00
Dima Dorfman
70d51341bf mdoc(7) police: remove extraneous .Pp before and/or after .Sh. 2001-07-09 09:54:33 +00:00
Ruslan Ermilov
5521ff5a4d mdoc(7) police: sort SEE ALSO xrefs (sort -b -f +2 -3 +1 -2). 2001-07-06 16:46:48 +00:00
Daniel Eischen
a9513dc678 Clear the in thread scheduler flag after jumping to the start of
a signal handler from the scheduler.

MFC after:	1 week
2001-06-29 17:09:07 +00:00
Jason Evans
651974ee92 Fix a race condition in pthread_join(). All of the following must occur
atomically:

1) Search _thread_list for the thread to join.
2) Search _dead_list for the thread to join.
3) Set the running thread as the joiner.

While we're at it, fix a race in the case where multiple threads try to
join on the same thread.  POSIX says that the behavior of multiple joiners
is undefined, but the fix is cheap as a result of the other fix.
2001-06-27 11:41:15 +00:00
Gregory Neil Shapiro
c1c5db8149 Typo fix: requires -> reacquires
Submitted by:	Murray S. Kucherawy <msk@sendmail.com>
MFC after:	3 days
2001-06-27 06:01:17 +00:00
Dima Dorfman
d33f4d20c9 Add a missing word.
Obtained from:	OpenBSD
2001-06-05 00:25:18 +00:00
Dima Dorfman
5940a2ebe0 Add a missing word. 2001-06-05 00:11:08 +00:00
Jason Evans
c024882f08 Add a test for PR 24345. 2001-05-20 23:12:13 +00:00
Jason Evans
b39e7e33f1 Update the verify script. 2001-05-20 23:11:54 +00:00
Jason Evans
745b431dc6 Don't define _REENTRANT, since the Makefile does so. 2001-05-20 23:11:09 +00:00
Jason Evans
dd2d9a766b Fix a typo. 2001-05-20 23:10:30 +00:00
Jason Evans
6699b0c6fe Instead of using a join queue for each thread, use a single pointer to
keep track of a joiner.  POSIX only supports a single joiner, so this
simplification is acceptable.

At the same time, make sure to mark a joined thread as detached so that
its resources can be freed.

Reviewed by:	deischen
PR:		24345
2001-05-20 23:08:33 +00:00
Ruslan Ermilov
108b08b24e Fixed typo in the description.
PR:		docs/27411
Submitted by:	David Wimsey <dwimsey@rtci.com>
2001-05-18 06:56:03 +00:00
Jason Evans
ffc19644c0 Condition variable waiters are queued in descending priority order, so
there is no need to wake all waiters to assure that the highest priority
thread is run.  As the semaphore code is written, there was no correctness
problem, but the change improves sem_post() performance.

Pointed out by:	deischen
2001-05-18 00:36:05 +00:00
Jason Evans
1317e200a8 Mark a thread that is suspended while sleeping as interrupted. 2001-05-16 21:58:45 +00:00
Akinori MUSHA
3b26be6ae1 Properly copy the P_ALTSTACK flag in struct proc::p_flag to the child
process on fork(2).

It is the supposed behavior stated in the manpage of sigaction(2), and
Solaris, NetBSD and FreeBSD 3-STABLE correctly do so.

The previous fix against libc_r/uthread/uthread_fork.c fixed the
problem only for the programs linked with libc_r, so back it out and
fix fork(2) itself to help those not linked with libc_r as well.

PR:		kern/26705
Submitted by:	KUROSAWA Takahiro <fwkg7679@mb.infoweb.ne.jp>
Tested by:	knu, GOTOU Yuuzou <gotoyuzo@notwork.org>,
		and some other people
Not objected by:	hackers
MFC in:		3 days
2001-05-07 18:07:29 +00:00
Daniel Eischen
59cc2dcac7 Move the check for a pending signals to after the thread has been
placed in any scheduling queue(s).  The process of dispatching
signals to a thread can change its state which will attempt to add
or remove the thread from any scheduling queue to which it belongs.
This can break some assertions if the thread isn't in the queue(s)
implied by its state.

When adding dispatching a pending signal to a thread, be sure to
remove the signal from the threads set of pending signals.

PR:		27035
Tested by:	brian
MFC in:		1 week
2001-05-04 20:37:07 +00:00
Mark Murray
98d2ef9e72 Compenate for header dethreading. 2001-05-01 09:32:34 +00:00
Daniel Eischen
9391331024 Typo; fix open() so that it is not a cancellation point when called
from libc.
2001-04-18 12:42:11 +00:00
Daniel Eischen
1cf08f3929 Reinstall the alternate signal stack after a fork.
PR:		25110
Tested by:	knu
2001-04-18 12:40:30 +00:00
Daniel Eischen
f9c408bc01 Clean up a bit. Use the correct TAILQ link when walking the thread
lists to free thread resources after a fork (in the child).  Also
remember to free the dead thread list.
2001-04-10 04:25:49 +00:00
Daniel Eischen
ac530e7b3a Added a missing set of braces to a conditional that encompasses more than
one statement.
2001-04-10 04:22:24 +00:00
Daniel Eischen
437df4859a To be consistent, use the __weak_reference macro from <sys/cdefs.h>
instead of #pragma weak to create weak definitions.

Suggested by:	bde
2001-04-10 04:19:21 +00:00
Thomas Moestl
8b28ef9528 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
2001-04-04 18:17:28 +00:00
Thomas Moestl
16cb0dd753 Add thread safety wrappers for the posix1e syscalls that deal with file
descriptors.

Approved by:	rwatson
Obtained from:	TrustedBSD Project
2001-04-04 18:10:25 +00:00
Ian Dowse
92f5474235 Add a leading underscore to the pthread_main_np function name, and
a "#pragma weak" directive linking the external symbol. This matches
the other pthread_* definitions, and ensures that users of this
function from within libc get the real version, not the stub.

Suggested by:	deischen
Reviewed by:	deischen, alfred
2001-04-03 22:25:39 +00:00
Ruslan Ermilov
4a558355e5 MAN[1-9] -> MAN. 2001-03-27 17:27:19 +00:00
Alfred Perlstein
8360efbd6c 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
2001-03-19 12:50:13 +00:00
Daniel Eischen
af4878847e Correct a race condition where it was possible for a signaled
thread to become stranded and not placed in the run queue.

MFC Candidate

Reported by:	tegge
2001-03-09 16:05:43 +00:00
Ruslan Ermilov
0d42ab242e mdoc(7) police: fix markup. 2001-03-02 09:59:58 +00:00
Ruslan Ermilov
096841eceb Use ``.St -p1003.1-96''. 2001-02-26 15:16:43 +00:00
Ruslan Ermilov
589a5e341f /^\.St/ s/-iso9945-1/-p1003.1-96/ 2001-02-26 14:48:38 +00:00
Daniel Eischen
c33f8c177f Really set the flags for a private mutex (used by libc/libc_r). 2001-02-26 01:06:52 +00:00
Daniel Eischen
c6f2aed102 Limit threads clock resolution to no less than 1000usec (1000Hz).
PR:		25300
Submitted by:	Tom Pavel <pavel@alum.mit.edu> (in part)
2001-02-26 01:05:33 +00:00
Daniel Eischen
f434cd45ed Remove (int) file descriptor locking. It should be up to the
application to provide locking for I/O operations.  This doesn't
break any of my tests, but the old behavior can be restored by
compiling with _FDLOCKS_ENABLED.  This will eventually be removed
when it is obvious it does not cause any problems.

Remove most of flockfile implementation, with the exception of
flockfile_debug.

Make error messages more informational (submitted by Mike Heffner
<spock@techfour.net>, who's now known as mikeh@FreeBSD.org).
2001-02-11 22:07:32 +00:00
Nik Clayton
7b79d3ab37 Fix typo.
PR:             docs/23936
Submitted by:   Garret Rooney <rooneg@rpi.edu>
2001-02-02 03:32:03 +00:00
Ruslan Ermilov
d0353b836e mdoc(7) police: split punctuation characters + misc fixes. 2001-02-01 16:38:02 +00:00
Daniel Eischen
f8a19b12fb s/_thread_sys_write/__sys_write/
Submitted by:	Mike Heffner <mheffner@vt.edu>
2001-01-31 02:16:57 +00:00
Daniel Eischen
f47892a9f7 Unbreak world by correctly specifying the prototype for __sys_aio_suspend.
A make buildworld was done but not with the committed pthread_private.h.

Reported by:	Manfred Antar <null@pozo.com>
2001-01-29 18:59:53 +00:00
Daniel Eischen
221b1e69c5 _exit in libc is now __sys_exit not __sys__exit.
Add another check for thread library initialization (jdp, we
really need a way to get _thread_init called at program start
before any constructors are run).
2001-01-29 03:24:23 +00:00
Daniel Eischen
75f7221ee6 -pthread -> -lc_r 2001-01-24 13:41:04 +00:00
Daniel Eischen
e5106342c6 Add weak definitions for wrapped system calls. In general:
_foo - wrapped system call
	foo - weak definition to _foo

and for cancellation points:

	_foo - wrapped system call
	__foo - enter cancellation point, call _foo(), leave
	        cancellation point
	foo - weak definition to __foo

Change use of global _thread_run to call a function to get the
currently running thread.

Make all pthread_foo functions weak definitions to _pthread_foo,
where _pthread_foo is the implementation.  This allows an application
to provide its own pthread functions.

Provide slightly different versions of pthread_mutex_lock and
pthread_mutex_init so that we can tell the difference between
a libc mutex and an application mutex.  Threads holding mutexes
internal to libc should never be allowed to exit, call signal
handlers, or cancel.

Approved by:	-arch
2001-01-24 13:03:38 +00:00
David E. O'Brien
cad1dd7bb4 Force strong references to several pthread_* functions which are weakly
referenced to by libgcc.a.

This is needed when linking statically as SVR4 (ie, ELF) behavior is to only
link in a module if it satisfies an undefined strong reference from somewhere.
(this surprises a lot of people) Things are different when using shared libs,
the entire library and its modules and their symbols are available at run-time
(when the weak reference is seen to still be unsatisfied and is satisfied on
the spot), this is not the case with static libs.

Thus one can have a static binary with unresolved week references, and at
run-time dereference a NULL pointer.

Submitted by:	eischen
2001-01-06 06:07:52 +00:00
Ruslan Ermilov
4263595653 Prepare for mdoc(7)NG. 2000-12-29 14:08:20 +00:00
Daniel Eischen
9ffc4537c8 When retrieving the time of day in nanosleep(), store it in the
global time of day.  This costs us nothing, but is a bit of a hack
to work around a process blocking and not having the time updated
by an ITIMER_PROF signal.

PR:		23679
2000-12-20 17:04:12 +00:00
Daniel Eischen
d73eb8c8ca Enable check for pending signals after calling a signal handler.
Restoration of a threads signal mask after invocation of a signal
handler may allow pending signals to become deliverable.

PR:		23647
2000-12-20 16:55:57 +00:00
Ruslan Ermilov
c23155a43a mdoc(7) police: Er macro usage cleanup. 2000-11-22 16:02:00 +00:00