Commit Graph

86 Commits

Author SHA1 Message Date
jb
d9ca3f69e6 Add a warning message for a thread locking against itself. This is
not supposed to happen, but I have seen bogus g++ code that causes
it.
1998-06-06 07:27:06 +00:00
jb
fa1af3c55b Simplify the handling of thread specific data. Only track if a key
is allocated or not, rather than keeping a count and attempting to
know it it is in-use. POSIX says that once a key is deleted, using the
key again results in undefined behaviour.
1998-06-06 07:24:24 +00:00
jb
0e04174c22 Re-design the thread specific key structure. 1998-06-06 07:20:23 +00:00
jb
14d31aca92 I got the last commit back to front. 1998-06-06 07:02:27 +00:00
jb
231ebf2d6f Fix the signal behaviour for internal states which set the thread
state to running despite the SA_RESTART flag which is really just for
syscalls.
1998-06-05 23:31:55 +00:00
jb
40735bd785 I shouldn't do things early in the morning.
I shouldn't do things early in the morning.
[...]
I shouldn't do things early in the morning.
1998-06-01 02:14:34 +00:00
jb
1a599891ae send and recv are wrappered in libc, so they shouldn't appear here. 1998-06-01 02:12:15 +00:00
jb
205e447fcb Remove some syscalls that should have been renamed (libc_r doesn't need
to wrapper them) and add a couple that should have been there.
1998-05-31 23:53:50 +00:00
jb
4e33c259ce Add some missing syscall wrappers. 1998-05-31 23:48:30 +00:00
jb
d1ff6ac118 Remove some stale code.
Pointed out by: Amancio
1998-05-31 23:47:06 +00:00
jb
c471a4b5e0 Don't restart a syscall when a SIGCHLD is received by a thread waiting
on a child process.
1998-05-31 23:46:01 +00:00
jb
11a0d9cda5 Make a copy of the caller's iovec array, mallocing if necessary,
and modify that if the writev() syscall does not completely write
all bytes in a single call.
1998-05-27 00:44:58 +00:00
jb
f5689a7c8a Remove error check from call to set the file descriptor to non-blocking
instead of explicitly ignoring some errors. This allows for the case
where a device is naturally non-blocking.
1998-05-27 00:41:22 +00:00
jb
ba8f020407 When doing a blocking write, keep looping until all the bytes are
written without returning to the caller. This only occurs on pipes
where either the number of bytes written is greater than the pipe
buffer or if there is insufficient space in the pipe buffer because the
reader is reading slower than the writer is writing.
1998-05-25 21:45:52 +00:00
jb
0dd6c91639 Treat the lock value as volatile. 1998-05-05 21:47:58 +00:00
jraynard
0db69331c5 Typo fixes 1998-05-03 22:59:47 +00:00
jb
0bb53ecc6b Cleanup in the child, not the parent.
Submitted by: Tor Egge <Tor.Egge@idi.ntnu.no>
1998-05-02 03:42:20 +00:00
jb
ab20b86639 Fix the incremental priority increment.
PR: bin/6467 Marino Ladavac <lada@pc8811.gud.siemens.at>
1998-04-30 21:50:29 +00:00
jb
0b5bef5fb7 Change the name of this source file so that libc_r builds it instead
of the one in libc that contains the weak symbol for __error. FreeBSD's
make accumulates paths to the point that it can find *anything*, possibly
including the car keys.
1998-04-30 09:04:10 +00:00
jb
338768eab3 Add spinlock. 1998-04-29 11:03:34 +00:00
jb
6c9ee23acc Change signal model to match POSIX (i.e. one set of signal handlers
for the process, not a separate set for each thread). By default, the
process now only has signal handlers installed for SIGVTALRM, SIGINFO
and SIGCHLD. The thread kernel signal handler is installed for other
signals on demand. This means that SIG_IGN and SIG_DFL processing is now
left to the kernel, not the thread kernel.

Change the signal dispatch to no longer use a signal thread, and
call the signal handler using the stack of the thread that has the
signal pending.

Change the atomic lock method to use test-and-set asm code with
a yield if blocked. This introduces separate locks for each type
of object instead of blocking signals to prevent a context
switch. It was this blocking of signals that caused the performance
degradation the people have noted.

This is a *big* change!
1998-04-29 09:59:34 +00:00
jb
9bbe93edfa Don't need wrappers for longjmp/setjmp anymore. 1998-04-29 09:40:51 +00:00
jb
ba3f8d4e2e Remove empty files that were renamed some time ago. 1998-04-29 09:39:34 +00:00
jb
f7b2be7722 Atomic lock source. 1998-04-29 09:36:03 +00:00
jb
10e0c9e2e7 Allow a thread dump to report the thread's sigmask when in the
PS_SIGWAIT state.
1998-04-17 09:39:37 +00:00
jb
2b906f181a When in PS_SIGWAIT state, still call signal handlers and set errno
to EINTR.
1998-04-17 09:37:41 +00:00
jb
19185ac512 Change the FILE locking to be by FILE, not by the underlying fd as
it was. Add a FILE_WAIT state and queue threads waiting for a FILE
lock. Start using the sys/queue.h macros instead of the way that MIT
pthreads did it.

Add a thread name to the private thread structure and a non-POSIX
function to set this. This helps (me at least) when sending a SIGINFO
to a threaded process to get a /tmp/uthread.dump to see what the
<expletive deleted> threads are doing this time. It is nice to be
able to recognise (yes, I spell that with an 's' too) which threads
are which.
1998-04-11 07:47:22 +00:00
jb
ddcbf85eb2 Enable static initialisation of mutexes and condition variables. 1998-04-04 11:33:01 +00:00
jb
c34d8f0bcb Rename static initializer defines for opaque structures so that the
POSIX specified names can be declared in pthread.h.
1998-04-04 10:58:12 +00:00
jb
fc00c3e358 Move the magic field initialisation to a place when it is more magic. 1998-04-04 07:27:29 +00:00
jb
6a1d5a1659 Add a magic field to the pthread structure to help recognize valid
threads from invalid ones. The pthread structure is opaque to the user
so this change does not cause any incompatibilities.

Hopefully this change will help code that was written for draft 4
fail gracefully if the programmer ignores the compiler warning about
the change in the level of indirection for the argument passed to
pthread_detach(). I got burnt, so I fixed then (expletive deleted)
thing.

These functions comply with the revised standard. That should shut
Terry up!
1998-04-03 09:31:15 +00:00
jb
a6ff3fe2e9 This function compiles with the standard, so say so. 1998-04-03 09:12:19 +00:00
jb
449d1d74af This function compiles with the standard, so say so.
Add a note about not touching errno and warn about previous drafts
of the standard which changed the level of indirection to the thread
argument. POSIX had a bit of trouble deciding what to do. So anyone
coding to both draft 4 and draft 10 (the final draft) will get burnt
by this function. I did. Grrr.
1998-04-03 09:11:15 +00:00
dufault
8ed0defc6e Finish _POSIX_PRIORITY_SCHEDULING. Needs P1003_1B and
_KPOSIX_PRIORITY_SCHEDULING options to work.  Changes:

Change all "posix4" to "p1003_1b".  Misnamed files are left
as "posix4" until I'm told if I can simply delete them and add
new ones;

Add _POSIX_PRIORITY_SCHEDULING system calls for FreeBSD and Linux;

Add man pages for _POSIX_PRIORITY_SCHEDULING system calls;

Add options to LINT;

Minor fixes to P1003_1B code during testing.
1998-03-28 11:51:01 +00:00
bde
ad583a7187 Fixed a function arg type in the synopsis. 1998-03-23 13:07:17 +00:00
jb
e8b6792d29 Fix a problem of indirection unblocking signals that would have caused
signals to be unblocked even if they were already blocked when entering
the function.

Pointed out by: bde
1998-03-22 04:13:23 +00:00
jb
aba00ab374 When forking a process, only the running thread gets to live. All
other threads never see the light of day and if they leave things
locked, blame POSIX.
1998-03-09 06:54:50 +00:00
jb
50a31a7bd8 Add lib/libc/include as an directory to search for header files.
Change MACHINE references to MACHINE_ARCH.

Declare the names of the syscalls that need to be renamed to allow
for the functions that libc_r provides replacements for. This list
used to be in lib/libc/sys/Makefile.inc, but has been moved here
to keep that makefile tidy and remove the temptation for people to
add things to the list without adding a libc_r replacement function.
1998-03-09 05:09:43 +00:00
jb
ff740b6b07 Add FreeBSD/Alpha code to initialise a jmpbuf for a created thread.
Change a bunch of __alpha references to __alpha__.
1998-03-09 04:46:26 +00:00
jb
696d96607e Add sched_yield() witch is the draft 10 equivalent of pthread_yield()
from draft 4. Move some of the schedule definitions to sched.h which
is a POSIX header.
1998-03-08 02:37:27 +00:00
julian
b31dde27bf Fixes from Jeremy Allison and Terry Lambert for pthreads:
specifically:
uthread_accept.c: Fix for inherited socket not getting correct entry in
                  pthread flags.
uthread_create.c: Fix to allow pthread_t pointer return to be null if
                  caller doesn't care about return.
uthread_fd.c: Fix for return codes to be placed into correct errno.
uthread_init.c: Changes to make gcc-2.8 thread aware for exception stack
                frames (WARNING: This is #ifdef'ed out by default and is
		different from the Cygnus egcs fix).
uthread_ioctl.c: Fix for blocking/non-blocking ioctl.
uthread_kern.c: Signal handling fixes (only one case left to fix,
                that of an externally sent SIGSEGV and friends -
		a fairly unusual case).
uthread_write.c: Fix for lock of fd - ask for write lock, not read/write.
uthread_writev.c: Fix for lock of fd - ask for write lock, not read/write.

Pthreads now works well enough to run the LDAP and ACAPD(with the gcc 2.8 fix)
sample implementations.
1998-02-13 01:27:34 +00:00
julian
5b999ea00c slight cleanup in handling sockets and file descriptors.
Same fix already applied to other types of fds. This one was apparently missed.
1998-02-05 21:16:52 +00:00
alex
370393763b Changed pthread_detach to conform to POSIX, i.e. the single argument
provided is of type pthread_t instead of pthread_t *.

PR:		4320

Return EINVAL instead of ESRCH if attempting to detach an already
detached thread.
1997-12-25 05:07:20 +00:00
alex
2d792e656e Modify the return values to comply with POSIX. Previously these
functions would return -1 and set errno to indicate the specific error.
POSIX requires that the functions return the error code as the return
value of the function instead.
1997-11-25 01:29:16 +00:00
alex
674aa81547 Added missing source file uthread_sigwait.c.
Submitted by:	Daniel M. Eischen <deischen@iworks.InterWorks.org>
1997-11-24 23:04:29 +00:00
alex
b0aecb1c1e Correct the return value from pthread_cond_timedwait when a timeout
occurs (was EAGAIN, is now ETIMEDOUT).

Submitted by:	Daniel M. Eischen <deischen@iworks.InterWorks.org>
1997-11-23 22:58:26 +00:00
jb
013b17e93c Bring back nanosleep from the cold.
The addition of the nanosleep syscall was correctly added to
libc/sys/Makefile so that it is renamed as _thread_sys_nanosleep().
This syscall is one of those that libc_r has to re-implement because
the only behaviour is to block the process. So libc_r just ignores the
fact that a nanosleep syscall exists and goes its own way - as it has
done all along .... and now it does again. And now a simple program
can sleep again. Phew.
1997-06-04 13:03:12 +00:00
alex
045a1cc0a4 Fixed overallocation of _thread_fd_table.
PR:		3494
Submitted by:	Steve Bauer <sbauer@rock.sdsmt.edu>
1997-05-13 23:54:22 +00:00
peter
b73ae73c5f Add const in the thread version of nanosleep()'s args 1997-05-12 10:02:18 +00:00
peter
4956656241 remove prototype for nanosleep(), it's visible in unistd.h now. 1997-05-12 10:00:46 +00:00