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).
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.
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.
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.
namely, put the thread to deadqueue rather than just leaking it.
- fix a race between pthread_detach/join and pthread_exit,
which also causes dead thread leaks.
- statically initialize all global spin locks. on hppa, 0 means
the lock is held, so leaving them with the default value doesn't work.
- compare functions pointers using a function-pointer type rather than
an integral type. on hppa, function pointers may be indirect,
so we need to trigger gcc to emit calls to the function-pointer
canonicalization routines in the millicode.
- on hppa the stack grows up, so handle that using the STACK_* macros.
- enable concurrency according to environment variable PTHREAD_CONCURRENCY
- add idle VP wakeup if there are additional jobs and idle VPs
- make reidlequeue per VP
- enable spinning for locks
- fix race condition in alarm processing
- fix race condition in mutex locking
- make debugging output line buffered and add VP prefix to debug lines
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.
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.
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.
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".
1. add new pthread__abort() and change pthread_assert(0) to it.
2. put constcond in the right place (in the macro).
3. no space after pthread__assert macro.
time) to pthread__start() (called on the first call of
pthread_create()), so that there's no opportunity for a fork() to
clear the per-process timer.
Problem pointed out by a test program from Mihai CHELARU on
current-users.
opposed to internal errors. The setting of the PTHREAD_ERRORMODE
environment variable determines the runtime behavior. Valid settings
are "ignore", "abort", and "print". The default is currently "abort".
* pthread_attr_getname_np()
* pthread_attr_setname_np()
* pthread_getname_np()
* pthread_setname_np()
In addition to being query'able by the application (for log messages, etc.),
it is intended that these names can show up in the debugger.
Reviewed by nathanw.
PT_FLAG_CS_DISABLED in pt_flags.
Prevents cancellation cleanup handlers from thinking that they've been
canceled and exiting mid-handler. Problem spotted by Matt Thomas.
* thr_create() (stub in libc aborts)
* thr_exit() (stub in libc calls exit())
* thr_yield() (stub in libc does nothing)
Also make the libc thr_self() stub not abort.
XXX Should we add thrattr_*() stubs for setting the detach-state?
- remove argument variable names since they pollute the namespace
- add mock implementation of the missing stack functions
XXX: we need to do this right [i.e. actually get and set sizes and addresses]
but the current stack setup makes this a bit complicated.