[BACK]Return to pset.3 CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / librt

File: [cvs.NetBSD.org] / src / lib / librt / pset.3 (download)

Revision 1.12, Thu May 6 10:49:53 2010 UTC (9 years, 5 months ago) by jruoho
Branch: MAIN
CVS Tags: yamt-pagecache-tag8, yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, yamt-pagecache, tls-maxphys-base, tls-maxphys, tls-earlyentropy-base, tls-earlyentropy, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, netbsd-8-base, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, 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, matt-nb8-mediatek-base, matt-nb8-mediatek, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, matt-mips64-premerge-20101231, localcount-20160914, cherry-xenmp-base, cherry-xenmp, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2, agc-symver-base, agc-symver
Changes since 1.11: +2 -2 lines

Use standard section headers, as documented in mdoc.samples(7).

.\"	$NetBSD: pset.3,v 1.12 2010/05/06 10:49:53 jruoho Exp $
.\"
.\" Copyright (c) 2008 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Mindaugas Rasiukevicius <rmind at NetBSD org>.
.\"
.\" 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 May 6, 2010
.Dt PSET 3
.Os
.Sh NAME
.Nm pset_create ,
.Nm pset_assign ,
.Nm pset_bind ,
.Nm pset_destroy
.Nd processor sets
.Sh SYNOPSIS
.In sys/pset.h
.Ft int
.Fn pset_create "psetid_t *psid"
.Ft int
.Fn pset_assign "psetid_t psid" "cpuid_t cpuid" "psetid_t *opsid"
.Ft int
.Fn pset_bind "psetid_t psid" "idtype_t type" "id_t id" "psetid_t *opsid"
.Ft int
.Fn pset_destroy "psetid_t psid"
.Sh DESCRIPTION
The processor sets API provides the possibility to exclusively
dedicate specific processors or groups of processors to processes
or threads.
After processes or threads are bound to a group of processors by
the API, the group henceforth runs only those processes or threads.
This section describes the functions used to control processor sets.
.Sh FUNCTIONS
.Bl -tag -width compact
.It Fn pset_create psid
Creates a processor set, and returns its ID into
.Fa psid .
.It Fn pset_assign psid cpu opsid
Assigns the processor specified by
.Fa cpuid
to the processor set specified by
.Fa psid .
Stores the current processor set ID of the processor or
.Dv PS_NONE
into
.Fa opsid ,
if the pointer is not
.Dv NULL .
.Pp
The following actions can be specified:
.Bl -enum -offset 2n
.It
If
.Fa psid
is set to
.Dv PS_QUERY ,
then the current processor set ID will be returned into
.Fa psid ,
and no assignment will be performed.
.It
If
.Fa psid
is set to
.Dv PS_MYID ,
then the processor set ID of the calling process will be used, and
.Fa psid
will be ignored.
.It
If
.Fa psid
is set to
.Dv PS_NONE ,
any assignment to the processor will be cleared.
.El
.It Fn pset_bind psid type id opsid
Dedicates the processor set specified by
.Fa psid
to the target specified by
.Fa id .
The current processor set ID to which the target is bound or
.Dv PS_NONE
will be returned in
.Fa opsid ,
if the pointer is not
.Dv NULL .
.Nx
supports the following types of targets specified by
.Fa type :
.Bl -tag -width P_LWPID -offset 2n
.It Dv P_PID
Process identified by the PID.
.It Dv P_LWPID
Thread of the calling process indentified by the LID.
.El
.Pp
The following actions can be specified:
.Bl -enum -offset 2n
.It
If
.Fa psid
is set to
.Dv PS_QUERY ,
then the current processor set ID to which the target is bound or
.Dv PS_NONE
will be returned in
.Fa opsid ,
and no binding will be performed.
.It
If
.Fa psid
is set to
.Dv PS_MYID ,
then the processor set ID of the calling process will be used.
.It
If
.Fa psid
is set to
.Dv PS_NONE ,
the specified target will be unbound from the processor set.
.El
.It Fn pset_destroy psid
Destroys the processor set specified by
.Fa psid .
Before destroying the processor set, all related assignments of the
processors will be cleared, and all bound threads will be unbound.
.Pp
If
.Fa psid
is
.Dv PS_MYID ,
the processor set ID of the caller thread will be used.
.El
.Sh IMPLEMENTATION NOTES
The
.Fn pset_bind
function can return the current processor set ID to which the
target is bound, or
.Dv PS_NONE .
However, for example, the process may have many threads, which could be
bound to different processor sets.
In such a case it is unspecified which thread will be used to return
the information.
.Pp
There is an alternative thread affinity interface, see
.Xr affinity 3 .
However, processor sets and thread affinity are mutually exclusive,
hence mixing of these interfaces is prohibited.
.Sh RETURN VALUES
Upon successful completion these functions return 0.
Otherwise, \-1 is returned and
.Va errno
is set to indicate the error.
.Sh EXAMPLES
An example of code fragment, which assigns the CPU whose ID is 0,
for current process:
.Bd -literal
	psetid_t psid;
	cpuid_t ci = 0;

	if (pset_create(\*[Am]psid) \*[Lt] 0)
		err(EXIT_FAILURE, "pset_create");

	/* Assign CPU 0 to the processor-set */
	if (pset_assign(psid, ci, NULL) \*[Lt] 0)
		err(EXIT_FAILURE, "pset_assign");

	/* Bind the current process to the processor-set */
	if (pset_bind(psid, P_PID, P_MYID, NULL) \*[Lt] 0)
		err(EXIT_FAILURE, "pset_bind");

	/*
	 * At this point, CPU 0 runs only the current process.
	 */
	perform_work();

	if (pset_destroy(psid) \*[Lt] 0)
		err(EXIT_FAILURE, "pset_destroy");
.Ed
.Sh ERRORS
The
.Fn pset_create
function fails if:
.Bl -tag -width Er
.It Bq Er ENOMEM
No memory is available for creation of the processor set, or limit
of the allowed count of the processor sets was reached.
.It Bq Er EPERM
The calling process is not the super-user.
.El
.Pp
The
.Fn pset_assign
function fails if:
.Bl -tag -width Er
.It Bq Er EBUSY
Another operation is performing on the processor set.
.It Bq Er EINVAL
.Fa psid
or
.Fa cpuid
are invalid.
.It Bq Er EPERM
The calling process is not the super-user, and
.Fa psid
is not
.Dv PS_QUERY .
.El
.Pp
The
.Fn pset_bind
function fails if:
.Bl -tag -width Er
.It Bq Er EBUSY
Another operation is performing on the processor set.
.It Bq Er EINVAL
.Fa psid
or
.Fa type
are invalid.
.It Bq Er EPERM
The calling process is not the super-user, and
.Fa psid
is not
.Dv PS_QUERY .
.It Bq Er ESRCH
The specified target was not found.
.El
.Pp
The
.Fn pset_destroy
function fails if:
.Bl -tag -width Er
.It Bq Er EBUSY
Another operation is performing on the processor set.
.It Bq Er EPERM
The calling process is not the super-user.
.El
.Sh SEE ALSO
.Xr affinity 3 ,
.Xr cpuset 3 ,
.Xr sched 3 ,
.Xr schedctl 8
.Sh STANDARDS
This API is expected to be compatible with the APIs found in Solaris and
HP-UX operating systems.
.Sh HISTORY
The processor sets appeared in
.Nx 5.0 .