[BACK]Return to _lwp_park.2 CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / sys

File: [cvs.NetBSD.org] / src / lib / libc / sys / _lwp_park.2 (download)

Revision 1.7, Wed Apr 30 13:10:51 2008 UTC (15 years, 11 months ago) by martin
Branch: MAIN
CVS Tags: yamt-pf42-base4, yamt-pf42-base3, yamt-pf42-base2, yamt-pagecache-tag8, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, wrstuden-revivesa-base-3, wrstuden-revivesa-base-2, wrstuden-revivesa-base-1, wrstuden-revivesa-base, wrstuden-revivesa, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, netbsd-5-base, netbsd-5-2-RELEASE, netbsd-5-2-RC1, netbsd-5-2-3-RELEASE, netbsd-5-2-2-RELEASE, netbsd-5-2-1-RELEASE, netbsd-5-2, netbsd-5-1-RELEASE, netbsd-5-1-RC4, netbsd-5-1-RC3, netbsd-5-1-RC2, netbsd-5-1-RC1, netbsd-5-1-5-RELEASE, netbsd-5-1-4-RELEASE, netbsd-5-1-3-RELEASE, netbsd-5-1-2-RELEASE, netbsd-5-1-1-RELEASE, netbsd-5-1, netbsd-5-0-RELEASE, netbsd-5-0-RC4, netbsd-5-0-RC3, netbsd-5-0-RC2, netbsd-5-0-RC1, netbsd-5-0-2-RELEASE, netbsd-5-0-1-RELEASE, netbsd-5-0, netbsd-5, matt-premerge-20091211, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, matt-nb5-pq3-base, matt-nb5-pq3, matt-nb5-mips64-u2-k2-k4-k7-k8-k9, matt-nb5-mips64-u1-k1-k5, matt-nb5-mips64-premerge-20101231, matt-nb5-mips64-premerge-20091211, matt-nb5-mips64-k15, matt-nb5-mips64, matt-nb4-mips64-k7-u2a-k9b, matt-mips64-premerge-20101231, matt-mips64-base2, jym-xensuspend-nbase, jym-xensuspend-base, jym-xensuspend, hpcarm-cleanup-nbase, christos-time_t-nbase, christos-time_t-base, cherry-xenmp-base, cherry-xenmp, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2, agc-symver-base, agc-symver
Branch point for: yamt-pagecache, tls-maxphys, christos-time_t
Changes since 1.6: +1 -8 lines

Convert TNF licenses to new 2 clause variant

.\"	$NetBSD: _lwp_park.2,v 1.7 2008/04/30 13:10:51 martin Exp $
.\"
.\" Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Jason R. Thorpe of Wasabi Systems, Inc, and by Andrew Doran.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd September 25, 2007
.Dt _LWP_PARK 2
.Os
.Sh NAME
.Nm _lwp_park
.Nd wait interruptably in the kernel
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In lwp.h
.Ft int
.Fn _lwp_park "const struct timespec *abstime" "lwpid_t unpark" "const void *hint" "const void *unparkhint"
.Sh DESCRIPTION
.Fn _lwp_park
can be used to synchronize access to resources among multiple light-weight
processes.
It causes the calling LWP to wait interruptably in the kernel, until one
of the following conditions is met:
.Bl -bullet
.It
The
.Fa abstime
argument is non-NULL, and the absolute UTC time it specifies has passed.
.It
The LWP receives a directed signal posted using
.Fn _lwp_kill ,
or is elected to handle a signal on behalf of its containing process.
.It
The LWP is awoken by another LWP in the same process that has made
a call to
.Fn _lwp_wakeup .
.It
The LWP is awoken by another LWP in the same process that has made
a call to
.Fn _lwp_unpark
or
.Fn _lwp_unpark_all .
.El
.Pp
The preferred method to awaken an LWP sleeping as a result of a call
to
.Fn _lwp_park
is to make a call to
.Fn _lwp_unpark ,
or
.Fn _lwp_unpark_all .
The
.Fn _lwp_wakeup
system call is a more general facility, and requires more resources
to execute.
.Pp
The optional
.Fa hint
argument specifies the address of object upon which the LWP is
synchronizing.
When the
.Fa hint
value is matched between calls to
.Fn _lwp_park
and
.Fn _lwp_unpark
or
.Fn _lwp_unpark_all ,
it may reduce the time necessary for the system to resume execution
of waiting LWPs.
.Pp
The
.Fa unpark
and
.Fa unparkhint
arguments can be used to fold a park operation and unpark operation into a
single system call.
If
.Fa unpark
is non-zero, the system will behave as if the following call had been made
before the calling thread begins to wait:
.Bd -literal
	_lwp_unpark(unpark, unparkhint);
.Ed
.Sh RETURN VALUES
.Fn _lwp_park
may return a value of 0.
Otherwise, \-1 is returned and
.Va errno
is set to provide more information.
.Sh ERRORS
.Bl -tag -width [EINVAL]
.It Bq Er EALREADY
A request was made to wake the LWP before it began to wait in
the kernel.
.It Bq Er EINTR
The LWP has been awoken by a signal or by a call to one of the
following functions:
.Fn _lwp_unpark ,
.Fn _lwp_unpark_all ,
.Fn _lwp_wakeup .
.It Bq Er EINVAL
The time value specified by
.Fa abstime
is invalid.
.It Bq Er ESRCH
No LWP can be found in the current process corresponding to
.Fa unpark .
.It Bq Er ETIMEDOUT
The UTC time specified by
.Fa abstime
has passed.
.El
.Sh SEE ALSO
.Xr _lwp_unpark 2 ,
.Xr _lwp_unpark_all 2 ,
.Xr _lwp_wakeup 2
.Sh HISTORY
The
.Fn _lwp_park
system call first appeared in
.Nx 5.0 .