$NetBSD: _lwp_ctl.2,v 1.6 2022/12/04 16:17:50 uwe Exp $ Copyright (c)2007 YAMAMOTO Takashi, All rights reserved. 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 AUTHOR 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 AUTHOR 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 April 13, 2012
.Dt _LWP_CTL 2
.Os
.Sh NAME
.Nm _lwp_ctl
.Nd prepare per-LWP communication area between kernel and userland
------------------------------------------------------------.Sh LIBRARY
.Lb libc
------------------------------------------------------------.Sh SYNOPSIS
n sys/lwpctl.h n lwp.h .Ft int
.Fn _lwp_ctl "int features" "struct lwpctl **address"
------------------------------------------------------------.Sh DESCRIPTION
.Fn _lwp_ctl
prepares per-LWP communication area for the calling LWP,
and maps it into the calling process' address space.
It takes the following arguments.
l -tag -width features t Fa features The bitwise-OR of the following flags.
l -tag -width Dv t Dv LWPCTL_FEATURE_CURCPU Request
.Vt lc_curcpu .
t Dv LWPCTL_FEATURE_PCTR Request
.Vt lc_pctr .
.El
t Fa address The address to store a pointer to
.Vt lwpctl
structure for the calling LWP.
.El
p
The per-LWP communication area is described by an
.Vt lwpctl
structure.
It has following members, depending on
.Fa features .
l -tag -width Fa t Vt int Fa lc_curcpu The integral identifier of the CPU on which the LWP is running,
or
.Dv LWPCTL_CPU_NONE
when the LWP is not running on any CPU.
It's updated by the kernel and should be considered as read-only for
userland.
It's available only if requested with the
.Dv LWPCTL_FEATURE_CURCPU
flag.
t Vt int Fa lc_pctr The integer which is incremented on every context switches to the LWP.
It can be used to detect preemption of the LWP
o
thus its name
.Dq preemption counter .
c
It's updated by the kernel and should be considered as read-only for
userland.
It's available only if requested with the
.Dv LWPCTL_FEATURE_PCTR
flag.
.El
------------------------------------------------------------
.Sh RETURN VALUES
.Rv -std _lwp_ctl
------------------------------------------------------------
.Sh ERRORS
------------------------------------------------------------
.Sh SEE ALSO
.Xr errno 2