#[repr(C)]struct Base {
config: *const Config,
arch: *const ArchConfig,
cpu: usize,
thread: *const Thread,
uma: *const Uma,
pmgr: *const ProcMgr,
}
Expand description
Implementation of pcpu
structure.
Access to this structure must be done by atomic reading or writing its field directly. It is not safe to have a temporary a pointer or reference to this struct or its field because the CPU might get interrupted, which mean it is possible for the next instruction to get executed on a different CPU if the interrupt cause the CPU to switch the task.
The activation of this struct is a minimum requirements for a new CPU to call most of the other
functions. The new CPU should call run_with_context()
as soon as possible. We don’t make the
functions that require this context as unsafe
nor make it check for the context because it
will be (almost) all of it. So we impose this requirement on a function that setup a CPU
instead.
Beware for any type that implement Drop
because it may access the CPU context. For maximum
safety the CPU setup function must not cause any value of the kernel type to drop before
context is activated. It is safe to drop values of Rust core type (e.g. String
) only on a
main CPU because the only kernel functions it can call into is either stage 1 allocator or
panic handler, both of them does not require a CPU context.
Fields§
§config: *const Config
§arch: *const ArchConfig
§cpu: usize
§thread: *const Thread
§uma: *const Uma
§pmgr: *const ProcMgr