xref: /minix3/lib/libc/sys/_lwp_park.2 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc.\"	$NetBSD: _lwp_park.2,v 1.9 2014/01/31 21:11:05 wiz Exp $
22fe8fb19SBen Gras.\"
32fe8fb19SBen Gras.\" Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
42fe8fb19SBen Gras.\" All rights reserved.
52fe8fb19SBen Gras.\"
62fe8fb19SBen Gras.\" This code is derived from software contributed to The NetBSD Foundation
72fe8fb19SBen Gras.\" by Jason R. Thorpe of Wasabi Systems, Inc, and by Andrew Doran.
82fe8fb19SBen Gras.\"
92fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without
102fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions
112fe8fb19SBen Gras.\" are met:
122fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright
132fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer.
142fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
152fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer in the
162fe8fb19SBen Gras.\"    documentation and/or other materials provided with the distribution.
172fe8fb19SBen Gras.\"
182fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
192fe8fb19SBen Gras.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
202fe8fb19SBen Gras.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
212fe8fb19SBen Gras.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
222fe8fb19SBen Gras.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
232fe8fb19SBen Gras.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
242fe8fb19SBen Gras.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
252fe8fb19SBen Gras.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
262fe8fb19SBen Gras.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
272fe8fb19SBen Gras.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
282fe8fb19SBen Gras.\" POSSIBILITY OF SUCH DAMAGE.
292fe8fb19SBen Gras.\"
30*0a6a1f1dSLionel Sambuc.Dd March 28, 2013
312fe8fb19SBen Gras.Dt _LWP_PARK 2
322fe8fb19SBen Gras.Os
332fe8fb19SBen Gras.Sh NAME
342fe8fb19SBen Gras.Nm _lwp_park
352fe8fb19SBen Gras.Nd wait interruptably in the kernel
362fe8fb19SBen Gras.Sh LIBRARY
372fe8fb19SBen Gras.Lb libc
382fe8fb19SBen Gras.Sh SYNOPSIS
392fe8fb19SBen Gras.In lwp.h
402fe8fb19SBen Gras.Ft int
41*0a6a1f1dSLionel Sambuc.Fn _lwp_park "clockid_t clock_id" "int flags" "const struct timespec *ts" "lwpid_t unpark" "const void *hint" "const void *unparkhint"
422fe8fb19SBen Gras.Sh DESCRIPTION
432fe8fb19SBen Gras.Fn _lwp_park
442fe8fb19SBen Grascan be used to synchronize access to resources among multiple light-weight
452fe8fb19SBen Grasprocesses.
462fe8fb19SBen GrasIt causes the calling LWP to wait interruptably in the kernel, until one
472fe8fb19SBen Grasof the following conditions is met:
482fe8fb19SBen Gras.Bl -bullet
492fe8fb19SBen Gras.It
502fe8fb19SBen GrasThe
51*0a6a1f1dSLionel Sambuc.Fa ts
52*0a6a1f1dSLionel Sambucargument is
53*0a6a1f1dSLionel Sambuc.Pf non- Dv NULL ,
54*0a6a1f1dSLionel Sambucand the time it specifies has passed.
55*0a6a1f1dSLionel SambucThe
56*0a6a1f1dSLionel Sambuc.Fa ts
57*0a6a1f1dSLionel Sambuctime can be an relative interval to wait if the
58*0a6a1f1dSLionel Sambuc.Ar flags
59*0a6a1f1dSLionel Sambucargument does not contain
60*0a6a1f1dSLionel Sambuc.Dv TIMER_ABSTIME
61*0a6a1f1dSLionel Sambucor it can be an absolute time compared to
62*0a6a1f1dSLionel Sambuc.Dv CLOCK_REALTIME
63*0a6a1f1dSLionel Sambucor
64*0a6a1f1dSLionel Sambuc.Dv CLOCK_MONOTONIC
65*0a6a1f1dSLionel Sambucdepending on the value
66*0a6a1f1dSLionel Sambucof the
67*0a6a1f1dSLionel Sambuc.Ar clock_id
68*0a6a1f1dSLionel Sambucargument.
692fe8fb19SBen Gras.It
702fe8fb19SBen GrasThe LWP receives a directed signal posted using
712fe8fb19SBen Gras.Fn _lwp_kill ,
722fe8fb19SBen Grasor is elected to handle a signal on behalf of its containing process.
732fe8fb19SBen Gras.It
742fe8fb19SBen GrasThe LWP is awoken by another LWP in the same process that has made
752fe8fb19SBen Grasa call to
762fe8fb19SBen Gras.Fn _lwp_wakeup .
772fe8fb19SBen Gras.It
782fe8fb19SBen GrasThe LWP is awoken by another LWP in the same process that has made
792fe8fb19SBen Grasa call to
802fe8fb19SBen Gras.Fn _lwp_unpark
812fe8fb19SBen Grasor
822fe8fb19SBen Gras.Fn _lwp_unpark_all .
832fe8fb19SBen Gras.El
842fe8fb19SBen Gras.Pp
852fe8fb19SBen GrasThe preferred method to awaken an LWP sleeping as a result of a call
862fe8fb19SBen Grasto
872fe8fb19SBen Gras.Fn _lwp_park
882fe8fb19SBen Grasis to make a call to
892fe8fb19SBen Gras.Fn _lwp_unpark ,
902fe8fb19SBen Grasor
912fe8fb19SBen Gras.Fn _lwp_unpark_all .
922fe8fb19SBen GrasThe
932fe8fb19SBen Gras.Fn _lwp_wakeup
942fe8fb19SBen Grassystem call is a more general facility, and requires more resources
952fe8fb19SBen Grasto execute.
962fe8fb19SBen Gras.Pp
972fe8fb19SBen GrasThe optional
982fe8fb19SBen Gras.Fa hint
992fe8fb19SBen Grasargument specifies the address of object upon which the LWP is
1002fe8fb19SBen Grassynchronizing.
1012fe8fb19SBen GrasWhen the
1022fe8fb19SBen Gras.Fa hint
1032fe8fb19SBen Grasvalue is matched between calls to
1042fe8fb19SBen Gras.Fn _lwp_park
1052fe8fb19SBen Grasand
1062fe8fb19SBen Gras.Fn _lwp_unpark
1072fe8fb19SBen Grasor
1082fe8fb19SBen Gras.Fn _lwp_unpark_all ,
1092fe8fb19SBen Grasit may reduce the time necessary for the system to resume execution
1102fe8fb19SBen Grasof waiting LWPs.
1112fe8fb19SBen Gras.Pp
1122fe8fb19SBen GrasThe
1132fe8fb19SBen Gras.Fa unpark
1142fe8fb19SBen Grasand
1152fe8fb19SBen Gras.Fa unparkhint
1162fe8fb19SBen Grasarguments can be used to fold a park operation and unpark operation into a
1172fe8fb19SBen Grassingle system call.
1182fe8fb19SBen GrasIf
1192fe8fb19SBen Gras.Fa unpark
1202fe8fb19SBen Grasis non-zero, the system will behave as if the following call had been made
1212fe8fb19SBen Grasbefore the calling thread begins to wait:
1222fe8fb19SBen Gras.Bd -literal
1232fe8fb19SBen Gras	_lwp_unpark(unpark, unparkhint);
1242fe8fb19SBen Gras.Ed
1252fe8fb19SBen Gras.Sh RETURN VALUES
1262fe8fb19SBen Gras.Fn _lwp_park
1272fe8fb19SBen Grasmay return a value of 0.
1282fe8fb19SBen GrasOtherwise, \-1 is returned and
1292fe8fb19SBen Gras.Va errno
1302fe8fb19SBen Grasis set to provide more information.
1312fe8fb19SBen Gras.Sh ERRORS
1322fe8fb19SBen Gras.Bl -tag -width [EINVAL]
1332fe8fb19SBen Gras.It Bq Er EALREADY
1342fe8fb19SBen GrasA request was made to wake the LWP before it began to wait in
1352fe8fb19SBen Grasthe kernel.
1362fe8fb19SBen Gras.It Bq Er EINTR
1372fe8fb19SBen GrasThe LWP has been awoken by a signal or by a call to one of the
1382fe8fb19SBen Grasfollowing functions:
1392fe8fb19SBen Gras.Fn _lwp_unpark ,
1402fe8fb19SBen Gras.Fn _lwp_unpark_all ,
1412fe8fb19SBen Gras.Fn _lwp_wakeup .
1422fe8fb19SBen Gras.It Bq Er EINVAL
1432fe8fb19SBen GrasThe time value specified by
144*0a6a1f1dSLionel Sambuc.Fa ts
1452fe8fb19SBen Grasis invalid.
1462fe8fb19SBen Gras.It Bq Er ESRCH
1472fe8fb19SBen GrasNo LWP can be found in the current process corresponding to
1482fe8fb19SBen Gras.Fa unpark .
1492fe8fb19SBen Gras.It Bq Er ETIMEDOUT
1502fe8fb19SBen GrasThe UTC time specified by
151*0a6a1f1dSLionel Sambuc.Fa ts
1522fe8fb19SBen Grashas passed.
1532fe8fb19SBen Gras.El
1542fe8fb19SBen Gras.Sh SEE ALSO
1552fe8fb19SBen Gras.Xr _lwp_unpark 2 ,
1562fe8fb19SBen Gras.Xr _lwp_unpark_all 2 ,
1572fe8fb19SBen Gras.Xr _lwp_wakeup 2
1582fe8fb19SBen Gras.Sh HISTORY
1592fe8fb19SBen GrasThe
1602fe8fb19SBen Gras.Fn _lwp_park
1612fe8fb19SBen Grassystem call first appeared in
1622fe8fb19SBen Gras.Nx 5.0 .
163