Manual Pages for Linux CentOS command on man CPU_XOR_S
MyWebUniversity

Manual Pages for Linux CentOS command on man CPU_XOR_S

CPUSET(3) Linux Programmer's Manual CPUSET(3)

NAME CPUSET, CPUCLR, CPUISSET, CPUZERO, CPUCOUNT, CPUAND, CPUOR, CPUXOR, CPUEQUAL, CPUALLOC, CPUALLOCSIZE, CPUFREE, CPUSETS, CPUCLRS, CPUISSETS, CPUZEROS, CPUCOUNTS, CPUANDS, CPUORS,

CPUXORS, CPUEQUALS - macros for manipulating CPU sets SYNOPSIS

#define GNUSOURCE /* See featuretestmacros(7) */

#include void CPUZERO(cpusett *set); void CPUSET(int cpu, cpusett *set); void CPUCLR(int cpu, cpusett *set); int CPUISSET(int cpu, cpusett *set); int CPUCOUNT(cpusett *set); void CPUAND(cpusett *destset, cpusett *srcset1, cpusett *srcset2); void CPUOR(cpusett *destset, cpusett *srcset1, cpusett *srcset2); void CPUXOR(cpusett *destset, cpusett *srcset1, cpusett *srcset2); int CPUEQUAL(cpusett *set1, cpusett *set2); cpusett *CPUALLOC(int numcpus); void CPUFREE(cpusett *set); sizet CPUALLOCSIZE(int numcpus); void CPUZEROS(sizet setsize, cpusett *set); void CPUSETS(int cpu, sizet setsize, cpusett *set); void CPUCLRS(int cpu, sizet setsize, cpusett *set); int CPUISSETS(int cpu, sizet setsize, cpusett *set); int CPUCOUNTS(sizet setsize, cpusett *set); void CPUANDS(sizet setsize, cpusett *destset, cpusett *srcset1, cpusett *srcset2); void CPUORS(sizet setsize, cpusett *destset, cpusett *srcset1, cpusett *srcset2); void CPUXORS(sizet setsize, cpusett *destset, cpusett *srcset1, cpusett *srcset2); int CPUEQUALS(sizet setsize, cpusett *set1, cpusett *set2); DESCRIPTION The cpusett data structure represents a set of CPUs. CPU sets are used by schedsetaffinity(2) and similar interfaces. The cpusett 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 set: CPUZERO() Clears set, so that it contains no CPUs. CPUSET() Add CPU cpu to set. CPUCLR() Remove CPU cpu from set. CPUISSET() Test to see if CPU cpu is a member of set. CPUCOUNT() Return the number of CPUs in set. Where a cpu argument is specified, it should not produce side effects, since the above macros may evaluate the argument more than once. The first available CPU on the system corresponds to a cpu value of 0, the next CPU corresponds to a cpu value of 1, and so on. The constant CPUSETSIZE (currently 1024) specifies a value one greater than the maximum CPU number that can be stored in cpusett. The following macros perform logical operations on CPU sets: CPUAND() Store the intersection of the sets srcset1 and srcset2 in destset (which may be one of the source sets). CPUOR() Store the union of the sets srcset1 and srcset2 in destset (which may be one of the source sets). CPUXOR() Store the XOR of the sets srcset1 and srcset2 in dest‐ set (which may be one of the source sets). The XOR means the set of CPUs that are in either srcset1 or srcset2, but not both. CPUEQUAL() Test whether two CPU set contain exactly the same CPUs. Dynamically sized CPU sets Because some applications may require the ability to dynamically size CPU sets (e.g., to allocate sets larger than that defined by the stan‐ dard cpusett data type), glibc nowadays provides a set of macros to support this. The following macros are used to allocate and deallocate CPU sets: CPUALLOC() Allocate a CPU set large enough to hold CPUs in the

range 0 to numcpus-1. CPUALLOCSIZE() Return the size in bytes of the CPU set that would be

needed to hold CPUs in the range 0 to numcpus-1. This macro provides the value that can be used for the setsize argument in the CPU*S() macros described below. CPUFREE() Free a CPU set previously allocated by CPUALLOC(). The macros whose names end with "S" are the analogs of the similarly named macros without the suffix. These macros perform the same tasks as their analogs, but operate on the dynamically allocated CPU set(s) whose size is setsize bytes. RETURN VALUE CPUISSET() and CPUISSETS() return nonzero if cpu is in set; other‐ wise, it returns 0. CPUCOUNT() and CPUCOUNTS() return the number of CPUs in set. CPUEQUAL() and CPUEQUALS() return nonzero if the two CPU sets are equal; otherwise it returns 0. CPUALLOC() returns a pointer on success, or NULL on failure. (Errors are as for malloc(3).) CPUALLOCSIZE() returns the number of bytes required to store a CPU set of the specified cardinality. The other functions do not return a value. VERSIONS The CPUZERO(), CPUSET(), CPUCLR(), and CPUISSET() macros were added in glibc 2.3.3. CPUCOUNT() first appeared in glibc 2.6. CPUAND(), CPUOR(), CPUXOR(), CPUEQUAL(), CPUALLOC(), CPUALLOCSIZE(), CPUFREE(), CPUZEROS(), CPUSETS(), CPUCLRS(), CPUISSETS(), CPUANDS(), CPUORS(), CPUXORS(), and CPUEQUALS() first appeared in glibc 2.7. CONFORMING TO

These interfaces are Linux-specific. NOTES To duplicate a CPU set, use 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 sizeof(unsigned long). An application should con‐ sider the contents of these extra bits to be undefined. Notwithstanding the similarity in the names, note that the constant CPUSETSIZE indicates the number of CPUs in the cpusett data type (thus, it is effectively a count of bits in the bitset), while the set‐ size argument of the CPU*S() macros is a size in bytes. The data types for arguments and return values shown in the SYNOPSIS are hints what about is expected in each case. However, since these interfaces are implemented as macros, the compiler won't necessarily catch all type errors if you violate the suggestions. BUGS

On 32-bit platforms with glibc 2.8 and earlier, CPUALLOC() allocates twice as much space as is required, and CPUALLOCSIZE() returns a value twice as large as it should. This bug should not affect the semantics of a program, but does result in wasted memory and less effi‐ cient operation of the macros that operate on dynamically allocated CPU sets. These bugs are fixed in glibc 2.9. EXAMPLE The following program demonstrates the use of some of the macros used for dynamically allocated CPU sets.

#define GNUSOURCE

#include

#include

#include

#include

#include int main(int argc, char *argv[]) { cpusett *cpusetp; sizet size; int numcpus, cpu; if (argc < 2) {

fprintf(stderr, "Usage: %s \n", argv[0]); exit(EXITFAILURE); } numcpus = atoi(argv[1]); cpusetp = CPUALLOC(numcpus); if (cpusetp == NULL) { perror("CPUALLOC"); exit(EXITFAILURE); } size = CPUALLOCSIZE(numcpus); CPUZEROS(size, cpusetp); for (cpu = 0; cpu < numcpus; cpu += 2) CPUSETS(cpu, size, cpusetp);

printf("CPUCOUNT() of set: %d\n", CPUCOUNTS(size, cpusetp)); CPUFREE(cpusetp); exit(EXITSUCCESS); } SEE ALSO schedsetaffinity(2), pthreadattrsetaffinitynp(3), pthreadsetaffin‐ itynp(3), cpuset(7) COLOPHON

This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can

be found at http://www.kernel.org/doc/man-pages/.

Linux 2012-03-15 CPUSET(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™