Standard C Library Functions thrsuspend(3C)
NAME
thrsuspend, thrcontinue - suspend or continue thread exe-
cution
SYNOPSIS
cc -mt [ flag... ] file...[ library... ]
#include
int thrsuspend(threadt targetthread);
int thrcontinue(threadt targetthread);
DESCRIPTION
The thrsuspend() function immediately suspends the execu-
tion of the thread specified by targetthread. On successful
return from thrsuspend(), the suspended thread is no longer
executing. Once a thread is suspended, subsequent calls to
thrsuspend() have no effect.
The thrcontinue() function resumes the execution of a
suspended thread. Once a suspended thread is continued, sub-
sequent calls to thrcontinue() have no effect.
A suspended thread will not be awakened by any mechanism
other than a call to thrcontinue(). Signals and the effect
of calls tomutexunlock(3C), rwunlock(3C), semapost(3C),
condsignal(3C), and condbroadcast(3C) remain pending until
the execution of the thread is resumed by thrcontinue().
RETURN VALUES
If successful, the thrsuspend() and thrcontinue() func-
tions return 0. Otherwise, a non-zero value is returned to
indicate the error.
ERORS
The thrsuspend() and thrcontinue() functions will fail if:
ESRCH The targetthread cannot be found in the current
process.
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
SunOS 5.11 Last change: 22 Mar 2002 1
Standard C Library Functions thrsuspend(3C)
ATRIBUTE TYPE ATRIBUTE VALUE
MT-Level MT-Safe
SEE ALSO
thrcreate(3C), thrjoin(3C), attributes(5), standards(5)
WARNINGS
The thrsuspend() function is extremely difficult to use
safely because it suspends the target thread with no concern
for the target thread's state. The target thread could be
holding locks, waiting for a lock, or waiting on a condition
variable when it is unconditionally suspended. The thread
will not run until thrcontinue() is applied, regardless of
any calls to mutexunlock(), condsignal(), or
condbroadcast() by other threads. Its existence on a sleep
queue can interfere with the waking up of other threads that
are on the same sleep queue.
The thrsuspend() and thrcontinue() functions should be
avoided. Mechanisms that involve the cooperation of the tar-
geted thread, such as mutex locks and condition variables,
should be employed instead.
SunOS 5.11 Last change: 22 Mar 2002 2
|