Module ostd::cpu::cpu_local

source ·
Expand description

CPU local storage.

This module provides a mechanism to define CPU-local objects.

This is acheived by placing the CPU-local objects in a special section .cpu_local. The bootstrap processor (BSP) uses the objects linked in this section, and these objects are copied to dynamically allocated local storage of each application processors (AP) during the initialization process.

Such a mechanism exploits the fact that constant values of non-[Copy] types can be bitwise copied. For example, a [Option<T>] object, though being not [Copy], have a constant constructor [Option::None] that produces a value that can be bitwise copied to create a new instance. [alloc::sync::Arc] however, don’t have such a constructor, and thus cannot be directly used as a CPU-local object. Wrapping it in a type that has a constant constructor, like [Option<T>], can make it CPU-local.

Structs§

Functions§

  • Initializes the CPU local data for the bootstrap processor (BSP).