summaryrefslogtreecommitdiffstats
path: root/man3/pthread_setaffinity_np.3
diff options
context:
space:
mode:
Diffstat (limited to 'man3/pthread_setaffinity_np.3')
-rw-r--r--man3/pthread_setaffinity_np.346
1 files changed, 22 insertions, 24 deletions
diff --git a/man3/pthread_setaffinity_np.3 b/man3/pthread_setaffinity_np.3
index a85a56e63..112317ded 100644
--- a/man3/pthread_setaffinity_np.3
+++ b/man3/pthread_setaffinity_np.3
@@ -4,7 +4,7 @@
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
-.TH pthread_setaffinity_np 3 2022-12-15 "Linux man-pages 6.03"
+.TH pthread_setaffinity_np 3 2023-07-20 "Linux man-pages 6.05.01"
.SH NAME
pthread_setaffinity_np, pthread_getaffinity_np \- set/get
CPU affinity of a thread
@@ -94,29 +94,34 @@ is smaller than the size of the affinity mask used by the kernel.
No thread with the ID
.I thread
could be found.
-.SH VERSIONS
-These functions are provided since glibc 2.3.4.
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
-.ad l
-.nh
.TS
allbox;
lbx lb lb
l l l.
Interface Attribute Value
T{
+.na
+.nh
.BR pthread_setaffinity_np (),
.BR pthread_getaffinity_np ()
T} Thread safety MT-Safe
.TE
-.hy
-.ad
.sp 1
.SH STANDARDS
-These functions are nonstandard GNU extensions;
+GNU;
hence the suffix "_np" (nonportable) in the names.
+.SH HISTORY
+glibc 2.3.4.
+.PP
+In glibc 2.3.3 only,
+versions of these functions were provided that did not have a
+.I cpusetsize
+argument.
+Instead the CPU set size given to the underlying system calls was always
+.IR sizeof(cpu_set_t) .
.SH NOTES
After a call to
.BR pthread_setaffinity_np (),
@@ -137,13 +142,6 @@ and
.BR sched_getaffinity (2)
system calls.
.PP
-In glibc 2.3.3 only,
-versions of these functions were provided that did not have a
-.I cpusetsize
-argument.
-Instead the CPU set size given to the underlying system calls was always
-.IR sizeof(cpu_set_t) .
-.PP
A new thread created by
.BR pthread_create (3)
inherits a copy of its creator's CPU affinity mask.
@@ -164,37 +162,37 @@ to check the resulting CPU affinity mask of the thread.
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
-
+\&
int
main(void)
{
int s;
cpu_set_t cpuset;
pthread_t thread;
-
+\&
thread = pthread_self();
-
+\&
/* Set affinity mask to include CPUs 0 to 7. */
-
+\&
CPU_ZERO(&cpuset);
for (size_t j = 0; j < 8; j++)
CPU_SET(j, &cpuset);
-
+\&
s = pthread_setaffinity_np(thread, sizeof(cpuset), &cpuset);
if (s != 0)
errc(EXIT_FAILURE, s, "pthread_setaffinity_np");
-
+\&
/* Check the actual affinity mask assigned to the thread. */
-
+\&
s = pthread_getaffinity_np(thread, sizeof(cpuset), &cpuset);
if (s != 0)
errc(EXIT_FAILURE, s, "pthread_getaffinity_np");
-
+\&
printf("Set returned by pthread_getaffinity_np() contained:\en");
for (size_t j = 0; j < CPU_SETSIZE; j++)
if (CPU_ISSET(j, &cpuset))
printf(" CPU %zu\en", j);
-
+\&
exit(EXIT_SUCCESS);
}
.EE