pset(3): add code example, note about thread affinity.

sched(3): mention affinity(3) and cpuset(3).
This commit is contained in:
rmind 2008-06-16 14:34:10 +00:00
parent e6acd90e07
commit 4e4303fb66
2 changed files with 37 additions and 2 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: pset.3,v 1.4 2008/05/05 14:46:40 ad Exp $
.\" $NetBSD: pset.3,v 1.5 2008/06/16 14:34:10 rmind Exp $
.\"
.\" Copyright (c) 2008 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -151,11 +151,42 @@ 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
Processor sets might be used together with the thread affinity, see
.Xr affinity 3 .
In such case, the affinity mask takes precedence over the assignment
to processor sets.
.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 -unfilled
psetid_t psid;
cpuid_t ci = 0;
if (pset_create(&psid) < 0)
err(EXIT_FAILURE, "pset_create");
/* Assign CPU 0 to the processor-set */
if (pset_assign(psid, ci, NULL) < 0)
err(EXIT_FAILURE, "pset_assign");
/* Bind the current process to the processor-set */
if (pset_bind(psid, P_PID, P_MYID, NULL) < 0)
err(EXIT_FAILURE, "pset_bind");
/*
* At this point, CPU 0 runs only the current process.
*/
perform_work();
if (pset_destroy(psid) < 0)
err(EXIT_FAILURE, "pset_destroy")
.Ed
.Sh ERRORS
The
.Fn pset_create
@ -216,6 +247,8 @@ Another operation is performing on the processor set.
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

View File

@ -1,4 +1,4 @@
.\" $NetBSD: sched.3,v 1.3 2008/05/24 12:57:00 ad Exp $
.\" $NetBSD: sched.3,v 1.4 2008/06/16 14:34:10 rmind Exp $
.\"
.\" Copyright (c) 2008 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -225,6 +225,8 @@ and value of
is not zero.
.El
.Sh SEE ALSO
.Xr affinity 3 ,
.Xr cpuset 3 ,
.Xr pset 3 ,
.Xr schedctl 8
.Sh STANDARDS