Commit Graph

109 Commits

Author SHA1 Message Date
Alexander Langer 8ac3b85e63 The pthreads standard has been published. Change:
...is expected to conform to IEEE (``POSIX'') Std 1003.1c when it is
   published.
to:
   ...conforms to ISO/IEC 9945-1 ANSI/IEEE (``POSIX'') Std 1003.1 Second
   Edition 1996-07-12.

Discussed with:	jb
1998-08-03 00:58:37 +00:00
Alexander Langer b4ff1b7295 A style fix for my previous commit. 1998-08-02 23:07:25 +00:00
Alexander Langer 27aa2e8958 Fixed a race condition during the first lock/trylock of a statically
initialized mutex.  Statically initialized mutexes are actually
initialized at first use (pthread_mutex_lock/pthread_mutex_trylock).
To prevent concurrent initialization by multiple threads, all
static initializations are now serialized by a spinlock.

Reviewed by:	jb
1998-08-02 17:04:25 +00:00
Poul-Henning Kamp 1fbdc08dfe I've put together man pages for the pthread_cleanup, pthread_cond, and
pthread_mutex routines. I've also tweaked pthread_create.3 to point to
pthread_cleanup_push(3) and pthread_cleanup_pop(3).

PR:		7450
Submitted by:	Brian Cully <shmit@kublai.com>
1998-07-31 09:09:19 +00:00
Bruce Evans bcc58f6898 Fixed a printf format error. Didn't fix assumption that sigset_t is
integral.
1998-06-30 18:00:11 +00:00
John Birrell ff09ba5fbb Add the missing {} that caused the function to return ESRCH if it
had to wait for the thread to exit and if the caller didn't want the
thread exit status.
1998-06-25 00:04:21 +00:00
John Birrell b9148b8a3e Don't allow a SIGCHLD to wake up a thread if the process has the default
signal handler installed for SIGCHLD. The ACE MT_SOCK_Test was hanging
as the result of being interrupted when it didn't expect to be.
1998-06-17 22:29:12 +00:00
John Birrell d989fc8faa If a thread is waiting on a child process to complete, the SIGCHLD
signal can arrive before the thread is woken from it's wait4. In this
case, don't return an EINTR, just set the thread state to running and
the wait4 wrapper will loop and get the exit status of the process.
1998-06-17 03:53:16 +00:00
Peter Wemm 02a93d74e0 Don't compile in the use of poll() when building libc_r. This isn't
so much a "fix", rather a bandaid to buy time to fix it properly
within the thread engine.
1998-06-14 11:25:46 +00:00
John Birrell 597035b4db If a short write, only loop if no error. 1998-06-14 09:36:14 +00:00
John Birrell 0b99d9d8ac Add poll to the list of hidden syscalls so that it gets renamed. This
propagates a bug (that there is no poll wrapper in libc_r), but it
prevents GNU configure scripts from trying to use it in preference
to select. libc_r really needs to change it's wait interface to use
poll instead of select because poll is more a superset of select that
the other way around.

This should allow the Roxen web server to work out-of-the-box. It's
configuration intercae is kinda neat. The code isn't. Shiver. 8-)
1998-06-12 02:21:27 +00:00
John Birrell 06ca87e9f7 Update the caller's descriptor masks even if there are none ready for
I/O for those applications that don't believe the return value of zero as
meaning that THERE ARE *NO* DESCRIPTORS READY.
1998-06-12 02:17:18 +00:00
John Birrell 8eb25828ad Check the access mode in the flags before waiting on a read or a write
that might never be possible if the file was not opened in the corrent
mode. This prevents a hang for bad programs. Why do people code like that?
1998-06-10 22:28:45 +00:00
John Birrell aef774b0d5 Remove SA_RESTART from the signal dispatch in user-space since this
seems to be tripping up a lot of applications.
1998-06-10 22:25:18 +00:00
John Birrell 3c165ef7b7 When doing a F_SETFL, read the flags back so that the ones stored
in the file descriptor table are exactly what the kernel knows subject
to the O_NONBLOCK flag being requested by the user.
1998-06-10 22:24:12 +00:00
John Birrell 627961e45f Add a commented out CFLAGS entry that can be uncommented to compile thread
lock debug into libc_r. I don't know if this is the best place to document
this, but at least it is recorded somewhere. 8-)
1998-06-09 23:25:13 +00:00
John Birrell ddc8afd422 Implement compile time debug support instead of tracking file name and
line number every time a file descriptor is locked.

This looks like a big change but it isn't. It should reduce the size
of libc_r and make it run slightly faster.
1998-06-09 23:21:05 +00:00
John Birrell a675022188 Add compile time debug instead of doing this all the time. Reduce the
time that a thread keeps the file descriptor table locked. In particular,
perform malloc/free calls outside the lock and handle the situation
where two threads can race to initialise the table entry for the same
file descriptor.
1998-06-09 23:16:53 +00:00
John Birrell 3411c10600 Add support for compile time debug. This is enabled if libc_r is built
with -D_LOCK_DEBUG. This adds the file name and line number to each lock
call and these are stored in the spinlock structure. When using debug
mode, the lock function will check if the thread is trying to lock
something it has already locked. This is not supposed to happen because
the lock will be freed too early.

Without lock debug, libc_r should be smaller and slightly faster.
1998-06-09 23:13:10 +00:00
John Birrell 74ebed9424 POSIX says that pthread_exit() is not allowed to be called from a
cleanup destructor, so trap this case to prevent me from being being
burnt again by applications that try to do this. With this change, an
application (like one using a mis-configured ACE) will exit the process
after displaying a message quoting the POSIX section that the application
has violated.
1998-06-09 23:08:41 +00:00
John Birrell 27949f44dc Add compile time thread lock debug support.
Add a thread specific flag to trap the case where pthread_exit() is
called from a destructor in violation of the Posix standard.
1998-06-09 23:02:43 +00:00
John Birrell 7d24d0302f Delete the atomic unlock function since it is no longer required.
Simplify the atomic lock to just write a value of 1 to the lock instead
of taking the value passed by the caller (which just confused things).
1998-06-09 08:25:41 +00:00
John Birrell 3dcb4f7556 Atomic lock asm code for the alpha version of libc_r. 1998-06-09 08:21:55 +00:00
John Birrell 2d8a580416 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
John Birrell c6831395f4 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
John Birrell c359f976b4 Re-design the thread specific key structure. 1998-06-06 07:20:23 +00:00
John Birrell 717d1611f4 I got the last commit back to front. 1998-06-06 07:02:27 +00:00
John Birrell 756534d117 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
John Birrell fca35cd32f 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
John Birrell 23c82db7a3 send and recv are wrappered in libc, so they shouldn't appear here. 1998-06-01 02:12:15 +00:00
John Birrell 8680cc3c47 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
John Birrell 382306949d Add some missing syscall wrappers. 1998-05-31 23:48:30 +00:00
John Birrell 5d359b97bb Remove some stale code.
Pointed out by: Amancio
1998-05-31 23:47:06 +00:00
John Birrell d972680a31 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
John Birrell 01029f8f17 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
John Birrell b46dfe97ae 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
John Birrell e5a8a007e1 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
John Birrell 9839f9695a Treat the lock value as volatile. 1998-05-05 21:47:58 +00:00
James Raynard c52c933ddd Typo fixes 1998-05-03 22:59:47 +00:00
John Birrell b1ad8d9155 Cleanup in the child, not the parent.
Submitted by: Tor Egge <Tor.Egge@idi.ntnu.no>
1998-05-02 03:42:20 +00:00
John Birrell 96efcebdfc Fix the incremental priority increment.
PR: bin/6467 Marino Ladavac <lada@pc8811.gud.siemens.at>
1998-04-30 21:50:29 +00:00
John Birrell 7bb870ac66 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
John Birrell ccd1da1333 Add spinlock. 1998-04-29 11:03:34 +00:00
John Birrell 4a027d50c7 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
John Birrell 312e185f9c Don't need wrappers for longjmp/setjmp anymore. 1998-04-29 09:40:51 +00:00
John Birrell 32664a7064 Remove empty files that were renamed some time ago. 1998-04-29 09:39:34 +00:00
John Birrell 1ce8c4dc49 Atomic lock source. 1998-04-29 09:36:03 +00:00
John Birrell af139b98d4 Allow a thread dump to report the thread's sigmask when in the
PS_SIGWAIT state.
1998-04-17 09:39:37 +00:00
John Birrell 334fa8f215 When in PS_SIGWAIT state, still call signal handlers and set errno
to EINTR.
1998-04-17 09:37:41 +00:00
John Birrell d60f0fa60d 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