Commit Graph

257 Commits

Author SHA1 Message Date
David Xu
5b54b0891a Backout last commit.
Requested by: jhb
2003-03-15 04:45:42 +00:00
David Xu
047a20e644 Fix a bug in rwlock. When a rwlock was locked by reader threads, a
writter thread can block reader threads to get read lock.
2003-03-14 01:02:47 +00:00
Alexey Zelkin
68d8899c03 Fix cut'n'paste error
Noticed by:	julian
2003-03-05 20:50:03 +00:00
Alexey Zelkin
09492be669 MFlibc_r: add and document pthread_attr_get_np() function. 2003-03-03 22:40:20 +00:00
David Xu
96dfe788ad Fix compiling error. 2003-02-26 08:28:28 +00:00
Jonathan Mini
3b63c6c8ea Insert threads interrupted by a signal while running onto the run queue. 2003-02-23 21:15:25 +00:00
Jonathan Mini
f88cb3c627 Add signal logic to the build. 2003-02-23 21:14:08 +00:00
Jonathan Mini
faa8342f9f Deliver signals posted via an upcall to the appropriate thread. 2003-02-17 10:05:18 +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
Jonathan Mini
e9d0431f0b Schedule spinlocked threads by moving them through the work queue, instead
of the wait queue.

Approved by: re (blanket)
Stolen from: davidxu
2002-11-24 06:45:45 +00:00
Jonathan Mini
4df51f23bb Get the wall clock time from the KSE mailbox, rather than doing another
syscall.
2002-11-24 06:43:21 +00:00
David Xu
662c0429b9 Fix idle timeout bug, use correct current time of day. 2002-11-20 12:35:59 +00:00
Jonathan Mini
1cb53a1828 Schedule an idle context to block until timeouts expire without blocking
further upcalls.
2002-11-12 00:55:01 +00:00
Jonathan Mini
40e044cbd3 Make pthread_sigmask(3) operate on the thread signal mask, not the process
signal mask.
2002-10-30 07:13:27 +00:00
Jonathan Mini
2d9a293b4e Use KSE to schedule threads. 2002-10-30 06:07:18 +00:00
Robert Drehmel
e31d11c36a Add the 'restrict' type qualifier to the prototypes of `sigaction',
`sigprocmask', `sigaltstack', and `sigwait' as well as to the
prototypes of the apparantly unimplemented functions `sigtimedwait'
and `sigwaitinfo'.  This complies with IEEE Std 1003.1-2001.
2002-10-02 10:53:44 +00:00
Jonathan Mini
255ab70cdf Make libpthread KSE aware.
Reviewed by:	deischen, julian
Approved by:	-arch
2002-09-16 19:52:52 +00:00
Jonathan Mini
cc118d869b 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
2002-09-16 08:45:36 +00:00
Daniel Eischen
d8b5986dd6 Remove much of the dereferencing of the fd table entries to look
at file flags and replace it with functions that will avoid null
pointer checks.

MFC to be done by archie ;-)

PR:		42100
Reviewed by:	archie, robert
MFC after:	3 days
2002-08-29 23:06:07 +00:00
Archie Cobbs
afa4625307 Make the libc_r version of select() set the readable or writable
file descriptor bit if poll() returns POLLERR, POLLHUP, or POLLNVAL.
Othewise, it's possible for select() to return successfully but
with no bits set.

Reviewed by:	deischen
MFC after:	3 days
PR:		bin/42175
2002-08-29 21:39:19 +00:00
Archie Cobbs
ccde72a411 When poll(2)'ing for readability or writability of a file descriptor
on behalf of a thread, we should check the POLLERR, POLLHUP, and
POLLNVAL flags as well to wake up the thread in these cases.

Suggested by:	deischen
MFC after:	3 days
2002-08-29 00:44:11 +00:00
Philippe Charnier
7fed38d0a0 Replace various spelling with FALLTHROUGH which is lint()able 2002-08-25 13:10:45 +00:00
Daniel Eischen
582dfa2dd4 Oops, forgot to set the suspended flag for threads that are created
initially suspended.  This was preventing such threads from getting
resumed.

Reported by:	Bill Huey <billh@gnuppy.monkey.org>
2002-07-09 13:24:52 +00:00
Daniel Eischen
88127f1a62 Make sigpending and sigsuspend account for signals that are pending on
the process as well as pending on the current thread.

Reported by:	Andrew MacIntyre <andymac@bullseye.apana.org.au>
2002-06-28 13:28:41 +00:00
Daniel Eischen
b4e1c937c7 Add a wrapper for pselect() in order to make it a cancellation point.
Prompted by: wollman
2002-06-28 13:26:02 +00:00
Robert Watson
4a85ccbe6d Missed in earlier commit -- I did cvs commit src/lib/libc. Oops. 2002-06-14 04:02:25 +00:00
Daniel Eischen
5eb8d1f0b0 Revamp suspend and resume. While I'm here add pthread_suspend_all_np()
and pthread_resume_all_np().  These suspend and resume all threads except
the current thread, respectively.  The existing functions pthread_single_np()
and pthread_multi_np(), which formerly had no effect, now exhibit the same
behaviour and pthread_suspend_all_np() and pthread_resume_all_np().  These
functions have been added mostly for the native java port.

Don't allow the uthread kernel pipe to use the same descriptors as
stdio.  Mostily submitted by Oswald Buddenhagen <ossi@kde.org>.

Correct some minor style nits.
2002-05-24 04:32:28 +00:00
Alfred Perlstein
2b75bbdb31 Undo namespace pollution by prefixing the globals pthread_guard_default and
pthread_page_size.

Fix a bunch line wrapping.

Pointed out by: deischen
2002-05-15 05:37:48 +00:00
Alfred Perlstein
efe5270b1e Don't use PAGE_SIZE in userland, instead use getpagesize(), this is to
allow running on other arches when the instructions are supported but
the page size granularity is not.

Glanced at by: peter
2002-05-13 07:58:15 +00:00
Alfred Perlstein
e5ba687a2c 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.
2002-05-11 08:13:42 +00:00
Archie Cobbs
663fc9cc7c Make these functions cancellation points like they should be:
poll(2), readv(2), select(2), wait4(2), writev(2).

PR:		bin/37658
Reviewed by:	deischen
MFC after:	1 week
2002-05-02 19:58:43 +00:00
Archie Cobbs
ca0989d865 Make sure calls to pthread_cancel() do not take effect if the target
thread is already exiting.

PR:		bin/37614
Reviewed by:	deischen
MFC after:	1 week
2002-05-02 19:57:59 +00:00
David E. O'Brien
07a7a2eba8 The GCC developers have made good on their threats against #pragma for 3.1.
Use __weak_reference in place of the #pragma.

Submitted by:	eischen
2002-04-15 23:11:38 +00:00
Jeroen Ruigrok van der Werven
92d2baa6a2 Return correct number of total bits set in all fd_set's.
Change case of POLLNVAL as an error.
Remove POLLHUP and POLLERR from one case, their place is most likely
amongst read events.

PR:		33723
Submitted by:	Alexander Litvin <archer@whichever.org>
Reviewed by:	deischen [Provided a small change to the PR patch as well]
MFC after:	4 weeks
2002-04-09 05:41:00 +00:00
Mark Murray
4cd0119367 Do not use __progname directly (except in [gs]etprogname(3)).
Also, make an internal _getprogname() that is used only inside
libc. For libc, getprogname(3) is a weak symbol in case a
function of the same name is defined in userland.
2002-03-29 22:43:43 +00:00
Daniel Eischen
3003bdb598 Add the ability to recognize old references to keys, and return NULL
when old keys are referenced (after pthread_key_delete()) via
pthread_getspecific().
2002-03-19 22:58:56 +00:00
Brian S. Dean
b18ae9245d Fix the return code from pthread_rwlock_try[rw|rd]lock() functions;
these should return EBUSY when the calling thread would block.

MFC after: 2 weeks
2002-03-15 18:27:58 +00:00
Daniel Eischen
ca4b2c1a79 Properly clear the status of a join operation if the joining thread is
canceled or the joinee is detached.
2002-03-06 19:28:41 +00:00
Daniel Eischen
9e9c4443f6 Don't rely on <sys/signal.h> to include <sys/ucontext.h> 2002-02-17 17:21:27 +00:00
Maxim Konovalov
0878d2e5e9 Correct a typo pthread_attr_setscope() function fails unconditionally
due to.

PR:		misc/30699
Reviewed by:	jasone, ru
Approved by:	jasone, ru
MFC after:	1 week
2002-02-14 15:20:36 +00:00
Daniel Eischen
69c287d288 This has been sitting in my local tree long enough. Remove the use
of an alternate signal stack for handling signals.  Let the kernel
send signals on the stack of the current thread and teach the threads
signal handler how to deliver signals to the current thread if it
needs to.  Also, always store a threads context as a jmp_buf.  Eventually
this will change to be a ucontext_t or mcontext_t.

Other small nits.  Use struct pthread * instead of pthread_t in internal
library routines.  The threads code wants struct pthread *, and pthread_t
doesn't necessarily have to be the same.

Reviewed by:	jasone
2002-02-09 19:58:41 +00:00
Daniel Eischen
2d170746c7 Use the real function address (instead of function address + 8) for the
return address when modifying a jmp_buf to create a new thread context.
Also set t12 with the return address.

This should fix libc_r on alpha.

With much detective work by: Bernd Walter <ticso@cicely.de>
2001-12-22 06:11:06 +00:00
Daniel Eischen
7512c816c0 Fix the retrieval of USRSTACK via sysctl so that it works for 64-bit
archs.  This should fix libc_r on alpha.

Submitted by:	Bernd Walter <ticso@cicely9.cicely.de>
2001-12-18 02:02:59 +00:00
Daniel Eischen
320bfcf3f1 When cancelling a thread while in a join operation, do not detach
the target thread of the join operation.  This allows the cancelled
thread to detach the target thread in its cancellation handler.
This bug was found by Butenhof's cancel_subcontract test.

Reviewed by:	jasone
2001-12-16 13:26:44 +00:00
Daniel Eischen
35686a943a Pull the target thread of a join operation from the correct place
when cancelling a thread.
2001-12-15 15:52:24 +00:00
Daniel Eischen
ccc7b69205 Fix pthread_join so that it works if the target thread exits while
the joining thread is in a signal handler.

Reported by:	Loren James Rittle <rittle@labs.mot.com>
MFC after:	1 week
2001-11-17 14:28:39 +00:00
Peter Wemm
eb9053b12f Make libc_r check the kern.usrstack sysctl instead of using internal
kernel #defines to figure out where the stack is located.  This stops
libc_r from exploding when the kernel is compiled with a different
KVM size.  IMHO this is all kinda bogus, it would be better to just
check %esp and work from that.
2001-10-26 21:19:22 +00:00
Ruslan Ermilov
98f9b06876 Style: sort __sys_foo() prototypes, tabs -> spaces, etc. 2001-10-26 18:45:02 +00:00
Ruslan Ermilov
53cff25eeb 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
2001-10-26 17:46:36 +00:00