Manual browser: pcu_discard(9)
|PCU(9)||Kernel Developer's Manual||PCU(9)|
NAMEpcu — per-CPU unit (PCU)
pcu_load(const pcu_ops_t *pcu);
pcu_save(const pcu_ops_t *pcu);
pcu_discard(const pcu_ops_t *pcu, bool valid);
pcu_valid_p(const pcu_ops_t *pcu);
DESCRIPTIONPer CPU Unit (PCU) is an interface to manage synchronization of any per-CPU context (unit) tied to an LWP context. Typical use of PCU is for "lazy-switch" synchronization of the FPU state. Each PCU has its operations defined by a pcu_ops_t structure. Members of pcu_ops_t are
u_int pcu_id; void (*pcu_state_save)(lwp_t *l); void (*pcu_state_load)(lwp_t *l, u_int flags); void (*pcu_state_release)(lwp_t *l);
- Indicate to MD code that the PCU state on the current CPU should be saved into the given LWP's MD storage.
Load PCU state from the given LWP's MD storage to the current CPU. The flags argument is a combination of one or more of the following:
- Indicate that the PCU state is considered valid and need not be initialized. This is the case if the PCU state was already used (and thus loaded) by the LWP and has not been discarded since.
- Indicate that a fault reoccurred while the PCU state is loaded, therefore PCU should be re-enabled. This happens if LWP is context switched to another CPU and then switched back to the original CPU while the state on that CPU has not been changed by other LWPs. It may also happen due to instruction "bouncing" on some architectures.
- Indicate to MD code that the PCU ownership by the LWP was released, therefore the next use of PCU on the LWP shall be detected and pcu_load() be called to reacquire the ownership. For example, this would normally be the changing of a bit for a CPU to trap on the execution of one of the PCU's instructions.
- Load or initialize the PCU state of the current LWP on the current CPU.
- Save the specified PCU state to the given LWP.
- Discard the specified PCU state of the current LWP. The PCU state will be considered invalid, unless the "valid" parameter is set to true.
- Return true if PCU state is considered valid. Generally, it always becomes "valid" when pcu_load() is called by the LWP. Otherwise, return false.
- Discard all PCU states of the given LWP; generally used by exec and exit.
- Save all PCU states of the given LWP; generally used during new LWP creation so that the PCU state of the parent could be copied.
CODE REFERENCESpcu is implemented within the file sys/kern/subr_pcu.c.
HISTORYPCU first appeared in NetBSD 6.0.
|May 25, 2014||NetBSD 7.0|