aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--man3/CPU_SET.332
1 files changed, 30 insertions, 2 deletions
diff --git a/man3/CPU_SET.3 b/man3/CPU_SET.3
index 7046fde3de..5fe9838423 100644
--- a/man3/CPU_SET.3
+++ b/man3/CPU_SET.3
@@ -82,6 +82,13 @@ CPU sets are used by
.BR sched_setaffinity (2)
and similar interfaces.
+The
+.I cpu_set_t
+data type is implemented as a bitset.
+However, the data structure treated as considered opaque:
+all manipulation of CPU sets should be done via the macros
+described in this page.
+
The following macros are provided to operate on the CPU set
.IR set :
.TP 17
@@ -177,9 +184,9 @@ in the range 0 to
Return the size in bytes of the CPU set that would be needed to
hold CPUs in the range 0 to
.IR num_cpus-1 .
-This macro provides the value that can be used for
+This macro provides the value that can be used for the
.I setsize
-in the
+argument in the
.BR CPU_*_S ()
macros described below.
.TP
@@ -255,6 +262,27 @@ and
first appeared in glibc 2.7.
.SH "CONFORMING TO"
These interfaces are Linux-specific.
+.SH NOTES
+To duplicate a CPU set, use
+.BR memcpy (3).
+
+Since CPU sets are bitsets allocated in units of long words,
+the actual number of CPUs in a dynamically
+allocated CPU set will be rounded up to the next multiple of
+.IR "sizeof(unsigned long)" .
+An application should consider the contents on these extra bits
+to be undefined.
+
+Note that the constant
+.B CPU_SETSIZE
+indicated the number of CPUs in the
+.I cpu_set_t
+data type (thus, it is effectively a count of bits in the bitset),
+while the
+.I setsize
+argument of the
+.BR CPU_*_S ()
+macros is a size in bytes.
.SH EXAMPLE
The following program demonstrates the use of some of the macros
used for dynamically allocated CPU sets.