1.\" $NetBSD: _lwp_ctl.2,v 1.5 2012/04/13 15:14:58 yamt 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 April 13, 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 sys/lwpctl.h 40.In lwp.h 41.Ft int 42.Fn _lwp_ctl "int features" "struct lwpctl **address" 43.\" ------------------------------------------------------------ 44.Sh DESCRIPTION 45.Fn _lwp_ctl 46prepares per-LWP communication area for the calling LWP, 47and maps it into the calling process' address space. 48It takes the following arguments. 49.Bl -tag -width features 50.It Fa features 51The bitwise-OR of the following flags. 52.Bl -tag -width LWPCTL_FEATURE_CURCPU 53.It Dv LWPCTL_FEATURE_CURCPU 54Request 55.Vt lc_curcpu . 56.It Dv LWPCTL_FEATURE_PCTR 57Request 58.Vt lc_pctr . 59.El 60.It Fa address 61The address to store a pointer to 62.Vt lwpctl 63structure for the calling LWP. 64.El 65.Pp 66The per-LWP communication area is described by an 67.Vt lwpctl 68structure. 69It has following members, depending on 70.Fa features . 71.Bl -tag -width int_lc_curcpu 72.It Vt int lc_curcpu 73The integral identifier of the CPU on which the LWP is running, 74or 75.Dv LWPCTL_CPU_NONE 76when the LWP is not running on any CPU. 77It's updated by the kernel and should be considered as read-only for 78userland. 79It's available only if requested with the 80.Dv LWPCTL_FEATURE_CURCPU 81flag. 82.It Vt int lc_pctr 83The integer which is incremented on every context switches to the LWP. 84It can be used to detect preemption of the LWP. 85(thus its name "preemption counter".) 86It's updated by the kernel and should be considered as read-only for 87userland. 88It's available only if requested with the 89.Dv LWPCTL_FEATURE_PCTR 90flag. 91.El 92.\" ------------------------------------------------------------ 93.Sh RETURN VALUES 94.Fn _lwp_ctl 95returns 0 on success. 96Otherwise, \-1 is returned and 97.Va errno 98is set to indicate the error. 99.\" ------------------------------------------------------------ 100.\".Sh ERRORS 101.\" ------------------------------------------------------------ 102.Sh SEE ALSO 103.Xr errno 2 104