aboutsummaryrefslogtreecommitdiffstats
path: root/man2/sched_setaffinity.2
diff options
context:
space:
mode:
Diffstat (limited to 'man2/sched_setaffinity.2')
-rw-r--r--man2/sched_setaffinity.226
1 files changed, 13 insertions, 13 deletions
diff --git a/man2/sched_setaffinity.2 b/man2/sched_setaffinity.2
index 01e4a4f9e5..958d14cd2a 100644
--- a/man2/sched_setaffinity.2
+++ b/man2/sched_setaffinity.2
@@ -351,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);
}