Commit Graph

109 Commits

Author SHA1 Message Date
nathanw
37c11910ec Re-enable nanosleep(); kernel bug is squished (kern_time.c:1.67). 2003-03-10 22:16:36 +00:00
lukem
f043c0fb57 add __RCSID() 2003-03-08 08:03:34 +00:00
scw
65e4a59445 Don't use FP instructions when building for m68010. Fixes broken sun2 build.
G/C some unused code.
2003-03-01 11:51:59 +00:00
nathanw
a4314c450c Disable userlevel nanosleep() until I find the timer/alarm bug that it
is tickling.
2003-02-28 18:37:44 +00:00
lha
c2d825cbda If pthreads hasn't started yet when calling sigsuspend, use the systemcall 2003-02-28 17:30:07 +00:00
nathanw
508a50ac15 In pthread_create(), rearrange name-setting code so that name is set
to NULL when the attribute structure does not have a private field
allocated.
2003-02-26 23:41:01 +00:00
thorpej
b33971b9c3 Add support for naming a thread, using an API compatible with Tru64 Unix:
* pthread_attr_getname_np()
* pthread_attr_setname_np()
* pthread_getname_np()
* pthread_setname_np()

In addition to being query'able by the application (for log messages, etc.),
it is intended that these names can show up in the debugger.

Reviewed by nathanw.
2003-02-26 22:02:48 +00:00
nathanw
66fcc1ce38 In pthread_exit(), clear pt_canceled in addition to setting
PT_FLAG_CS_DISABLED in pt_flags.

Prevents cancellation cleanup handlers from thinking that they've been
canceled and exiting mid-handler. Problem spotted by Matt Thomas.
2003-02-22 00:53:29 +00:00
nathanw
6aab0806c8 Implement nanosleep() at userlevel. Threaded applications seem to like
to sleep a lot, and there's no need for each such thread to consume kernel
resources.

(accidentally checked the pthread.c part of this in yesterday; no reason
 not to finish the job)
2003-02-15 22:15:50 +00:00
jdolecek
e6781abf3f interposition sigtimedwait() with a thread-aware version, which uses
single proxy thread to do the actual syscall, and blocks other threads
in userland
2003-02-15 21:18:59 +00:00
nathanw
ca0eaa6f66 Remove unused #include <assert.h> 2003-02-15 04:39:16 +00:00
nathanw
6adb81d685 Move debug toggle to pthread_debug.h. 2003-02-15 04:38:58 +00:00
nathanw
de9d8cde2a Remove debug toggle and add debug counter for signals and broadcasts
that actually wake another thread up.
2003-02-15 04:38:33 +00:00
nathanw
53827081be Adapt to pthread__assert() and remove local debug toggle. 2003-02-15 04:37:04 +00:00
nathanw
8bcff70bb0 Define a pthread-specific assert function, pthread__assert(), that
bails out without trying to flush stdio buffers.
2003-02-15 04:34:40 +00:00
nathanw
e0ae1bd1b7 Move module-specific debugging definitions here. 2003-02-15 04:33:45 +00:00
nathanw
515d60d00c Remove unnecessary inclusion of <assert.h>. 2003-02-15 00:52:18 +00:00
nathanw
4fb740b8de Implement pthread_atfork() (in libc, because the required threadlib
stub behavior is exactly the same as the usual behavior).
2003-02-13 02:50:48 +00:00
fvdl
59f9830997 Continue at the plain switch return point in pthread__switch, not the
locked one, in the !PIC case. From Tor Egge via Havard Eidnes.
2003-02-10 11:09:33 +00:00
jdolecek
ef9eed1dac pthread_kill() was implemented, remove from list
pthread_cond_timedwait() now works even before SA initialization, but some
other routines do not; update the paragraph for this
2003-02-06 09:55:47 +00:00
jdolecek
9cac4b3f36 minor whitespace changes 2003-02-04 20:14:10 +00:00
nathanw
947e41dfa9 Arrange to pause for a while if pthread_cond_wait() or
pthread_cond_timedwait() is called before any threads have been
created and the SA infrastructure is up and running.

Addresses PR lib/20139.

XXX probably need to do this for all of the pthread_*_timedlock()
functions, too.
2003-02-01 00:57:31 +00:00
tron
8cf036775b Add a missing bracket to make this compile. 2003-01-31 12:27:19 +00:00
pk
453f6b99a3 Include <sys/types.h>
Remove v9 register defs.
2003-01-31 12:06:27 +00:00
nathanw
96b5a26db2 Use pthread__sched_sleepers() instead of iterating over sleep queues
ourself.
2003-01-31 04:59:40 +00:00
nathanw
029982e17b Add a new internal function, pthread__sched_sleepers(), which iterates
over a sleep queue and puts everything on the run queue. This permits
the iteration to be inside the acquisition of the run queue spinlock,
avoiding repetitive acquire/release cycles.
2003-01-31 04:58:57 +00:00
nathanw
69367db47f Do a similar tuneup on pthread_cond_signal() and
pthread_cond_broadcast(): use double-checked locking to avoid
pthread__self() and pthread_spinlock() when signaling or broadcasting
on a condition variable with no waiters.
2003-01-31 04:26:50 +00:00
nathanw
6cca91fc86 Mutex tuneup.
* Use a double-checked locking technique to avoid taking
   the interlock in pthread_mutex_unlock().

 * In pthread_mutex_lock() and pthread_mutex_trylock(), only store the
   stack pointer, not the thread ID, in ptm_owner. Do the translation
   to a thread ID in the slow-lock, errorcheck, and recursive mutex
   cases rather than in the common path.

 * Juggle where pthread__self() is called, to move it out of the fast path.

Overall, this means that neither pthread_self() nor
pthread_spin[un]lock() are used in the course of locking and unlocking
an uncontested mutex. Speeds up the fast path by 40-50%, and
eliminates about 98% of spinlocks used by a couple of large threaded
applications.

(Still a GET_MUTEX_PRIVATE() in the fast path... perhaps the type
should be in the main body of the mutex).
2003-01-31 02:55:00 +00:00
fvdl
1627b9c342 libpthread support for x86_64. 2003-01-30 02:10:31 +00:00
nathanw
f66d2f37f7 More rototilling:
* Implement pthread_kill().

  * Return the old thread mask, not the old process mask, in our
    interpositioned sigaction call.

  * Refer to _NSIG, not NSIG.

  * Gut pthread_sigmask(). It was handling a lot of corner cases that
    weren't legal anyway. Handle unblocked signals with a new
    pthread__kill_self() routine (also used by pthread_kill()).

  * Be more consistent with locking around pt_sigacts[].
2003-01-30 01:12:42 +00:00
nathanw
a8773f45f8 Simplify pthread__upcall() a bit by moving lock resolution before the big
switch statement, and moving upcall-type-specific code into that switch.
Beneficial side effect: don't manipulate a statelock before lock resolution
occurs.
2003-01-30 01:04:50 +00:00
nathanw
7d8ac1f6c2 Set a thread's state to RUNNABLE when yielding. 2003-01-30 01:00:58 +00:00
drochner
e81f9f1784 cosmetics 2003-01-29 14:03:08 +00:00
jdolecek
5e8bddc2e7 __sigaction14(): sanity check 'sig' before use, same way as sigaction1()
in kernel
2003-01-28 21:04:37 +00:00
nathanw
6505a5330c Add debug counters for mutex and condvar operations. 2003-01-27 21:01:00 +00:00
nathanw
05a755440a Add cancellation stubs for accept() and connect(). 2003-01-27 20:57:41 +00:00
nathanw
ee45767b84 printf format fixes. 2003-01-27 20:54:26 +00:00
nathanw
9ff1e2d385 Make pthread_barrier_wait() handle spurious wakeups from pthread__block()
by adding a generation number to the barrier structure and incrementing it
when the barrier fires.

XXX this is an ABI change for anything using barriers, but the library is
new enough and nothing in the tree uses barriers so I'm going to let it
slide. Using the private data pointer for a field that will always be present
would be excessive.
2003-01-25 00:47:05 +00:00
nathanw
fe8e8dad4a More signal rearranging:
- Signal handlers now simply continue executing the current thread,
   rather than trying to put themselves back on the queue that they came
   from, which was rather fragile. As a result, all callers of
   pthread__block() must be prepared to handle spurious wakeups.

 - When a signal arrives for a thread that is blocked in the kernel,
   note this in another field in pthread_st and set a flag. Process the
   signal and set up the trampoline for the handler *after* the thread
   unblocks, so that both the trampoline and the returned state from
   the kernel are preserved.

 - Factor out some code into a pthread__deliver_signal() routine;
   the signal-taking code in pthread_sigmask() should be able to use this
   soon.

This is still gross, and there are still some terrible MP issues lurking here,
but progress crawls along.
2003-01-25 00:43:38 +00:00
nathanw
564fe117cc Make pthread_join() accomodate spurious wakeups from pthread__block(). 2003-01-25 00:37:01 +00:00
jdolecek
254ff213ae unlock pt_statelock _after_ changing pt_state, not before
problem found and fix suggested by Nick Hudson
2003-01-24 17:43:45 +00:00
thorpej
c04d6591c0 Correct omission in notice. 2003-01-24 01:54:02 +00:00
thorpej
c184191ce3 p1003.1b semaphore manual pages have been moved to librt. 2003-01-24 01:53:27 +00:00
thorpej
1b4d724c8e sem_init(): oops, only destroy the ksem on error if it is a ksem. 2003-01-22 23:18:06 +00:00
thorpej
c151b13c1f Rewrite to use our internal scheduling primitives. 2003-01-22 22:51:42 +00:00
scw
b5ca8aee09 Yay! Working pthreads for sh5. 2003-01-22 13:52:48 +00:00
scw
04c6e0b141 pthread__lock_ras_start and pthread__lock_ras_end need to be declared
as function pointers, not character arrays, for the benefit of
platforms (e.g. SH5) where the two types are quite distinct.
2003-01-22 13:52:03 +00:00
scw
5f7bdeae84 Need to include <string.h> for memcmp() prototype. 2003-01-22 13:49:14 +00:00
nathanw
dc651e62df Don't bother acquiring the tsd_lock and reading the destructor function
if the corresponding TSD entry is empty.

Cuts down lock/unlock pairs for this operation from 256 to the number
of active TSD entries; sicne this is done when every thread exits, it saves
many total lock/unlock pairs.
2003-01-21 23:29:22 +00:00
wiz
ab206b65a6 New sentence, new line. 2003-01-21 11:48:03 +00:00