|
|
#include <sys/types.h> #include <sys/processor.h>
int p_online(processorid_t processorid, int flag);
The processor specified by the first argument is set on-line or off-line or is unchanged, depending on whether the flag argument is P_ONLINE, P_OFFLINE, or P_STATUS.
When P_ONLINE is specified and the processor is off-line, the processor is brought on-line and allowed to process LWPs (lightweight processes) and perform system activities.
When P_ONLINE or P_OFFLINE is specified and the processor is powered off, it is powered on. In the P_ONLINE case, the processor is also brought on-line and allowed to process LWPs (lightweight processes) and perform system activities.
When P_OFFLINE is specified and the processor is on-line, it is taken off-line and not allowed to process LWPs. The processor will become as inactive as possible.
When P_STATUS is specified, no change occurs, but the current status is returned.
Processor numbers are integers, greater than or equal to 0, and are defined by the hardware platform. Processor numbers are not necessarily contiguous, but ``not too sparse.'' Processor numbers should always be printed in decimal.
The number of processors present can be determined by calling sysconf(_SC_NPROCESSORS_CONF). The list of valid processor numbers can be determined by calling p_online() with processorid values starting at 0 until all processors have been found. The EINVAL error is returned for invalid processor numbers. See EXAMPLES below.
#include <sys/unistd.h>
#include <sys/processor.h>
#include <sys/types.h>
#include <stdio.h>
#include <errno.h>
int
main()
{
processorid_t i;
int status;
int n = sysconf(_SC_NPROCESSORS_ONLN);
for (i = 0; n > 0; i++) {
status = p_online(i, P_STATUS);
if (status == -1 && errno == EINVAL)
continue;
printf("processor %d present\n", i);
n--;
}
return (0);
}
|
|
Created by unroff & hp-tools. © by Hans-Peter Bischof. All Rights Reserved (1997).
Last modified 07/October/97