1.\" $NetBSD: _lwp_ctl.2,v 1.4 2012/03/14 13:24:48 jruoho Exp $ 2.\" 3.\" Copyright (c)2007 YAMAMOTO Takashi, 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25.\" SUCH DAMAGE. 26.\" 27.\" ------------------------------------------------------------ 28.Dd March 14, 2012 29.Dt _LWP_CTL 2 30.Os 31.Sh NAME 32.Nm _lwp_ctl 33.Nd prepare per-LWP communication area between kernel and userland 34.\" ------------------------------------------------------------ 35.Sh LIBRARY 36.Lb libc 37.\" ------------------------------------------------------------ 38.Sh SYNOPSIS 39.In lwp.h 40.Ft int 41.Fn _lwp_ctl "int features" "struct lwpctl **address" 42.\" ------------------------------------------------------------ 43.Sh DESCRIPTION 44.Fn _lwp_ctl 45prepares per-LWP communication area for the calling LWP, 46and maps it into the calling process' address space. 47It takes the following arguments. 48.Bl -tag -width features 49.It Fa features 50The bitwise-OR of the following flags. 51.Bl -tag -width LWPCTL_FEATURE_CURCPU 52.It Dv LWPCTL_FEATURE_CURCPU 53Request 54.Vt lc_curcpu . 55.It Dv LWPCTL_FEATURE_PCTR 56Request 57.Vt lc_pctr . 58.El 59.It Fa address 60The address to store a pointer to 61.Vt lwpctl 62structure for the calling LWP. 63.El 64.Pp 65The per-LWP communication area is described by an 66.Vt lwpctl 67structure. 68It has following members, depending on 69.Fa features . 70.Bl -tag -width int_lc_curcpu 71.It Vt int lc_curcpu 72The integral identifier of the CPU on which the LWP is running, 73or 74.Dv LWPCTL_CPU_NONE 75when the LWP is not running on any CPU. 76It's updated by the kernel and should be considered as read-only for 77userland. 78It's available only if requested with the 79.Dv LWPCTL_FEATURE_CURCPU 80flag. 81.It Vt int lc_pctr 82The integer which is incremented on every context switches to the LWP. 83It can be used to detect preemption of the LWP. 84(thus its name "preemption counter".) 85It's updated by the kernel and should be considered as read-only for 86userland. 87It's available only if requested with the 88.Dv LWPCTL_FEATURE_PCTR 89flag. 90.El 91.\" ------------------------------------------------------------ 92.Sh RETURN VALUES 93.Fn _lwp_ctl 94returns 0 on success. 95Otherwise, \-1 is returned and 96.Va errno 97is set to indicate the error. 98.\" ------------------------------------------------------------ 99.\".Sh ERRORS 100.\" ------------------------------------------------------------ 101.Sh SEE ALSO 102.Xr errno 2 103