aboutsummaryrefslogtreecommitdiffstats
path: root/man3
diff options
context:
space:
mode:
authorMichael Kerrisk <mtk.manpages@gmail.com>2008-11-13 21:56:39 -0500
committerMichael Kerrisk <mtk.manpages@gmail.com>2008-11-25 20:53:59 -0500
commit69241990531c46cde47ae7312abdac3d317d6e51 (patch)
tree1416d4e9eaecde79032c6079e57163e2b8f7030a /man3
parentb62e3548228be55c9b46f4b26f90a7065cd05090 (diff)
downloadman-pages-69241990531c46cde47ae7312abdac3d317d6e51.tar.gz
CPU_SET.3: Various improvements in DESCRIPTION
After review comments by Bert Wesarg: * Explain that cpu_set_t is a bitset, but should be considered opaque. * A CPU set can be duplicated with memset(). * Size of a CPU set is rounded up to size of long. * CPU_SETSIZE is in bits, but the setsize argument is in bytes. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com> Reported-by: Bert Wesarg <bert.wesarg@googlemail.com> Reviewed-by: Bert Wesarg <bert.wesarg@googlemail.com>
Diffstat (limited to 'man3')
-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.