Commit Graph

297 Commits

Author SHA1 Message Date
christos 38b1c6f405 Add:
int    pthread_attr_setcreatesuspend_np(pthread_attr_t *);
int    pthread_suspend_np(pthread_t);
int    pthread_resume_np(pthread_t);

needed for java. Approved and fixed by cl.
2003-11-09 18:56:48 +00:00
fvdl c4e432f3bd Make register usage more consistent, also in comparison with the i386
version, for easier maintenance.
2003-11-08 21:46:42 +00:00
fvdl 127827f46e Restore %rax correctly during a full context restore (oops). 2003-11-08 21:45:59 +00:00
wiz 85cc64da0f Typo; from Jared Yanovich via jmc@openbsd. 2003-11-02 11:18:10 +00:00
yamt 71b290e975 use explicit "l" suffixes. (eg. lea -> leal) 2003-10-30 13:56:37 +00:00
wiz bc81ecac30 sigwait(2), not (3). 2003-10-30 12:57:11 +00:00
jdolecek e2e1314ccd bump date too 2003-10-30 11:53:33 +00:00
jdolecek f65cf67b62 xref sigwait(3) 2003-10-30 11:51:42 +00:00
cl 812a254c5d remove incorrect assert:
regular threads can block in the kernel while holding (libpthread) locks
and have to be continued

XXX if the blocked upcall is preempted, the blocked threads syscall
XXX return value can get lost
2003-10-29 18:53:34 +00:00
lukem f85d2d1c14 Use ${HOST_SH} instead of `sh'.
If necessary, pull in <bsd.sys.mk> to get the definition of HOST_SH;
Makefiles that pull in one of (most of) <bsd.*.mk> will get this anyway.
2003-10-26 07:25:33 +00:00
yamt 2016949b00 update a comment. 2003-10-24 17:35:22 +00:00
fvdl c2405107f1 Correct and simplify computing the return point; just use PC-relative
addressing.
2003-10-20 14:50:18 +00:00
fvdl b30e737545 Make sure the stack stays aligned. 2003-10-19 21:45:03 +00:00
yamt 5cd18e71cc in pthread__deliver_signal(),
copy siginfo_t into the stack of the target thread
rather than relying on the luck that on-stack siginfo_t stay valid.
2003-10-16 13:38:28 +00:00
chs f58c80fc8f fix typo in previous. 2003-10-12 00:25:25 +00:00
wiz 37ac1db454 available, not avaliable. From miod@openbsd. 2003-09-29 09:50:21 +00:00
nathanw 9839173881 Don't include <machine/lock.h> anymore; instead, we now get
__cpu_simple_lock_t and __SIMPLELOCK_{UN,}LOCKED from <sys/types.h>.
Should prevent the massive namespace pollution by way of dragging in
many MD headers that has been observed to break stuff.
2003-09-26 22:48:23 +00:00
cl bfa716044e SA_SIGINFO support for m68k (libpthread) 2003-09-22 14:45:48 +00:00
cl c6de69ee49 fix pt_trapuc handling errors:
- movl to address register doesn't set flags (add explicit test)
- clr only clears a word (use clrl)
2003-09-17 20:08:07 +00:00
cl 5c40d56471 fix SA/pthread pagefault failure:
- prevent BLOCKED upcalls on double page faults and during upcalls
- make libpthread handle blocked threads which hold locks
- prevent UNBLOCKED upcalls from overtaking their BLOCKED upcall
this adds a new syscall sa_unblockyield
see also http://mail-index.netbsd.org/tech-kern/2003/09/15/0020.html
2003-09-16 13:51:31 +00:00
christos 86d645082f fix syntax; thanks aymeric 2003-09-13 17:19:55 +00:00
christos d1bb4290e8 explicitly use a sigset_t * variable to recover the signal mask pointer. 2003-09-13 15:26:38 +00:00
drochner 45a9abb6af make it compile with PTHREAD_SIG_DEBUG again 2003-09-12 15:31:00 +00:00
kleink 8742dcef75 Fix pasto in previous. 2003-09-12 10:10:39 +00:00
christos 138df80b74 convert to use siginfo/ucontext style of signal delivery instead of
sigcontext. Approved by nathanw.
2003-09-12 00:37:17 +00:00
christos 338cc5f663 sprinkle ARGSUSED for good cheer. 2003-09-11 21:51:57 +00:00
cl 89d0cfd21f Remove possible race condition in upcall recycling. 2003-09-07 14:47:44 +00:00
uwe b5623b232f Use delay slot in STACK_SWITCH (catching up with sparc64 changes). 2003-09-07 02:08:31 +00:00
uwe 7d522ba08b Use correct context to switch to.
From sparc64 fix by Andrey Petrov <petrov@netbsd>.
2003-09-07 01:54:47 +00:00
petrov 0d472e116b typo in previous commit, annul isn't good there,
noticed by Eduardo Horvath.
2003-08-26 17:50:06 +00:00
petrov 2cae323122 Use branch-slot in STACK_SWITCH, suggested by Martin Husemann. 2003-08-25 23:00:23 +00:00
petrov c139cd4893 Use correct context to switch to. 2003-08-25 22:48:24 +00:00
ragge 644236bf71 Add PT_TRAPUC and pthread__switch_return_point.
Not tested (as most of the pthread stuff on vax) but at least
allow the system to compile.
2003-08-25 20:32:13 +00:00
nathanw e1fb9dd8e8 In pthread__deliver_signal(), correctly use pt_trapuc or pt_uc as the
context-to-restore instead of always using pt_uc.

Fixes a problem with signal handlers for synchronous signals noted by
Matthias Drochner on current-users.
2003-08-22 17:35:52 +00:00
martin 88055fbde5 Include <stdlib.h> for exit() prototype. 2003-08-20 09:50:16 +00:00
nathanw bd9a18b79f Split out pthread_{set,get}specific() into a separate file and arrange
for that file to not be built with profiling. This makes it reasonable to
use pthread_{set,get}specific() to implement thread-safe profiline call counts.
2003-08-13 18:52:01 +00:00
scw 46fc66f7d8 Adapt to Nathan's recent pt_trapuc/pt_sleepuc change. 2003-08-12 14:01:08 +00:00
agc eb7c1594f1 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22280, verified by myself.
2003-08-07 16:42:00 +00:00
lukem a93ea220fc Rework how dependency generation is performed:
* DPSRCS contains extra dependencies, but is _NOT_ added to CLEANFILES.
  This is a change of behaviour.  If a Makefile wants the clean semantics
  it must specifically append to CLEANFILES.
  Resolves PR toolchain/5204.

* To recap: .d (depend) files are generated for all files in SRCS and DPSRCS
  that have a suffix of: .c .m .s .S .C .cc .cpp .cxx

* If YHEADER is set, automatically add the .y->.h to DPSRCS & CLEANFILES

* Ensure that ${OBJS} ${POBJS} ${LOBJS} ${SOBJS} *.d  depend upon ${DPSRCS}

* Deprecate the (short lived) DEPENDSRCS


Update the various Makefiles to these new semantics; generally either
adding to CLEANFILES (because DPSRCS doesn't do that anymore), or replacing
specific .o dependencies with DPSRCS entries.

Tested with "make -j 8 distribution" and "make distribution".
2003-08-01 17:03:41 +00:00
kleink 7d3a44f705 Remove PT_SLEEPUC, which somehow wasn't. 2003-07-29 15:18:49 +00:00
salo 99410184e7 netbsd.org->NetBSD.org 2003-07-26 19:24:24 +00:00
mrg 9759912dd6 need <string.h> 2003-07-26 18:33:06 +00:00
skrll 795970599f Typo in comment. 2003-07-24 08:03:44 +00:00
wiz 576530e520 Add pthread(3), based on one by Hubert Feyrer, improved by yours truly,
reviewed by Nathan J. Williams.
2003-07-24 07:50:24 +00:00
nathanw 0878df5d25 Lock accesses to pt_flags and pt_cancel.
When disabling cancellation, clear the pt_cancel flag if it was set
and note the cancellation request with PT_FLAG_CS_PENDING. This avoids
a problem where a cancellation request entered but not acted upon before
pthread_setcanclstate(PTHREAD_CANCEL_DISABLE) is called would still be
aceted upon before cancellation was re-enabled.
2003-07-21 22:24:09 +00:00
nathanw 329747fb90 Add a lock on the pt_flags field. 2003-07-21 22:21:07 +00:00
nathanw 0c96790183 Use _sys_write() instead of write() in the assertion and error
functions, to avoid invoking the cancellation machinery in the middle
of trying to print an assertion or error message.
2003-07-21 22:17:14 +00:00
nathanw 68a63a4079 Move initialization of variable 'nthreads' so that pthread_exit() from
the main thread, with no other threads created, exits cleanly instead
of triggering an assertion in pthread_next().
2003-07-21 22:14:57 +00:00
nathanw ec2c169839 pthread.c was getting a bit unwieldly. Move pthread_attr stuff out
into a new file, and put the shared private structure definition in
pthread_int.h.
2003-07-18 22:33:45 +00:00
nathanw 0172694e7d Implement a bunch of pthread_attr_() functions, which genuinely set and examine
pthread_attr_t objects, although most of the properties being set don't really
affect threads yet:

pthread_attr_{get,set}guardsize()
pthread_attr_{get,set}inheritsched()
pthread_attr_{get,set}scope()
pthread_attr_{get,set}stack()
pthread_attr_setstack{size,addr}()

Remove some useless assertions and error checks in the existing pthread_attr()
routines.

Implement pthread_attr_get_np(), to examine the attributes of an existing
thread. Idea and interface from FreeBSD.

Change PTHREAD_ERRORMODE environment variable to PTHREAD_DIAGASSERT, and
make it behave like libc's LIBC_DIAGASSERT. The way to disable error-checking
and aborting is now "PTHREAD_DIAGASSERT=AEL", rather than
"PTHREAD_ERRORMODE=ignore".
2003-07-18 22:12:30 +00:00
nathanw 067fa34e42 Add prototypes and necessary symbols for a bunch of pthread_attr_*() functions,
including (interface borrowed from FreeBSD) pthread_attr_get_np().

Remove a few limit-indicating symbols that don't actually need to be defined
(and if they did need to be defined, it would be in limits.h, not here).
2003-07-18 22:01:47 +00:00
nathanw 9e5c87057d Add strong alias for setcancelstate. 2003-07-18 21:57:26 +00:00
lukem 98e8a6d142 #include <pthread_types.h> instead of "pthread_types.h" 2003-07-18 15:58:43 +00:00
nathanw 1a9edd35f7 Simplify pthread__stackalloc() by using the newish aligned-mmap()
feature.
2003-07-17 21:07:39 +00:00
nathanw d686fc0deb Define PTHREAD_* structure initializers from _PTHREAD_* macros from
pthread_types.h.
2003-07-17 20:59:35 +00:00
nathanw d37a996a49 Adapt to structure name changes. 2003-07-17 20:55:25 +00:00
nathanw deb18e9d04 Adapt to internal structure name changes.
Add a couple of useful flags and symbols.
2003-07-17 20:52:38 +00:00
nathanw c541f9e56a Prepare for inclusion in sys/types.h by ensuring that all the symbols
defined end with _t or start with _[A-Z_].
2003-07-17 20:51:36 +00:00
nathanw 608b92c095 Don't use PTHREAD_DESTRUCTOR_ITERATIONS; the constant is going away. 2003-07-17 20:40:43 +00:00
fvdl 2949ab0051 Take the normal return path in sigtimedwait when the current thread was
canceled as well. From Stephan Uphoff.
2003-07-17 18:15:21 +00:00
nathanw e171479839 pthread_kill() prototype moved to <signal.h>. 2003-07-16 21:26:33 +00:00
matt 0f8d87a96d Update to new world order. **not tested** But will allow builds to
finish.
2003-07-09 00:55:45 +00:00
uwe ea81adf86a Not that the branch in SETC doens't have a delay slot, remove the
.empty comment as it's no longer pertinent.
2003-07-05 23:01:25 +00:00
marcus 4e24351384 PIC patch from Valeriy E. Ushakov applied.
Also, removed bogus delay slot flag from branch instruction.
2003-07-05 22:50:09 +00:00
marcus cccf9dfce5 The field "pt_sleepuc" doesn't exist in struct pthread_st. 2003-07-05 21:27:23 +00:00
skrll ec57ccf92d Typos in comments. 2003-07-04 15:16:14 +00:00
wiz cf10d78423 Remove superfluous word. 2003-07-04 11:59:34 +00:00
wiz 3261c36039 Add comma. 2003-07-04 11:57:58 +00:00
wiz c9b0edd1ba Remove superfluous word. 2003-07-04 11:57:17 +00:00
wiz df617ae85c Fix typo. 2003-07-04 11:55:58 +00:00
wiz 9edf05479a Mark up a defined value. 2003-07-04 11:47:03 +00:00
wiz 63e8a90e85 New sentence, new line. 2003-07-04 10:19:42 +00:00
wiz 7398828105 Fix typo. 2003-07-04 10:18:46 +00:00
wiz 1e15cda14b > -> \*[Gt] 2003-07-04 08:43:33 +00:00
wiz 5b1fed0bc5 Sort sections. 2003-07-04 08:42:57 +00:00
wiz f84167245a .Pp fixes. 2003-07-04 08:42:20 +00:00
wiz 2f56847e01 Fix SEE ALSO. 2003-07-04 08:41:25 +00:00
wiz ba587118af Drop trailing whitespace. 2003-07-04 08:36:06 +00:00
wiz 7dd0ed6e01 We do not want empty lines in mdoc. 2003-07-01 10:23:52 +00:00
wiz 5231f1f288 Remove trailing whitespace. 2003-06-26 10:01:18 +00:00
nathanw 9639eeaf54 Adapt to pt_trapuc: change STACK_SWITCH to check for a value in pt_trapuc
and use it preferentially to a value in pt_uc, clearing it once on the new
stack. Move stores into pt_uc back to before the stack switch; storing
after the stack switch opened a one-instruction race condition where an upcall
that had just started a chain could be preempted again, and would bomb when
restarted due to its pt_uc not yet having been updated. Now that pt_trapuc
is what the upcall code writes to, it is safe to store to pt_uc before
switching stacks.

Remove obsolete pt_sleepuc code.
2003-06-26 01:45:31 +00:00
nathanw 487eb7e193 Initialize pt_trapuc in pthread__initthread(). 2003-06-26 01:30:39 +00:00
nathanw 1414a095ac Remove PT_SLEEPUC and add PT_TRAPUC. 2003-06-26 01:29:28 +00:00
nathanw 81a27fd0b2 Adapt to pt_trapuc: Store context obtained from upcalls there, clear it
in switchto targets and vitims, and print it in debug messages (including
indication of whether a context is trap or user context).

Remove obsolete pt_sleepuc handling.
2003-06-26 01:28:14 +00:00
nathanw 1af6125572 Clear pt_trapuc when idling threads. 2003-06-26 01:26:39 +00:00
nathanw 2534cd2bea Introduce a new pointer, pt_trapuc, that stores thread context captured
by the kernel. Separating this from pt_uc makes it possible to avoid a race
condition in pt_uc management near the STACK_SWITCH part of pthread__switch()
and pthread__locked_switch().

Remove pt_sleepuc pointer, which was made obsolete by the previous round of
UC juggling but still present in the assembler files.
2003-06-26 01:26:11 +00:00
nathanw 3ca7487c30 More printf format size tweaks. 2003-06-25 23:26:00 +00:00
nathanw 4a9ac109f0 Complain clearly if SA syscalls aren't avaliable. 2003-06-25 23:23:27 +00:00
nathanw 39f9ecfa06 Oops, reordering the PT_STATE/PT_SWITCHTOUC/PT_SWITCHTO assembly
killed a live value too soon. Fix by using a different register for
the PT_STATE immediate.
2003-06-24 18:54:56 +00:00
nathanw 96458e8892 Update the switch_return point name in the static case. 2003-06-23 22:50:23 +00:00
uwe b92f152573 First bits of SH3 support. Only _context_u.S is implemented (passess
cu[1-6] tests), the pthread_switch.S is stubbed out for now.

Code posted by Christian Groessler (cpg at aladdin dot de) to port-sh3.
2003-06-23 19:34:43 +00:00
martin f546abe798 Catch up with Nathan's changes to other archs. 2003-06-17 23:18:48 +00:00
nathanw 876d7e7eec Dodge a potential race condition in pthread__debuglog_printf(). It's
still possible for multiple threads to write into the same space, but
they shouldn't be able to corrupt the write pointer in the process.

Also, check for pointer-lapping a bit more carefully in the wrap
vs. non-wrap case.
2003-06-16 21:24:48 +00:00
martin aba86b525b Catch up with changes Nathan did to other archs. 2003-06-15 17:11:36 +00:00
scw 7d221cb560 Apply Nathan's switch-away fix and previous save-PT_UC from new stack fix. 2003-06-13 08:07:03 +00:00
scw 04f197eae9 Apply Nathan's switch-away fix and previous save-PT_UC from new stack fix.
Compile-tested only.
2003-06-13 07:45:17 +00:00
nathanw 4bd45b7b3b Oops, that's switch_return_point, not locked_return_point. The perils
of cut-and-paste.
2003-06-12 23:19:27 +00:00
nathanw aa6f5de228 STACKSPACE of 16 is too small, given the use of CALLFRAME_SIZ;
increase to match.
2003-06-12 23:01:17 +00:00
nathanw eb6ba6fbef Apply switch-away fix and previous save-PT_UC from new stack fix. 2003-06-12 23:00:28 +00:00
fvdl 1a31b8db4d Apply Nathan's switch-away fix. 2003-06-12 22:03:18 +00:00