Commit Graph

320 Commits

Author SHA1 Message Date
Tor Egge
2a99cc4322 Backout unblocking of signal if no threads can currently handle it.
The check for pending signal after direct invocation of signal handler
is sufficient.
2006-10-14 01:11:44 +00:00
Tor Egge
081871afc8 Delay unblocking signal and restoring process signal mask until the
thread signal mask has been updated to avoid stack overflow during signal
bursts.

Don't block signal forever if no threads can currently handle signal.

Check for pending signal after direct invocation of signal handler.
2006-10-13 20:12:07 +00:00
Tor Egge
c8b69d87c0 Delay setting wakeup time until after poll array has been allocated.
Blocking on the malloc spinlock would cause the select timeout to be lost.
2006-10-13 20:04:13 +00:00
Tor Egge
ed5348ec19 Sync thread jump table with libc and other thread libraries. 2006-10-13 20:01:40 +00:00
Stefan Farfeleder
ad7c49168f - Prefix MUTEX_TYPE_MAX with PTHREAD_ to avoid namespace pollution.
- Remove the macros MUTEX_TYPE_FAST and MUTEX_TYPE_COUNTING_FAST.

OK'ed by:	deischen
2005-08-19 21:31:42 +00:00
John Baldwin
2bd979f7a3 Mark _thread_exit() and __sys_exit() as __dead2 to quiet some warnings. 2005-05-31 19:57:23 +00:00
John Baldwin
94e7919893 Style tweak. 2005-05-31 19:56:52 +00:00
Xin LI
8dcb56dc78 Provide more POSIX-complaint ttyname_r(3) interface[1], which is slightly
different from what has been offered in libc_r (the one spotted in the
original PR which is found in libthr has already been removed by David's
commit, which is rev. 1.44 of lib/libthr/thread/thr_private.h):
	- Use POSIX standard prototype for ttyname_r, which is,
		int ttyname_r(int, char *, size_t);
	  Instead of:
	  	char *ttyname_r(int, char *, size_t);
	  This is to conform IEEE Std 1003.1, 2004 Edition [1].
	- Since we need to use standard errno for return code, include
	  errno.h in ttyname.c
	- Update ttyname(3) implementation according to reflect the API
	  change.
	- Document new ttyname_r(3) behavior
	- Since we already make use of a thread local storage for
	  ttyname(3), remove the BUGS section.
	- Remove conflicting ttyname_r related declarations found in libc_r.

Hopefully this change should not have changed the API/ABI, as the ttyname_r
symbol was never introduced before the last unistd.h change which happens a
couple of days before.

[1] http://www.opengroup.org/onlinepubs/009695399/functions/ttyname.html

Requested by:	Tom McLaughlin <tmclaugh sdf lonestar org>
Through PR:	threads/76938
Patched by:	Craig Rodrigues <rodrigc crodrigues org> (with minor changes)
Prompted by:	mezz@
2005-05-13 16:27:30 +00:00
Joe Marcus Clarke
d525de835f Increase the default stacksizes:
32-bit		64-bit
main thread	2 MB		4 MB
other threads	1 MB		2 MB

Adapted from:	libpthread
Approved by:	deischen
2005-02-28 17:15:31 +00:00
Jeffrey Hsu
2353e77b0f More fixes to the copyright notice.
Submitted by:	Ken Smith <kensmith@cse.Buffalo.EDU>
2005-01-08 17:16:43 +00:00
Jeffrey Hsu
c26a1d9f0e Fix copyright notice. 2005-01-08 01:59:36 +00:00
Greg Lehey
00c948e4ce Add pthread_atfork().
PR:  		bin/68841
Submitted by:	Dan Nelson <dnelson@allantgroup.com>
2004-12-10 03:36:45 +00:00
David Schultz
6004362e66 Don't include sys/user.h merely for its side-effect of recursively
including other headers.
2004-11-27 06:51:39 +00:00
Stefan Farfeleder
4eae39bfdf Avoid using void pointers in additive expressions.
PR:		56653
2004-08-14 17:46:10 +00:00
Daniel Eischen
39edba076e Initialize the (i386) frame pointer when setting up a thread
context.

Submitted by:	Marc Olzheim <marcolz@stack.nl>
Tested by:	Marc Olzheim <marcolz@stack.nl>
2004-01-22 19:15:08 +00:00
Daniel Eischen
7d7a08f174 MFlibpthread: Add a simple work-around for deadlocking on recursive
readlocks on a rwlock while there are writers waiting.
2004-01-08 15:39:12 +00:00
Daniel Eischen
eae42a5949 Reenable signals for threads after joining.
Submitted by:	Marc Olzheim <marcolz@stack.nl>
2003-12-31 13:41:54 +00:00
Daniel Eischen
6512f49fe6 Return to the caller if write() returns 0.
PR:	59291
2003-12-17 16:44:03 +00:00
Peter Wemm
29f2f145e4 For the amd64 we need to do some extra stack alignment fixups. Otherwise
we can end up with some threads with a non-16-byte-aligned stack.  This
causes some interesting side effects, including general protection
faults leading to a SIGBUS when doing floating point or varargs.  This
should be just a verbose NOP for the other platforms.

Approved by:  re (scottl)
2003-12-03 06:54:40 +00:00
Daniel Eischen
fcd58c1978 If __sys_write() returns 0, allow that to exit the loop in libc_r's
wrapped version of write().

Submitted by:	dan@langille.org
2003-09-29 13:41:26 +00:00
Mark Peek
6fcd700395 Add wrapper for kqueue() to keep track of the allocated fd and allow it to
be closed. This fixes a file descriptor leak when closing a kqueue() fd.

Reviewed by:	deischen
MFC after:	1 week
2003-07-25 17:02:33 +00:00
Alexander Leidinger
f970961773 Sanity check fd before using it as an array index.
Noticed by:	ted@NLnetLabs.nl (Ted Lindgreen)
Approved by:	ru
2003-06-09 16:45:37 +00:00
Peter Wemm
3aefe09423 Port libc_r to amd64, and turn it back on for amd64. It passes all of
the same src/lib/libc_r/test/* tests that the other platforms pass.
2003-06-02 22:22:52 +00:00
Ruslan Ermilov
61fa6d584f Fixed another bug in the threaded close() call; clear the
stale stdio descriptors flags.

PR:		bin/51535
Submitted by:	Enache Adrian <enache@rdslink.ro>
Reviewed by:	deischen
Approved by:	re (scottl)
2003-05-31 05:23:20 +00:00
Ruslan Ermilov
d635dc4671 If an application closes one of its stdio descriptors (0..2),
an excessive close() on one of these descriptors would cause
a memory for this descriptor to be allocated in the internal
descriptor table.  When this descriptor gets used again, e.g.
through the call to open() or socket(), the descriptor would
be erroneously left in the blocking mode, and the whole
application would get stuck on a blocking operation, e.g.,
in accept(2).

Prevent this bug from happening by disallowing close() against
non-active descriptors (return -1 and set errno to EBADF in
this case).

Reviewed by:	deischen
Approved by:	re (scottl)
2003-05-31 05:20:44 +00:00
John Polstra
8c0d4b5f92 Add stub implementations of pthread_[gs]etconcurrency to libc_r and
libthr.  No changes were made to libpthread by request of deischen,
who will soon commit a real implementation for that library.

PR:		standards/50848
Submitted by:	Sergey A. Osokin <osa@freebsd.org.ru>
MFC after:	1 week
2003-04-20 01:53:13 +00:00
Jeff Roberson
cc3521d660 - Define a _spinunlock() function so that threading implementations may do
more complicated things than just setting the lock to 0.
 - Implement stubs for this function in libc and the two threading libraries
   that are currently in the tree.
2003-03-26 04:02:24 +00:00
Marcel Moolenaar
cafd6dbd76 Fix threaded applications on ia64 that are linked dynamicly. We did
not save (restore) the global pointer (GP) in the jmpbuf in setjmp
(longjmp) because it's not needed in general. GP is considered a
scratch register at callsites and hence is always restored after a
call (when it's possible that the call resolves to a symbol in a
different loadmodule; otherwise GP does not have to be saved and
restored at all), including calls to setjmp/longjmp. There's just
one problem with this now that we use setjmp/longjmp for context
switching: A new context must have GP defined properly for the
thread's entry point. This means that we need to put GP in the
jmpbuf and consequently that we have to restore is in longjmp.
This automaticly requires us to save it as well.

When setjmp/longjmp isn't used for context switching, this can be
reverted again.
2003-03-05 04:39:24 +00:00
Marcel Moolenaar
d4f7f050a8 Don't cast an int to a pointer type without (possibly) widening the
integral type to the size of a pointer type when it's known that the
cast is valid. On ia64 such casts are generally bad news and has led
us (=peter :-) to make such casts fatal. By casting to intptr_t
before casting to a pointer type, this now compiles cleanly in LP64
architectures. Note that the final cast has been changed to void*
(instead of siginfo_t*) to make it explicit that we're not trying to
pass a siginfo_t pointer but rather trying to pass an int when the
prototype says it should be a pointer.
2003-03-05 04:28:08 +00:00
Alfred Perlstein
969e2ea158 Actually link in the attr_{set,get}stack. 2003-02-11 07:28:28 +00:00
Alfred Perlstein
4e44912c6c Add pthread_attr_getstack() and pthread_attr_setstack().
Submitted by: Craig Rodrigues <rodrigc@attbi.com>
2003-02-10 08:48:04 +00:00
Alexey Zelkin
618a8b4df0 Improve pthread_attr_get_np() by enabling it to return thread's real stack
address instead of specified by pthread_attr_t passed to pthread_create().

Suggested by:	deischen
2003-02-03 10:08:45 +00:00
Daniel Eischen
c54f72859c Increase the scheduler stack to 4 pages. This should prevent a stack
overflow when dumping thread info (generated by receipt of SIGINFO).

Reported by:	jmallet
2003-01-11 00:43:20 +00:00
Max Khon
f7ed1917e2 pthread_attr_get_np() now takes 'pthread_t' (not 'pthread_t *')
to be consistent with other pthread_XXX functions
2003-01-07 21:43:30 +00:00
Marcel Moolenaar
4b1d654efb Port libc_r to ia64. We need to do things slightly different
because we have 2 stacks per thread: the regular downward
memory stack and the irregular upward register stack. This
implementation lets both stacks grow toward each other. An
alternative scheme is to have them grow away from each other.
The alternate scheme has the advantage that both stack grow
toward guard pages. Since libc_r is virtually dead and we
really want the *context stuff for thread switching, we don't
try to be perfect, just functional.
2003-01-06 00:56:23 +00:00
Thomas Moestl
54a701f52e Add MD definitions for sparc64. This is based on work by des. 2003-01-05 22:37:03 +00:00
Daniel Eischen
3f28905813 Fix typos in comment.
Submitted by:	Craig Rodrigues <rodrigc@attbi.com>
2002-12-28 05:20:03 +00:00
Ruslan Ermilov
8d436e783f Make accept(), connect(), recvfrom(), recvmsg(), sendmsg(),
and sendto() cancelation points, as required by POSIX.1-2001.

Reviewed by:	deischen
2002-12-19 11:39:20 +00:00
Archie Cobbs
e46cac58cd When about to do an execve(), don't reset the O_NONBLOCK flag on any file
descriptors that have the close-on-exec flag set, as that will have no
effect anyway and might screw something else up if the file descriptor
happens to be shared with another process.

PR:		standards/43335
MFC after:	1 week
2002-11-15 00:34:28 +00:00
Daniel Eischen
f38fac1471 At initialization, override the pthread stub routines in libc
by filling in the jump table.

Convert uses of pthread routines within libc_r to use the internal
versions (_pthread_foo instead of pthread_foo).

Remove a couple of globals from application namespace.
2002-11-13 18:13:26 +00:00
Archie Cobbs
6578194b8b Fix bogus return values from libc_r's writev() routine in situations where
a partial-write is followed by an error.

PR:		43335
MFC after:	3 days
2002-11-12 19:01:49 +00:00
Archie Cobbs
83189ac197 Fix bogus return values from libc_r's write() routine in situations where
a partial-write is followed by an error.

PR:		43335
MFC after:	1 week
2002-11-05 00:59:18 +00:00
Daniel Eischen
0ece26b0ba Use the strong symbol'd version of pthread_mutex_init so we don't
accidentally call a stub or application provided version of the
same routine.

Submitted by:	dfr
2002-10-31 18:17:58 +00:00
Alexey Zelkin
cab33357a5 Hook uthread_attr_get_np.c to build 2002-10-26 13:55:35 +00:00
Alexey Zelkin
6dc0be5f9f Add pthread_attr_get_np() function. This is FreeBSD non-portable POSIX threads
extenston function. It supposed to provide facility to get already created
thread's attributes. Looks like it's last thing we need to make JDK's Hotspot
building without requirement to have source tree.

Reviewed by:	deischen
MFC after:	3 days
2002-10-26 13:53:22 +00:00
Alexey Zelkin
64536616e6 Be more agresive on arguments' checking.
OK'ed by:	deischen
MFC after:	3 days
2002-10-26 13:47:06 +00:00
Max Khon
979187053d remove unused __sys_sigaltstack() declaration
Approved by:	deischen
2002-10-22 17:13:32 +00:00
Juli Mallett
47a6e68f2c When dumping thread info, only include the filename and line if we actually
know what file! (Prevents use of NULL).

MFC after:	1 day
Reviewed by:	deischen
2002-10-20 22:49:06 +00:00
Juli Mallett
4aba47f7ce FD locking is not enabled anymore, so the table which contains the owner
of a file descriptor has NULL entries, so don't dereference the table entries
to get the owners ever -- don't print the owners when processing a thread_dump
request as a result of SIGINFO.

Reviewed by:	deischen
2002-10-17 20:26:26 +00:00
Max Khon
19521b0699 fix typo in comments (in preparation for MFC)
Approved by:	deischen
2002-10-15 16:40:57 +00:00