1thr_suspend(3C) Standard C Library Functions thr_suspend(3C)
2
3
4
6 thr_suspend, thr_continue - suspend or continue thread execution
7
9 cc -mt [ flag... ] file...[ library... ]
10 #include <thread.h>
11
12 int thr_suspend(thread_t target_thread);
13
14
15 int thr_continue(thread_t target_thread);
16
17
19 The thr_suspend() function immediately suspends the execution of the
20 thread specified by target_thread. On successful return from thr_sus‐
21 pend(), the suspended thread is no longer executing. Once a thread is
22 suspended, subsequent calls to thr_suspend() have no effect.
23
24
25 The thr_continue() function resumes the execution of a suspended
26 thread. Once a suspended thread is continued, subsequent calls to
27 thr_continue() have no effect.
28
29
30 A suspended thread will not be awakened by any mechanism other than a
31 call to thr_continue(). Signals and the effect of calls tomu‐
32 tex_unlock(3C), rw_unlock(3C), sema_post(3C), cond_signal(3C), and
33 cond_broadcast(3C) remain pending until the execution of the thread is
34 resumed by thr_continue().
35
37 If successful, the thr_suspend() and thr_continue() functions return
38 0. Otherwise, a non-zero value is returned to indicate the error.
39
41 The thr_suspend() and thr_continue() functions will fail if:
42
43 ESRCH The target_thread cannot be found in the current process.
44
45
47 See attributes(5) for descriptions of the following attributes:
48
49
50
51
52 ┌─────────────────────────────┬─────────────────────────────┐
53 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
54 ├─────────────────────────────┼─────────────────────────────┤
55 │MT-Level │MT-Safe │
56 └─────────────────────────────┴─────────────────────────────┘
57
59 thr_create(3C), thr_join(3C), attributes(5), standards(5)
60
62 The thr_suspend() function is extremely difficult to use safely because
63 it suspends the target thread with no concern for the target thread's
64 state. The target thread could be holding locks, waiting for a lock, or
65 waiting on a condition variable when it is unconditionally suspended.
66 The thread will not run until thr_continue() is applied, regardless of
67 any calls to mutex_unlock(), cond_signal(), or cond_broadcast() by
68 other threads. Its existence on a sleep queue can interfere with the
69 waking up of other threads that are on the same sleep queue.
70
71
72 The thr_suspend() and thr_continue() functions should be avoided. Mech‐
73 anisms that involve the cooperation of the targeted thread, such as
74 mutex locks and condition variables, should be employed instead.
75
76
77
78SunOS 5.11 22 Mar 2002 thr_suspend(3C)