Commit Graph

254 Commits

Author SHA1 Message Date
Jason Evans
f3ee83c3bf The second call to _thread_kern_sig_defer() in sem_post() should be a call
to _thread_kern_sig_undefer().
2000-08-23 07:59:50 +00:00
Alfred Perlstein
022daa34f2 Fix an off-by-one error in the recursive mutex handling that made it
prematurely release recursive mutexes.

Test case provided by: Bradley T. Hughes <bhughes@trolltech.com>
Reviewed by: deischen
2000-08-13 01:30:36 +00:00
Jason Evans
f8842c0a18 kevent() is not a POSIX cancellation point, so _kevent() need not be
defined.

Remove some unnecessary header file inclusions.
2000-08-08 00:12:35 +00:00
Jonathan Lemon
532c92a865 Add wrapper for kevent() syscall
Noted as missing by: nicolas.leonard@animaths.com
2000-08-07 16:51:56 +00:00
Jason Evans
b167c9a5c1 Make sem_post() safe to call from within a signal handler, as required by
POSIX/SUSv2.
2000-08-01 21:19:09 +00:00
Doug Rabson
678ef1b49e Call _thread_init() from pthread_once() if it has not already been called.
This fixes a segfault in some C++ programs which use exceptions before
main() has been called (i.e. from global constructors).

Reviewed by: deischen
2000-07-21 09:31:13 +00:00
Jason Evans
c1110eb673 pthread_once --> pthread_once_t. 2000-07-19 16:38:07 +00:00
Jason Evans
8e234adf86 Change my email address in the copyright notices for the sake of consistency
(jasone@canonware.com --> jasone@freebsd.org).
2000-07-18 01:38:19 +00:00
Jason Evans
390a1cd5eb Deal correctly with statically initialized condition variables in
pthread_cond_signal(), pthread_cond_broadcast(), and pthread_cond_timedwait().

Do not dump core in pthread_cond_timedwait() (due to a NULL pointer
dereference) if attempting to wait on an uninitialized condition variable.

PR:	bin/18099
2000-07-17 22:55:05 +00:00
Jason Evans
82db3da3e1 Reshuffle the SEE ALSO section.
Prompted by:	sheldonh
2000-07-17 22:33:32 +00:00
Jason Evans
e21fa6847e Remove DEBUG_FLAGS=-g3, which never should have been committed. 2000-07-05 16:21:42 +00:00
Jason Evans
b79702feff Fix typo in SEE ALSO section. 2000-06-28 03:15:21 +00:00
Jason Evans
8d107d1210 If multiple threads are blocked in sigwait() for the same signal that does
not have a user-supplied signal handler, when a signal is delivered, one
thread will receive the signal, and then the code reverts to having no
signal handler for the signal.  This can leave the other sigwait()ing
threads stranded permanently if the signal is later ignored, or can result
in process termination when the process should have delivered the signal to
one of the threads in sigwait().

To fix this problem, maintain a count of sigwait()ers for each signal that
has no default signal handler.  Use the count to correctly install/uninstall
dummy signal handlers.

Reviewed by:	deischen
2000-06-27 21:30:16 +00:00
Jason Evans
314be1347b pthread_mutex_lock(), pthread_cond_trywait(), and pthread_cond_wait() are
not allowed to return EINTR, but use of pthread_suspend_np() could cause
EINTR to be returned.  To fix this, restructure pthread_suspend_np() so that
it does not interrupt a thread that is waiting on a mutex or condition, and
keep enough state around that pthread_resume_np() can fix things up
afterwards.

Reviewed by:	deischen
2000-06-14 17:17:41 +00:00
Chris Costello
d2e7a6a46f Fix a misspelling: undefied -> undefined 2000-05-27 22:02:32 +00:00
Jake Burkholder
e39756439c Back out the previous change to the queue(3) interface.
It was not discussed and should probably not happen.

Requested by:		msmith and others
2000-05-26 02:09:24 +00:00
Jake Burkholder
740a1973a6 Change the way that the queue(3) structures are declared; don't assume that
the type argument to *_HEAD and *_ENTRY is a struct.

Suggested by:	phk
Reviewed by:	phk
Approved by:	mdodd
2000-05-23 20:41:01 +00:00
Jason Evans
ccb3a748f4 Fix a memory leak. pthread_set_name_np() allocates space for a name, but
was not deallocating space for the previous name, if any.

PR:	misc/18504
2000-05-16 22:08:14 +00:00
Jason Evans
40316fa981 Fix a memory leak. pthread_set_name_np() allocates space for a name, but
_thread_gc() was not deallocating it.

PR:	misc/18504
2000-05-16 21:57:12 +00:00
Alexey Zelkin
0543309637 add MLINKS: pthread_testcancel(3) -> pthread_setcanceltype(3) 2000-05-12 09:59:44 +00:00
Bruce Evans
27010737a9 "Fixed" missing include in synopsis. POSIX.1-1996 only specifies
including <signal.h>, but that must be a bug in POSIX.1, because it
also specifies that the relevant prototype is [only] in <pthread.h>.
2000-05-11 16:13:18 +00:00
Bruce Evans
ce8973f06a Fixed misspelling of a struct tag in a function parameter type. 2000-05-11 16:03:38 +00:00
Bruce Evans
80a07932e7 Fixed missing consts for function parameters, so that the code matches
the man page and POSIX.1.  Fixed nearby misformatting.  Fixed a missing
prototype.
2000-05-11 15:57:17 +00:00
Sheldon Hearn
f167d7fb3e Fix miscellaneous mdoc macro argument limit infringements.
PR:		18465
Reported by:	Kazu TAKAMUNE <takamune@avrl.mei.co.jp>
2000-05-09 14:02:06 +00:00
Alexey Zelkin
2a53c5ec96 mdoc(7) cleanup:
. use real function names as `.Nm' macro argument in NAME section. It allows
them to appear in apropos(1) or whatis(1) output.

. replace empty lines with `.Pp' macro.

. replace hardcoded standard names with their `.St' macro equivalents.

. sort cross references in SEE ALSO section
2000-05-04 08:05:45 +00:00
Jason Evans
97f2978aa0 Add missing .El macro. 2000-05-03 08:50:43 +00:00
Jason Evans
4c089f4dff Add missing man pages. Fix various compliance bugs, mostly having to do with
error return values.  Implement pthread_mutexattr_gettype().

PR:		docs/16537, docs/17538
2000-05-02 06:51:40 +00:00
Jason Evans
98a1f447bb Add a wrapper for the sendfile() system call.
PR:		bin/17366
2000-04-27 00:59:44 +00:00
Jason Evans
e419521997 Add test to detect propagation of cancellation points within libc_r. 2000-04-26 23:25:58 +00:00
Jason Evans
be1d533999 Automated regression test harness for libc_r. Existing tests are integrated,
a new test for POSIX semaphores was added, and examples of harness usage are
included.
2000-04-24 21:07:45 +00:00
Alexey Zelkin
d8a7868820 Introduce .Lb macro to libc_r manpages. 2000-04-22 15:50:29 +00:00
Jason Evans
7e5e179982 Explicitly include sys/cdefs.h to get the definition of __strong_reference(),
rather than getting lucky due to header dependencies.
2000-03-18 22:36:46 +00:00
Daniel Eischen
1d013a86ed Fix pthread_suspend_np/pthread_resume_np. For the record, suspending a
thread waiting on an event (I/O, condvar, etc) will, when resumed using
pthread_resume_np, return with EINTR.  For example, suspending and resuming
a thread blocked on read() will not requeue the thread for the read, but
will return -1 with errno = EINTR.  If the suspended thread is in a critical
region, the thread is suspended as soon as it leaves the critical region.

Fix a bogon in pthread_kill() where a signal was being delivered twice
to threads waiting in sigwait().

Reported by (suspend/resume bug):	jdp
Reviewed by:	jasone
2000-03-15 13:59:27 +00:00
Sheldon Hearn
c6ff3a1bf7 Remove single-space hard sentence breaks. These degrade the quality
of the typeset output, tend to make diffs harder to read and provide
bad examples for new-comers to mdoc.
2000-03-02 09:14:21 +00:00
Ruslan Ermilov
a02c8fe575 Fix the installworld breakage from rev 1.9.
Submitted by:	reg
Reviewed by:	ru
Approved by:	jasone (rev 1.9)
Pointy hat to:	unfurl
2000-02-18 13:21:16 +00:00
Bill Swingle
9969b45007 fixed missing trailing \
Submitted by:	Thimble Smith <tim@mysql.com>
2000-02-18 05:31:26 +00:00
Bill Swingle
30fd3a5b2b Adds missing symlinks for pthread related manpages.
PR:		16537
Submitted by:	AnarCat <beaupran@iro.umontreal.ca>
Approved by:	jasone
2000-02-18 02:26:27 +00:00
Jason Evans
8a668b9049 For errors, return -1 and set errno to indicate the error type, rather than
returning the error directly.

For sem_post(), make sure that the correct thread is woken up.  This has
unfortunate performance implications, but is necessary for POSIX compliance.

Approved by:	jkh
2000-02-16 19:34:53 +00:00
Jason Evans
b0a1b4f809 Add man pages for the sem_*() functions.
Approved by:	jkh
2000-02-16 19:31:53 +00:00
Jason Evans
d77639f25f Use __strong_reference() instead of __weak_reference() to assure that the
weak symbols of the same name are not used.
2000-01-29 22:53:55 +00:00
Jason Evans
4ec6f67d10 Use _fcntl() (not fcntl()) inside of fcntl().
Reported by:	green
2000-01-28 22:10:27 +00:00
Jason Evans
9233c4d942 Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(),
just use _foo() <-- foo().  In the case of a libpthread that doesn't do
call conversion (such as linuxthreads and our upcoming libpthread), this
is adequate.  In the case of libc_r, we still need three names, which are
now _thread_sys_foo() <-- _foo() <-- foo().

Convert all internal libc usage of: aio_suspend(), close(), fsync(), msync(),
nanosleep(), open(), fcntl(), read(), and write() to _foo() instead of foo().

Remove all internal libc usage of: creat(), pause(), sleep(), system(),
tcdrain(), wait(), and waitpid().

Make thread cancellation fully POSIX-compliant.

Suggested by:	deischen
2000-01-27 23:07:25 +00:00
Jason Evans
0c5d1a3361 Fix millisecond to nanosecond conversion.
PR:		misc/16245
2000-01-22 09:15:15 +00:00
Jason Evans
beab1ec9b5 Minor *jmp() cleanups. 2000-01-20 21:53:59 +00:00
Jason Evans
120bfc9ded Add sem_*() functions. Named semaphores and process-shared semaphores
are not supported by this implementation, and the error return values
from sem_init(), sem_open(), sem_close(), and sem_unlink() reflect this.

Approved by:	jkh
2000-01-20 07:54:49 +00:00
Jason Evans
adbd6ee028 Do signal deferral for pthread_kill() as it was done in the old days.
Submitted by:	deischen
2000-01-20 04:46:52 +00:00
Jason Evans
0a3fa43c7e Implement continuations to correctly handle [sig|_]longjmp() inside of a
signal handler.  Explicitly check for jumps to anywhere other than the
current stack, since such jumps are undefined according to POSIX.

While we're at it, convert thread cancellation to use continuations, since
it's cleaner than the original cancellation code.

Avoid delivering a signal to a thread twice.  This was a pre-existing bug,
but was likely unexposed until these other changes were made.

Defer signals generated by pthread_kill() so that they can be delivered on
the appropriate stack.  deischen claims that this is unnecessary, which is
likely true, but without this change, pthread_kill() can cause undefined
priority queue states and/or PANICs in [sig|_]longjmp(), so I'm leaving
this in for now.  To compile this code out and exercise the bug, define
the _NO_UNDISPATCH cpp macro.  Defining _PTHREADS_INVARIANTS as well will
cause earlier crashes.

PR:			kern/14685
Collaboration with:	deischen
2000-01-19 07:04:50 +00:00
Daniel Eischen
7e416d8e49 Properly initialize the last active time of the initial thread. This fixes
the case that a CPU hungry main thread is prevented from being preempted
due to a negative calculation of its time slice.

Reported by:	Alexander Litvin <archer@lucky.net>
2000-01-18 11:35:25 +00:00
Jason Evans
f560c4e709 Track libc's three-tier symbol naming. libc_r must currently implement
the _libc_*() entry points and add *() weak aliases.  This will all
change for the better when libc_r becomes libpthread.
2000-01-12 09:28:58 +00:00
Daniel Eischen
3eadb69d1f Make sched_param parameter a const to comply with POSIX and SUSv2 specs.
This doesn't need to be applied to stable, because somehow -stable seems
to have gotten it right.

Reviewed by:	jasone
2000-01-10 04:14:08 +00:00