sysmgr_runstate(), sysmgr_runstate_dynamic()
Change the runstate of a processor
Synopsis:
#include <sys/sysmgr.h>
int sysmgr_runstate( unsigned cpu,
int enable );
int sysmgr_runstate_dynamic( unsigned cpu,
int enable );
Arguments:
- cpu
- The index of the CPU whose state you want to change.
- enable
- Zero to offline the processor; non-zero to bring it back online. For more details, see below.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The sysmgr_runstate() and sysmgr_runstate_dynamic() functions offline or online the specified CPU as follows:
- sysmgr_runstate() manually takes a CPU offline (if enable is zero) or brings it online (if one).
- sysmgr_runstate_dynamic() lets the kernel dynamically take a CPU on- or offline (if enable is one), depending on the system load.
These settings work together:
| Runstate | Dynamic runstate | Action |
|---|---|---|
| 0 | — | The CPU is permanently offline |
| 1 | 0 | The CPU is permanently online (the default) |
| 1 | 1 | The CPU is dynamically brought on- or offline by the kernel, depending on load. |
Note:
- In order to successfully change the state, your process must have the PROCMGR_AID_RUNSTATE ability enabled. For more information, see procmgr_ability().
- These functions don't turn the power on or off for the CPU;
they tell the kernel whether or not to schedule threads on it.
If you take a CPU offline, it sits on a
WFIinstruction (for ARM), or aHLTinstruction (for x86). If you want to turn the power off for an idle CPU, use InterruptHookIdle2() to register a callback that shuts it down.
You can use sysmgr_runstate_burst() to notify the kernel that it should bring CPUs online because the system is about to get busy.
Returns:
EOK on success. If an error occurs, the function can return any value listed in the Errors section.
Errors:
- EAGAIN
- A needed resource was unavailable.
- EINVAL
- The CPU bits included invalid bits.
- ENOMEM
- There was insufficient memory to complete the operation.
- EPERM
- The calling process doesn't have the required permission of PROCMGR_AID_RUNSTATE; see procmgr_ability().
Classification:
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | No |
| Signal handler | Yes |
| Thread | Yes |
Page updated:
