Commit Graph

480 Commits

Author SHA1 Message Date
ad 342557fb0f Update. 2007-08-23 19:21:40 +00:00
ad 0225b043d2 Acquire the correct lock in pthread_detach(). Spotted by Jan Kryl. 2007-08-23 19:13:23 +00:00
ad 40724da2ba pthread_suspend_np, pthread_resume_np, pthread_detach: return correct code
on error.
2007-08-17 14:28:31 +00:00
ad cc383c5771 Minor correction for debug code and a cosmetic change. 2007-08-16 23:37:08 +00:00
ad 2639b90e3b One more micro-optimization.. 2007-08-16 14:53:45 +00:00
ad d9adedd764 Trim fat off libpthread internal spinlock operations. Makes a mesurable
improvement across the board.
2007-08-16 13:54:16 +00:00
ad b8833ff53f - Reinitialize the absolute minimum when recycling user thread state.
Chops another ~10% off create/join in a loop on i386.
- Disable low level debugging as this is stable. Improves benchmarks
  across the board by a small percentage. Uncontested mutex acquire
  and release in a loop becomes about 8% quicker.
- Minor cleanup.
2007-08-16 12:01:49 +00:00
ad 9e28719960 Remove PT_FIXEDSTACKSIZE_LG. 2007-08-16 01:09:34 +00:00
ad ed964af19e Cache thread context for creation instead of setting it up every time.
Speeds create/join loop by about 10-15% on i386.
2007-08-16 00:41:23 +00:00
ad c94f5a91bc Simplify pthread_join(). Knocks about 5% off pthread_create/join in a loop. 2007-08-15 22:48:52 +00:00
ad 1d42dbd29a Missed variable rename.. 2007-08-07 19:58:30 +00:00
ad c3f8e2ee55 Change the signature of _lwp_park() to accept an lwpid_t and second
hint pointer, but do so in a way that remains compatible with older
pthread libraries. This can be used to wake another thread before the
calling thread goes asleep, saving at least one syscall + involuntary
context switch. This turns out to be a fairly large win on the condvar
benchmarks that I have tried.
2007-08-07 19:04:21 +00:00
ad 7bf06aa722 Make libpthread_dbg build again. 2007-08-04 18:54:12 +00:00
ad 15c28fd2d8 Update. 2007-08-04 13:46:04 +00:00
ad a014cf23cb Fix error in previous. 2007-08-04 13:43:46 +00:00
ad 50fa8db4e4 Some significant performance improvements, and a fix for a race with pthread
detach/join.

- Make mutex acquire spin for a short time, as done with spinlocks.
- Make the number of spins controllable with the env var PTHREAD_NSPINS.
- Reduce the amount of time that libpthread internal spinlocks are held.
- Rely more on the barrier effects of park/unpark to avoid taking spinlocks.
- Simplify the locking around pthreads and the global queues.
- Align per-thread sync data on a 128 byte boundary.
- Offset thread stacks by a small amount to try and reduce cache thrash.
2007-08-04 13:37:48 +00:00
ad 2813873c47 Remove unused counters. 2007-08-01 21:48:19 +00:00
wiz c54913c02b Remove scheduler activations references. Bump date. 2007-05-19 14:24:42 +00:00
ad e7c35aabc9 Remove obsolete comment. 2007-05-02 21:54:16 +00:00
heinz 9e9284adba Fixed spelling error. 2007-04-17 21:11:47 +00:00
ad b5a5e72af1 Mirror a fix made to the kernel's condvars:
After resuming execution, the thread must check to see if it
has been restarted as a result of pthread_cond_signal().  If it
has, but cannot take the wakeup (because of eg a pending Unix
signal or timeout) then try to ensure that another thread sees
it.  This is necessary because there may be multiple waiters,
and at least one should take the wakeup if possible.
2007-04-12 21:36:06 +00:00
scw 5764a76889 Remove support for NetBSD/{,evb}sh5. 2007-04-08 09:35:21 +00:00
ad a5070151ae - Test+branch is usually cheaper than making an indirect function call,
so avoid making them.
- When parking an LWP on a condition variable, point the hint argument at
  the mutex's waiters queue. Chances are we will be awoken from that later.
2007-03-24 18:51:59 +00:00
ad 1dd83d7758 Move PTHREADD_ADD(PTHREADD_COND_WOKEUP) back to the correct spot. 2007-03-21 19:08:18 +00:00
ad a63c21f286 PR lib/34931: PTHREAD_ATTR(3) doesn't document PTHREAD_CREATE_JOINABLE and
PTHREAD_CREATE_DETACHED macros. From Matthew Mondor.
2007-03-21 18:53:32 +00:00
ad d68cf1be1a - When signalling waiters, try not to awaken them immediatley. If we hold
the mutex that the waiters are using to synchronise, then transfer them
  to the mutex's waiters list so that the wakeup is deferred until release
  of the mutex. Improves the timings for CV sleep/wakeup by between 30-100%
  in tests conducted locally on a UP system. There can be a penalty for MP
  systems when only one thread is being awoken, but in practice I think it
  won't be be an issue.
- pthread_signal: search for a thread that does not have a pending wakeup.
  Threads can have a pending wakeup and still be on the waiters list if we
  clash with an earlier pthread_cond_broadcast().
2007-03-20 23:49:58 +00:00
ad b0427b61fb - Maintain a per-thread pointer to the last mutex acquired by the app, to
be used only as as a hint. Clear the pointer when releasing the mutex.
- When releasing a mutex, wake all waiters. Makes it possible to tranfer
  waiters from another object to a mutex.
2007-03-20 23:33:10 +00:00
ad bfa3094e84 Cosmetic changes. 2007-03-14 23:34:48 +00:00
ad 0c61b6a65c - pthread__park: always check for cancellation.
- pthread__unpark: cosmetic changes.
2007-03-14 23:33:42 +00:00
ad 3cf001f506 - Update to match changed pthread__park() interface.
- Simplify the locking in sem_wait().
2007-03-05 23:56:44 +00:00
ad c79299e2ec Update to match changed pthread__park() interface. 2007-03-05 23:56:17 +00:00
ad fe47a5c777 - Update to match changed pthread__park() interface.
- Fix a bug where a thread could be "reentered" onto the waiters queue.
2007-03-05 23:55:54 +00:00
ad 792cc0e17d - Simplify the interface to pthread__park() and friends slightly.
- If sysctl() fails, complain.
2007-03-05 23:55:40 +00:00
ad 8c1c910253 - Sync with reality.
- Minor cosmetic changes.
2007-03-05 23:53:53 +00:00
ad da3cc0ffcf Cosmetic and minor debugging changes. 2007-03-05 23:30:17 +00:00
ad f1c2a5c056 Undo previous, it matches IEEE 1003.1. 2007-03-05 22:25:27 +00:00
ad d6d036f667 Drop the interlock if cancelled. 2007-03-05 22:11:40 +00:00
ad 1f1ddafc0c Add __sigsuspend14, sigtimedwait as cancellation points. 2007-03-04 20:07:13 +00:00
ad 44e5b56619 Fix a sleep/wakeup race with condvars. 2007-03-02 19:56:47 +00:00
ad 67513ce0a2 Silence a gcc/lint warning. 2007-03-02 18:58:45 +00:00
ad de2138164c Remove the PTHREAD_SA option. If M:N threads is reimplemented it's
better off done with a seperate library.
2007-03-02 18:53:51 +00:00
ad dba14ef0a0 Don't grab the state lock to check for cancellation around condition
variables, as _lwp_wakeup/lwp_park provide the necessary barrier.
2007-03-02 17:47:40 +00:00
ad dc39f9ec83 pthread_detach: acquire the join lock before changing pt_flags. 2007-03-02 17:40:55 +00:00
ad 1bcb6087a6 On x86, issue the pause instruction while spinning. 2007-03-02 17:34:21 +00:00
ad 1296e8508f - Put detached & exiting threads on the tail of the deadqueue, not head.
- Don't forget to set PT_FLAG_DETACHED.
2007-02-21 22:31:38 +00:00
ad dacd4bd9ca Minor optimisation to previous: only check for continued existence of
the thread if it was detached.
2007-02-21 22:25:57 +00:00
yamt 4cdc2ed889 fix a race between pthread_exit and pthread_create.
inefficient, but better than crashing.
2007-02-15 15:39:33 +00:00
ad 3247035dcc Cast the return value of _lwp_unpark_all(), just in case. 2007-02-09 23:53:24 +00:00
ad a21c37097e Bump libpthread & libpthread_dbg minor versions so that an old SA copy
gets kept in the file system. Requested by pavel.
2007-02-09 23:00:16 +00:00
ad 401499f30e Sync with kernel changes introduced by merging the newlock2 branch. 2007-02-09 22:08:48 +00:00