-
Avi Kivity authored
Per-cpu variables can be used from contexts where preemption is disabled (such as interrupts) or when migration is impossible (pinned threads) for managing data that is replicated for each cpu. The API is a smart pointer to a variable which resolves to the object's location on the current cpu. Define: #include <osv/percpu.hh> PERCPU(int, my_counter); PERCPU(foo, my_foo); Use: ++*my_counter; my_foo->member = 7;
Avi Kivity authoredPer-cpu variables can be used from contexts where preemption is disabled (such as interrupts) or when migration is impossible (pinned threads) for managing data that is replicated for each cpu. The API is a smart pointer to a variable which resolves to the object's location on the current cpu. Define: #include <osv/percpu.hh> PERCPU(int, my_counter); PERCPU(foo, my_foo); Use: ++*my_counter; my_foo->member = 7;