cpuset(3) - Linux man page
Name
cpuset - manipulate sets of CPUs portablySynopsis
- cpuset_t*
- cpuset_alloc(void)
- void
- cpuset_copy(cpuset_t* dest, cpuset_t*src)
- void
- cpuset_free(cpuset_t* setp)
- void
- cpuset_init(cpuset_t*setp)
- int
- cpuset_get_cpu(cpuset_t* setp, cpu_t cpu)
- void
- cpuset_negate(cpuset_t*setp)
- void
- cpuset_set_cpu(cpuset_t*setp, cpu_t cpu, int state)
- int
- cpuset_is_empty(cpuset_t*setp)
- int
- cpuset_is_eq(cpuset_t* setp1 cpuset_t* setp2)
- int
- cpuset_is_full(cpuset_t*setp)
- int
- cpuset_is_valid_cpu(cpu_t cpu)
- int
- cpuset_count(cpuset_t* setp)
- char*
- cpuset_get_string(cpuset_t* setp)
- void
- cpuset_set_string(cpuset_t*setp, char* hexstr)
- cpuset_t*
- cpuset_and(cpuset_t* setp1, cpuset_t* setp2)
- cpuset_t*
- cpuset_or(cpuset_t* setp1, cpuset_t* setp2)
- cpuset_t*
- cpuset_xor(cpuset_t* setp1, cpuset_t* setp2)
- void
- cpuset_and_eq(cpuset_t* setp1, cpuset_t* setp2)
- void
- cpuset_or_eq(cpuset_t* setp1, cpuset_t* setp2)
- void
- cpuset_xor_eq(cpuset_t* setp1, cpuset_t* setp2)
- cpu_t
- cpuset_max_cpu(void)
- cpu_t
- cpuset_min_cpu(void)
gcc [options...] file -lmpadvise ...
Description
These functions allow sets of CPUs to be manipulated portably as follows:- cpuset_alloc()
- Dynamically create a CPU set object.
- cpuset_copy()
- Copy the contents of one CPU set object to another.
- cpuset_free()
- Dynamically destroy a previously allocated CPU set object.
- cpuset_init()
- Initialize a CPU set object to the empty set.
- cpuset_get_cpu()
- Get the state of an individual CPU in a CPU set.
- cpuset_negate()
- Negate the CPU set. This inverts the state of each CPU in the CPU set.
- cpuset_set_cpu()
- Set or clear individual CPUs within the CPU set using a state of 1 or 0 respectively.
- cpuset_is_empty()
- Compare the CPU set to the empty set.
- cpuset_is_eq()
- Compare two CPU sets for equality.
- cpuset_is_full()
- Compare the CPU set to the complete set.
- cpuset_is_valid()
- Test a logical CPU identifier to see if it is supported by the current CPU set implementation.
- A successful test does not imply that the current system supports the CPU,
- only that it is within the limits imposed by the current CPU set implementation.
- cpuset_count()
- Return the count of the number of CPUs that are currently set in the specified CPU set.
- cpuset_get_string()
- Obtain a human readable hexadecimal mask string representing the specified object's CPU set. The length of the string is implementation defined and should not be assumed to be fixed (use of strlen() is recommended). The returned string must be freed when done (calling cpuset_free()).
- cpuset_set_string()
- Set a CPU object to correspond to a specified hexadecimal mask string.
- cpuset_and()
- Perform a bitwise AND operation on setp1 and setp2. This function allocates a new cpuset_t to store the results, and returns a pointer to the newly allocated cpuset_t. You must call cpuset_free() on the returned cpuset_t when the results are no longer needed.
- cpuset_or()
- Perform a bitwise OR operation on setp1 and setp2. This function allocates a new cpuset_t to store the results, and returns a pointer to the newly allocated cpuset_t. You must call cpuset_free() on the returned cpuset_t when the results are no longer needed.
- cpuset_xor()
- Perform a bitwise XOR operation on setp1 and setp2. This function allocates a new cpuset_t to store the results, and returns a pointer to the newly allocated cpuset_t. You must call cpuset_free() on the returned cpuset_t when the results are no longer needed.
- cpuset_and_eq()
- Perform a bitwise AND operation on setp1 and setp2 and stores the results in setp1. No new cpuset_t objects are allocated by the function.
- cpuset_or_eq()
- Perform a bitwise OR operation on setp1 and setp2 and stores the results in setp1. No new cpuset_t objects are allocated by the function.
- cpuset_xor_eq()
- Perform a bitwise XOR operation on setp1 and setp2 and stores the results in setp1. No new cpuset_t objects are allocated by the function.
- cpuset_max_cpu()
- Return the highest CPU number in the range of CPUs supported by the cpuset implementation.
- cpuset_min_cpu()
- Return the lowest CPU number in the range of CPUs supported by the cpuset implementation (usually 0).
Options
- cpu
- Logical CPU identifier starting with zero.
- hexstr
- A null-terminated string of continuous hexadecimal ASCII characters that specify a mask which can be directly mapped to a CPU set.
- setp
- Pointer to a cpuset_t object.
- setp1
- Pointer to a cpuset_t object supplied as an argument. When using cpuset_and_eq(), cpuset_or_eq(), or cpuset_xor_eq(), this value also stores the results of the function.
- setp2
- Pointer to a cpuset_t object supplied as an argument.
- state
- A boolean value indicating whether the specified CPU is present in the set or not.
Return Value
Functions that return boolean values return 1 for TRUE and 0 for FALSE.Errors
cpuset_alloc() returns NULL if space could not be allocated for the cpuset_t object. All other functions cannot fail.
Examples
Allocate a CPU set object:
cpuset_t* setp;
setp = cpuset_alloc();
Free a CPU set object:
cpuset_free(setp);
Initialize a CPU set object to the empty set:
cpuset_init(setp);
Test a CPU set object to see if it is the empty set:
if (cpuset_is_empty(setp)) {
/* empty */
} else {
/* not empty */
}
Initialize a CPU set object to the value corresponding to a mask string of hexadecimal characters:
cpuset_set_string(setp, "ffff");
Caveats
Although the cpuset_t typedef is available to the C programmer, it is cpuset implementation dependent and instances of the object should not be created directly. Instead, use the cpuset_alloc() and cpuset_free() functions.
Copyright
Copyright © 2002 Concurrent Computer Corporation. This source code is licensed under the GNU LGPL Version 2.1. Author: Jason Baietto (jason.baietto@ccur.com)