Commit Graph

406 Commits

Author SHA1 Message Date
yamt
41cc94b9f0 remove unused IDLESPINS. 2006-10-03 09:37:07 +00:00
wrstuden
25b0eaef3c Close a window in which we can not notice a recently-slept-on-our
mutex thread, thus leaving a thread sleeping on an unlocked mutex.

Reviewed by myself and Christos.

Problem reported by Arne H. Juul, arnej at pvv dot ntnu dot no,
in PR 26208. This fix represents option 1 presented in the PR.
2006-08-22 21:46:09 +00:00
ross
1a70c2f1e4 Err, restore the name of pthread__switch_return_point, it is
referenced from C code.
2006-07-09 01:07:38 +00:00
ross
a228aa3de2 Revise for LP64.
Encapsulate previously copied code sections into macros.
2006-07-08 05:09:44 +00:00
ross
032dc727f7 remove unreferenced temporary label 2006-07-08 05:04:49 +00:00
chuck
f4e3e7fe3b sigtimedwait: if we collect a queued signal via pt_siglist, do not
forget to clear it out of pt_siglist, otherwise we will keep getting
it over and over again.   fixes a problem introduced in rev 1.43.

problem observed with mysqld where sending it a SIGHUP after it has
set an alarm (e.g. due to some package like rt3 using it) caused the
signal handler thread to go into a tight loop (collecting a SIGALRM
[via sigwait() in mysqld.cc] that would not go away due to the above
issue).   mysqld appears to get a SIGHUP when /etc/rc exits, so it
can go into this tight loop after a reboot (but not if you restart
it by hand).   the bad sequence is:
	/etc/rc runs:
		- starts mysqld
		- starts web server with rt3 fastcgi starts
		- fastcgi/rt3 talks to mysqld (causing it to set an alarm)
		- /etc/rc exits, SIGHUP goes to mysqld
		- mysqld catches SIGHUP, signal handler thread gets
			stuck in loop (database continues to operate, slowly).

you can also trigger the problem by sending mysqld a SIGHUP by hand after
you've caused it to set an alarm by connecting to it.
2006-06-12 16:45:14 +00:00
snj
a640fe8c43 It's "its." 2006-04-24 19:00:29 +00:00
drochner
f782e99583 There is no point in using the internal sigprocmask() to initialize
the process' signal mask -- this ends up in a no-op.
Use the system call directly instead.
(This might be done in pthread_sig.c, but for now I wanted a simple
patch which is easily tested and pulled up.)
2006-04-24 18:39:36 +00:00
cube
562d0d89a2 Instead of using hard-coded values for various registers, get them from the
current context.  Valid values can change depending on how the kernel is
setup.  i386 and amd64 happen to be setup differently.
2006-03-29 22:55:15 +00:00
christos
142b3180cb Coverity CID 882: Avoid NULL deref. 2006-03-19 23:01:03 +00:00
yamt
9f9e6a32dd - do PTHREAD_MLOCK_KLUDGE in pthread__stackid_setup, rather than callers,
so that the main thread is not different from others.
  as a side effect, fix memory leak in pthread_create on error.
- make pthread__stackid_setup return a error rather than calling err(2).
2006-02-12 11:41:53 +00:00
skrll
2b3543128f I was a bit over zealous with my last change so revert the
locked_return_point change.

Loading the instruction at locked_return_point as a return value didn't
work so well.

Thanks to uwe, cube, and dsl.
2006-01-09 22:17:16 +00:00
kleink
5af00b0b39 pthread_sigmask(): Add restrict qualifier to set, oset args. 2006-01-07 20:10:29 +00:00
uwe
6b8eb49dd6 Use PLT for PIC calls to avoid text relocs in the shared library. 2006-01-06 22:46:14 +00:00
uwe
55ad9313a6 In PIC code call setcontext(2) via PLT to avoid text reloc in the
shared library.
2006-01-04 17:44:53 +00:00
skrll
73b7bdcee7 A couple of fixes to make libpthread really shared, i.e. not have text re-
locations:

	- Don't declare pthread__switch_away global
	- Do the PIC dance for pthread__switch_return_point and
	  pthread__locked_switch. Ideally these (and other) symbols would
	  be hidden.

Thanks to uwe@, dyoung@ and elad@ for help.

XXX sh3 is still to be done.
XXX vax does strange things.
2006-01-04 12:43:43 +00:00
uwe
ffaa72c2cc Adapt to new PIC macros that are now in <machine/asm.h>. Same binary
code is generated (still with text relocs, but eliminating them is the
next step).
2005-12-31 05:08:28 +00:00
perry
ce666bb8ce __asm__ -> __asm 2005-12-24 23:10:08 +00:00
perry
4e11af46bc Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete. 2005-12-24 21:11:15 +00:00
christos
d7e5caf4fd include libc after our own files to fix ports that have 2 assym.h's. One
in pthread and one in libc.
2005-12-13 22:07:20 +00:00
chs
3ad2320789 if mlock() fails in pthread_create(), return EAGAIN instead of
failing an assertion.
2005-10-19 02:44:45 +00:00
chs
0e67554241 starting the pthread library (ie. calling pthread__start()) before
any threads are created turned out to be not such a good idea.
there are stronger requirements on what has to work in a forked child
while a process is still single-threaded.  so take all that stuff
back out and fix the problems with single-threaded programs that
are linked with libpthread differently, by checking if the library
has been started and doing completely different stuff if it hasn't been:
 - for pthread_rwlock_timedrdlock(), just fail with EDEADLK immediately.
 - for sem_wait(), the only thing that can unlock the semaphore is a
   signal handler, so use sigsuspend() to wait for a signal.
 - for pthread_mutex_lock_slow(), just go into an infinite loop
   waiting for signals.

I also noticed that there's a "sem2" test that has never worked in its
single-threaded form.  the problem there is that a signal handler tries
to take a sem_t interlock which is already held when the signal is received.
fix this too, by adding a single-threaded case for sig_trywait() that
blocks signals instead of using the userland interlock.
2005-10-19 02:15:03 +00:00
chs
ba70e96a09 in pthread_kill() and pthread_suspend_np(), return without doing anything
if the target thread is a zombie.

in all the functions that didn't do so already, verify a pthread_t before
dereferencing it (under #ifdef ERRORCHECK, since these checks are not
mandated by the standard).

clean up some debugging stuff.
2005-10-16 00:37:52 +00:00
chs
c190c7de90 fix the interaction between sigtimedwait() and pthread_kill(),
both waking up a sleeping thread and avoiding going to sleep if
a signal is already pending.  fixes PR 30348.
2005-10-16 00:31:35 +00:00
chs
2415c56ed0 in pthread_mutex_lock_slow(), pthread_rwlock_timedrdlock() and sem_wait(),
call pthread__start() if it hasn't already been called.  this avoids
an internal assertion from the library if these routines are used
before any threads are created and they need to sleep.
fixes PR 20256, PR 24241, PR 25722, PR 26096.
2005-10-16 00:07:24 +00:00
kleink
34ef731cb3 Change the sched_*() functions to return -1 and set errno to ENOSYS
(per the standard) instead of returning ENOSYS.  Noted by Ian Zagorskih
in PR kern/30970.
2005-10-09 11:17:28 +00:00
tv
21eb6bbacb pthread_attr_getschedpolicy() wasn't setting the return buffer at all.
SCHED_OTHER happens to be 0, so this assignment to "int *" succeeds,
and becomes a no-op.

Fix by dereferencing "policy" to do the assignment, thus filling the
return buffer with 0.
2005-09-21 15:27:14 +00:00
christos
f1cc481dfe XXX: Work around libpthread's "intimate" connection with libc. 2005-09-13 02:45:38 +00:00
christos
0393abcb27 Revert part of previous; we need to merge acts.sa_mask into our pthread mask.
Thanks martin...
2005-07-26 20:16:07 +00:00
christos
9d60b1fc89 - removed bogus acts.sa_mask setting.
- unblock the signal we are currently delivering, because it might have
  been blocked if we are woken up by another thread.
2005-07-26 20:11:02 +00:00
nathanw
0774992407 Add cancellation protection to pthread_once() as per the standard; if
the once routine is cancelled, the effect on once_control is as if
pthread_once() was never called.

Bug report and fix from PR lib/30734.
2005-07-16 23:14:53 +00:00
yamt
9493e4bf43 make this compile without PTHREAD_MLOCK_KLUDGE. 2005-07-01 12:35:18 +00:00
peter
d4cc3cce89 Create links for pthread_attr_setschedparam.3
and pthread_attr_getschedparam.3 to pthread_attr.3.

From Igor Sobrado in PR/29997.
2005-06-17 18:37:24 +00:00
wiz
52e496a68e New sentence, new line. 2005-06-17 18:26:53 +00:00
wiz
27d002e8de New sentence, new line.
Break much too long line.
2005-06-17 18:23:52 +00:00
peter
a28acffec8 Don't create links to pthread_barierattr_init.3 and
pthread_barierattr_destroy.3 but to pthread_barrierattr_init.3
and pthread_barrierattr_destroy.3 (note the 2 rs in barrier).
2005-06-17 18:23:19 +00:00
peter
568accb2c0 Fix various spelling errors.
From Igor Sobrado in PR/29997.
2005-06-17 18:07:06 +00:00
thorpej
d93ab54e03 Use TOOL_GENASSYM. Part of PR toolchain/30350 2005-05-30 16:02:56 +00:00
nathanw
5f7a108732 Avoid passing along a timespec with a negative number of seconds if
the current time plus the caller-supplied time to sleep wraps the
time_t. Instead, sleep until INT_MAX.
2005-04-19 16:38:57 +00:00
matt
38b7b2fcde Merge updates to algorithms from i386 switch code. 2005-04-09 20:53:19 +00:00
matt
7fa678813d Add STACKSPACE 2005-04-09 20:50:27 +00:00
matt
e722e50c79 Rework and cleanup. Don't use REI, fake a call frame instead. 2005-04-09 20:49:02 +00:00
kleink
9cf9c2316b Add restrict qualifiers to <pthread.h> function arguments. 2005-03-21 17:55:07 +00:00
kleink
34579587e1 Include <sys/select.h> explicitly rather than relying on other headers
to do it.
2005-03-21 09:00:49 +00:00
kleink
363c26d4ba Interpose cancellation points in pollts() and pselect(), bringing us
to libc.so.12.127 and libpthread.so.0.6.
2005-03-18 11:23:44 +00:00
jwise
f579845294 Lint warning police -- don't use `//' for comments in C code. 2005-03-17 17:23:21 +00:00
kleink
ebf592f1e6 Move up the definition of __LIBC12_SOURCE__; since <poll.h> now includes
<sys/sigtypes.h> this is needed earlier.
2005-03-10 00:34:23 +00:00
nathanw
22f226cf84 Correct the order of arguments to __sigplusset() in two places to correct
the signal mask experienced by signal handlers in threaded programs.
Fixes regress/lib/libpthread/sigmask3.
2005-02-27 18:25:01 +00:00
nathanw
916de87872 Keep the kernel updated with signal action signal masks (act.sa_mask) until
threads are started, since before that the traditional signal invocation
method will be used. Fixes regress/lib/libpthread/sigmask2.
2005-02-26 20:33:06 +00:00
nathanw
1eaf7124f7 Fetch the old signal mask for the signal action whether or not we're
setting a new signal action; this makes sigaction(sig, NULL, &oact)
return a sensible value in the signal mask instead of stack trash.

Addresses PR lib/29536.

XXX the mask seen by signal handlers in a program linked with
libpthread but not yet multithreaded will not reflect masks set here.
2005-02-26 18:15:25 +00:00