'\" te .\" Copyright (c) 2001 Sun Microsystems, Inc. All Rights Reserved .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] .TH THR_SUSPEND 3C "Mar 22, 2002" .SH NAME thr_suspend, thr_continue \- suspend or continue thread execution .SH SYNOPSIS .LP .nf cc -mt [ \fIflag\fR... ] \fIfile\fR...[ \fIlibrary\fR... ] #include \fBint\fR \fBthr_suspend\fR(\fBthread_t\fR \fItarget_thread\fR); .fi .LP .nf \fBint\fR \fBthr_continue\fR(\fBthread_t\fR \fItarget_thread\fR); .fi .SH DESCRIPTION .sp .LP The \fBthr_suspend()\fR function immediately suspends the execution of the thread specified by \fItarget_thread\fR. On successful return from \fBthr_suspend()\fR, the suspended thread is no longer executing. Once a thread is suspended, subsequent calls to \fBthr_suspend()\fR have no effect. .sp .LP The \fBthr_continue()\fR function resumes the execution of a suspended thread. Once a suspended thread is continued, subsequent calls to \fBthr_continue()\fR have no effect. .sp .LP A suspended thread will not be awakened by any mechanism other than a call to \fBthr_continue()\fR. Signals and the effect of calls to\fBmutex_unlock\fR(3C), \fBrw_unlock\fR(3C), \fBsema_post\fR(3C), \fBcond_signal\fR(3C), and \fBcond_broadcast\fR(3C) remain pending until the execution of the thread is resumed by \fBthr_continue()\fR. .SH RETURN VALUES .sp .LP If successful, the \fBthr_suspend()\fR and \fBthr_continue()\fR functions return \fB0\fR. Otherwise, a non-zero value is returned to indicate the error. .SH ERRORS .sp .LP The \fBthr_suspend()\fR and \fBthr_continue()\fR functions will fail if: .sp .ne 2 .na \fB\fBESRCH\fR \fR .ad .RS 10n The \fItarget_thread\fR cannot be found in the current process. .RE .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ MT-Level MT-Safe .TE .SH SEE ALSO .sp .LP \fBthr_create\fR(3C), \fBthr_join\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5) .SH WARNINGS .sp .LP The \fBthr_suspend()\fR 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 \fBthr_continue()\fR is applied, regardless of any calls to \fBmutex_unlock()\fR, \fBcond_signal()\fR, or \fBcond_broadcast()\fR 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. .sp .LP The \fBthr_suspend()\fR and \fBthr_continue()\fR functions should be avoided. Mechanisms that involve the cooperation of the targeted thread, such as mutex locks and condition variables, should be employed instead.