summaryrefslogtreecommitdiffstats
path: root/man2/sched_setaffinity.2
diff options
context:
space:
mode:
Diffstat (limited to 'man2/sched_setaffinity.2')
-rw-r--r--man2/sched_setaffinity.239
1 files changed, 20 insertions, 19 deletions
diff --git a/man2/sched_setaffinity.2 b/man2/sched_setaffinity.2
index 6538b44ec..9389e099d 100644
--- a/man2/sched_setaffinity.2
+++ b/man2/sched_setaffinity.2
@@ -12,7 +12,7 @@
.\" 2008-11-12, mtk, removed CPU_*() macro descriptions to a
.\" separate CPU_SET(3) page.
.\"
-.TH sched_setaffinity 2 2023-02-05 "Linux man-pages 6.03"
+.TH sched_setaffinity 2 2023-05-03 "Linux man-pages 6.05.01"
.SH NAME
sched_setaffinity, sched_getaffinity \- \
set and get a thread's CPU affinity mask
@@ -134,9 +134,12 @@ capability in the user namespace of the thread
.TP
.B ESRCH
The thread whose ID is \fIpid\fP could not be found.
-.SH VERSIONS
-The CPU affinity system calls were introduced in Linux kernel 2.5.8.
-The system call wrappers were introduced in glibc 2.3.
+.SH STANDARDS
+Linux.
+.SH HISTORY
+Linux 2.5.8,
+glibc 2.3.
+.PP
Initially, the glibc interfaces included a
.I cpusetsize
argument, typed as
@@ -145,8 +148,6 @@ In glibc 2.3.3, the
.I cpusetsize
argument was removed, but was then restored in glibc 2.3.4, with type
.IR size_t .
-.SH STANDARDS
-These system calls are Linux-specific.
.SH NOTES
After a call to
.BR sched_setaffinity (),
@@ -350,50 +351,50 @@ sys 12.07
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
-
+\&
int
main(int argc, char *argv[])
{
int parentCPU, childCPU;
cpu_set_t set;
unsigned int nloops;
-
+\&
if (argc != 4) {
fprintf(stderr, "Usage: %s parent\-cpu child\-cpu num\-loops\en",
argv[0]);
exit(EXIT_FAILURE);
}
-
+\&
parentCPU = atoi(argv[1]);
childCPU = atoi(argv[2]);
nloops = atoi(argv[3]);
-
+\&
CPU_ZERO(&set);
-
+\&
switch (fork()) {
case \-1: /* Error */
err(EXIT_FAILURE, "fork");
-
+\&
case 0: /* Child */
CPU_SET(childCPU, &set);
-
+\&
if (sched_setaffinity(getpid(), sizeof(set), &set) == \-1)
err(EXIT_FAILURE, "sched_setaffinity");
-
+\&
for (unsigned int j = 0; j < nloops; j++)
getppid();
-
+\&
exit(EXIT_SUCCESS);
-
+\&
default: /* Parent */
CPU_SET(parentCPU, &set);
-
+\&
if (sched_setaffinity(getpid(), sizeof(set), &set) == \-1)
err(EXIT_FAILURE, "sched_setaffinity");
-
+\&
for (unsigned int j = 0; j < nloops; j++)
getppid();
-
+\&
wait(NULL); /* Wait for child to terminate */
exit(EXIT_SUCCESS);
}