1.\" $NetBSD: pthread_suspend_np.3,v 1.2 2003/11/12 11:58:34 wiz Exp $ 2.\" 3.\" Copyright (c) 2003 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Christos Zoulas. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.Dd November 12, 2003 38.Dt PTHREAD_SUSPEND_NP 3 39.Os 40.Sh NAME 41.Nm pthread_suspend_np , 42.Nm pthread_resume_np 43.Nd suspend/resume the given thread 44.Sh LIBRARY 45.Lb libpthread 46.Sh SYNOPSIS 47.In pthread.h 48.Ft int 49.Fn pthread_suspend_np "pthread_t thread" 50.Ft int 51.Fn pthread_resume_np "pthread_t thread" 52.Sh DESCRIPTION 53The 54.Fn pthread_suspend_np 55function suspends the 56.Ar thread 57given as argument. 58If 59.Ar thread 60is the currently running thread as returned by 61.Xr pthread_self 3 , 62the function fails and returns 63.Er EDEADLK . 64Otherwise, it removes the named thread from the running queue, and 65adds it to the suspended queue. 66The 67.Ar thread 68will remain blocked until 69.Fn pthread_resume_np 70is called on it. 71.Pp 72.Fn pthread_resume_np 73resumes the 74.Ar thread 75given as argument, if it was suspended. 76.Sh RETURN VALUES 77The 78.Fn pthread_suspend_np 79function returns 0 on success and an error number indicating the 80reason for the failure. 81The 82.Fn pthread_resume_np 83function always returns 0. 84.Sh ERRORS 85.Fn pthread_suspend_np 86shall fail if: 87.Bl -tag -width Er 88.It Bq Er EDEADLK 89The thread requested to suspend was the currently running thread. 90.El 91.Pp 92.Fn pthread_resume_np 93never fails. 94.Sh NOTES 95Some 96.Fn pthread_suspend_np 97implementations may allow suspending the current thread. 98This is dangerous, because the semantics of the function would then 99require the scheduler to schedule another thread, causing a thread 100context switch. 101Since that context switch can happen in a signal handler by someone 102calling 103.Fn pthread_suspend_np 104in a signal handler, this is currently not allowed. 105.Pp 106In 107.Fn pthread_resume_np 108we don't check if the 109.Ar thread 110argument is not already suspended. 111Some implementations might return an error condition if 112.Fn pthread_resume_np 113is called on a non-suspended thread. 114.Sh SEE ALSO 115.Xr pthread_attr_setcreatesuspend_np 3 , 116.Xr pthread_self 3 117