PCU(9) |
Kernel Developer's Manual |
PCU(9) |
NAME
pcu — per-CPU unit (PCU)
SYNOPSIS
#include <sys/pcu.h>
void
pcu_load(const pcu_ops_t *pcu);
void
pcu_save(const pcu_ops_t *pcu);
void
pcu_save_all(lwp_t *l);
void
pcu_discard(const pcu_ops_t *pcu);
bool
pcu_used_p(const pcu_ops_t *pcu);
DESCRIPTION
Per 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" synchronisation of 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, bool used);
void (*pcu_state_release)(lwp_t *l);
-
pcu_state_save()
-
save the current CPU's state into the given LWP's MD storage.
-
pcu_state_load()
-
load PCU state from the given LWP's MD storage to the current CPU. The used argument is true if it is not the first time the LWP uses the PCU.
-
pcu_state_release()
-
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 ownership. For example, this would often be the changing of a bit for a CPU to trap on the execution of one of the PCU's instructions.
FUNCTIONS
-
pcu_load()
-
Load (initialize) the PCU state of the current LWP on the current CPU.
-
pcu_save()
-
Save the specified PCU state to the given LWP.
-
pcu_discard()
-
Discard the specified PCU state of the current LWP.
-
pcu_used_p()
-
Return true if PCU was used (i.e. pcu_load() was called) by the LWP. Otherwise, return false.
-
pcu_save_all()
-
Save all PCU state of the given LWP, so that it could be used later.
CODE REFERENCES
pcu is implemented within the file sys/kern/subr_pcu.c.
HISTORY
PCU first appeared in NetBSD 6.0.