1*f14fb602SLionel Sambuc.\" $NetBSD: _lwp_ctl.2,v 1.5 2012/04/13 15:14:58 yamt Exp $ 22fe8fb19SBen Gras.\" 32fe8fb19SBen Gras.\" Copyright (c)2007 YAMAMOTO Takashi, 42fe8fb19SBen Gras.\" All rights reserved. 52fe8fb19SBen Gras.\" 62fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without 72fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions 82fe8fb19SBen Gras.\" are met: 92fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright 102fe8fb19SBen Gras.\" notice, this list of conditions and the following disclaimer. 112fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright 122fe8fb19SBen Gras.\" notice, this list of conditions and the following disclaimer in the 132fe8fb19SBen Gras.\" documentation and/or other materials provided with the distribution. 142fe8fb19SBen Gras.\" 152fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 162fe8fb19SBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 172fe8fb19SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 182fe8fb19SBen Gras.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 192fe8fb19SBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 202fe8fb19SBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 212fe8fb19SBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 222fe8fb19SBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 232fe8fb19SBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 242fe8fb19SBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 252fe8fb19SBen Gras.\" SUCH DAMAGE. 262fe8fb19SBen Gras.\" 272fe8fb19SBen Gras.\" ------------------------------------------------------------ 28*f14fb602SLionel Sambuc.Dd April 13, 2012 292fe8fb19SBen Gras.Dt _LWP_CTL 2 302fe8fb19SBen Gras.Os 312fe8fb19SBen Gras.Sh NAME 322fe8fb19SBen Gras.Nm _lwp_ctl 332fe8fb19SBen Gras.Nd prepare per-LWP communication area between kernel and userland 342fe8fb19SBen Gras.\" ------------------------------------------------------------ 352fe8fb19SBen Gras.Sh LIBRARY 362fe8fb19SBen Gras.Lb libc 372fe8fb19SBen Gras.\" ------------------------------------------------------------ 382fe8fb19SBen Gras.Sh SYNOPSIS 39*f14fb602SLionel Sambuc.In sys/lwpctl.h 402fe8fb19SBen Gras.In lwp.h 412fe8fb19SBen Gras.Ft int 422fe8fb19SBen Gras.Fn _lwp_ctl "int features" "struct lwpctl **address" 432fe8fb19SBen Gras.\" ------------------------------------------------------------ 442fe8fb19SBen Gras.Sh DESCRIPTION 452fe8fb19SBen Gras.Fn _lwp_ctl 462fe8fb19SBen Grasprepares per-LWP communication area for the calling LWP, 472fe8fb19SBen Grasand maps it into the calling process' address space. 482fe8fb19SBen GrasIt takes the following arguments. 492fe8fb19SBen Gras.Bl -tag -width features 502fe8fb19SBen Gras.It Fa features 512fe8fb19SBen GrasThe bitwise-OR of the following flags. 522fe8fb19SBen Gras.Bl -tag -width LWPCTL_FEATURE_CURCPU 532fe8fb19SBen Gras.It Dv LWPCTL_FEATURE_CURCPU 54*f14fb602SLionel SambucRequest 55*f14fb602SLionel Sambuc.Vt lc_curcpu . 562fe8fb19SBen Gras.It Dv LWPCTL_FEATURE_PCTR 57*f14fb602SLionel SambucRequest 58*f14fb602SLionel Sambuc.Vt lc_pctr . 592fe8fb19SBen Gras.El 602fe8fb19SBen Gras.It Fa address 61*f14fb602SLionel SambucThe address to store a pointer to 62*f14fb602SLionel Sambuc.Vt lwpctl 63*f14fb602SLionel Sambucstructure for the calling LWP. 642fe8fb19SBen Gras.El 652fe8fb19SBen Gras.Pp 66*f14fb602SLionel SambucThe per-LWP communication area is described by an 67*f14fb602SLionel Sambuc.Vt lwpctl 68*f14fb602SLionel Sambucstructure. 692fe8fb19SBen GrasIt has following members, depending on 702fe8fb19SBen Gras.Fa features . 712fe8fb19SBen Gras.Bl -tag -width int_lc_curcpu 72*f14fb602SLionel Sambuc.It Vt int lc_curcpu 732fe8fb19SBen GrasThe integral identifier of the CPU on which the LWP is running, 742fe8fb19SBen Grasor 752fe8fb19SBen Gras.Dv LWPCTL_CPU_NONE 762fe8fb19SBen Graswhen the LWP is not running on any CPU. 772fe8fb19SBen GrasIt's updated by the kernel and should be considered as read-only for 782fe8fb19SBen Grasuserland. 792fe8fb19SBen GrasIt's available only if requested with the 802fe8fb19SBen Gras.Dv LWPCTL_FEATURE_CURCPU 812fe8fb19SBen Grasflag. 82*f14fb602SLionel Sambuc.It Vt int lc_pctr 832fe8fb19SBen GrasThe integer which is incremented on every context switches to the LWP. 842fe8fb19SBen GrasIt can be used to detect preemption of the LWP. 852fe8fb19SBen Gras(thus its name "preemption counter".) 862fe8fb19SBen GrasIt's updated by the kernel and should be considered as read-only for 872fe8fb19SBen Grasuserland. 882fe8fb19SBen GrasIt's available only if requested with the 892fe8fb19SBen Gras.Dv LWPCTL_FEATURE_PCTR 902fe8fb19SBen Grasflag. 912fe8fb19SBen Gras.El 922fe8fb19SBen Gras.\" ------------------------------------------------------------ 932fe8fb19SBen Gras.Sh RETURN VALUES 942fe8fb19SBen Gras.Fn _lwp_ctl 952fe8fb19SBen Grasreturns 0 on success. 962fe8fb19SBen GrasOtherwise, \-1 is returned and 972fe8fb19SBen Gras.Va errno 982fe8fb19SBen Grasis set to indicate the error. 992fe8fb19SBen Gras.\" ------------------------------------------------------------ 1002fe8fb19SBen Gras.\".Sh ERRORS 1012fe8fb19SBen Gras.\" ------------------------------------------------------------ 1022fe8fb19SBen Gras.Sh SEE ALSO 1032fe8fb19SBen Gras.Xr errno 2 104