Added a NOTE to point out that the affinity mask is actually a

per-thread attribute that can be adjusted independently
for each thread in a thread group.
This commit is contained in:
Michael Kerrisk 2005-05-03 14:24:08 +00:00
parent 8ea6b1affa
commit d2b761645c
1 changed files with 22 additions and 9 deletions

View File

@ -25,11 +25,13 @@
.\" 2002-11-19 Robert Love <rml@tech9.net> - initial version
.\" 2004-04-20 mtk - fixed description of return value
.\" 2004-04-22 aeb - added glibc prototype history
.\" 2005-05-03 mtk - noted that sched_setaffinity may cause thread
.\" migration and that CPU affinity is a per-thread attribute.
.\"
.TH SCHED_SETAFFINITY 2 2005-05-03 "Linux" "Linux Programmer's Manual"
.SH NAME
sched_setaffinity, sched_getaffinity \- set and get a process's CPU affinity
mask
sched_setaffinity, sched_getaffinity \- set and get a process's CPU
affinity mask
.SH SYNOPSIS
.B #include <sched.h>
.sp
@ -48,12 +50,14 @@ is zero, then the current process is used.
.sp
The affinity mask is represented by the bitmask stored in
.IR mask .
The least significant bit corresponds to the first logical processor number on
the system, while the most significant bit corresponds to the last logical
processor number on the system. A set bit corresponds to a legally schedulable
CPU while an unset bit corresponds to an illegally schedulable CPU. In other
words, a process is bound to and will only run on processors whose
corresponding bit is set. Usually, all bits in the mask are set.
The least significant bit corresponds to the first logical processor
number on the system, while the most significant bit corresponds to
the last logical processor number on the system.
A set bit corresponds to a legally schedulable CPU while an unset
bit corresponds to an illegally schedulable CPU.
In other words, a process is bound to and will only run on
processors whose corresponding bit is set.
Usually, all bits in the mask are set.
.sp
If the process specified by
.I pid
@ -103,7 +107,7 @@ is set appropriately.
A supplied memory address was invalid.
.TP
.B EINVAL
The affinity bitmask
The affinity bitmask
.I mask
contains no processors that are physically on the system, or the length
.I len
@ -122,6 +126,13 @@ capability.
.TP
.B ESRCH
The process whose ID is \fIpid\fR could not be found.
.SH "NOTES"
The affinity mask is actually a per-thread attribute that can be
adjusted independently for each of the threads in a thread group.
The value returned from a call to
.BR gettid (2)
can be passed in the argument
.IR pid .
.SH "HISTORY"
The affinity syscalls were introduced in Linux kernel 2.5.8.
The library calls were introduced in glibc 2.3, and are still in
@ -140,7 +151,9 @@ extern int sched_getaffinity (pid_t pid, size_t cpusetsize,
cpu_set_t *cpuset);
.fi
.SH "SEE ALSO"
.BR clone (2),
.BR getpriority (2),
.BR gettid (2),
.BR nice (2),
.BR sched_get_priority_max (2),
.BR sched_get_priority_min (2),