SimpleKernel 1.17.0
Loading...
Searching...
No Matches
per_cpu.hpp File Reference
#include <cpu_io.h>
#include <etl/singleton.h>
#include <unistd.h>
#include <array>
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
Include dependency graph for per_cpu.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  per_cpu::PerCpu
 每个 CPU 核心的局部数据 More...
 

Namespaces

namespace  per_cpu
 

Typedefs

using per_cpu::PerCpuArraySingleton = etl::singleton< std::array< PerCpu, SIMPLEKERNEL_MAX_CORE_COUNT > >
 PerCpu 数组单例类型
 

Functions

struct per_cpu::PerCpu per_cpu::__attribute__ ((aligned(SIMPLEKERNEL_PER_CPU_ALIGN_SIZE)))
 
static __always_inline auto per_cpu::GetCurrentCore () -> PerCpu &
 获取当前核心的 PerCpu 数据
 
构造/析构函数
 PerCpu (size_t id)
 
 PerCpu ()=default
 
 PerCpu (const PerCpu &)=default
 
 PerCpu (PerCpu &&)=default
 
auto operator= (const PerCpu &) -> PerCpu &=default
 
auto operator= (PerCpu &&) -> PerCpu &=default
 
 ~PerCpu ()=default
 

Variables

size_t core_id {0}
 核心 ID
 
TaskControlBlockrunning_task {nullptr}
 当前运行的任务
 
TaskControlBlockidle_task {nullptr}
 空闲任务
 
CpuSchedDatasched_data {nullptr}
 调度数据 (RunQueue) 指针
 

Function Documentation

◆ operator=() [1/2]

auto __attribute__::operator= ( const PerCpu ) -> PerCpu &=default
default

◆ operator=() [2/2]

auto __attribute__::operator= ( PerCpu &&  ) -> PerCpu &=default
default

◆ PerCpu() [1/4]

__attribute__::PerCpu ( )
default

◆ PerCpu() [2/4]

__attribute__::PerCpu ( const PerCpu &  )
default

◆ PerCpu() [3/4]

__attribute__::PerCpu ( PerCpu &&  )
default

◆ PerCpu() [4/4]

__attribute__::PerCpu ( size_t  id)
explicit

Definition at line 12 of file per_cpu.hpp.

20{
21
23struct PerCpu {
25 size_t core_id{0};
26
32 CpuSchedData* sched_data{nullptr};
33
36 explicit PerCpu(size_t id) : core_id(id) {}
37
38 PerCpu() = default;
39 PerCpu(const PerCpu&) = default;
40 PerCpu(PerCpu&&) = default;
41 auto operator=(const PerCpu&) -> PerCpu& = default;
42 auto operator=(PerCpu&&) -> PerCpu& = default;
43 ~PerCpu() = default;
45} __attribute__((aligned(SIMPLEKERNEL_PER_CPU_ALIGN_SIZE)));
46
47static_assert(sizeof(PerCpu) <= SIMPLEKERNEL_PER_CPU_ALIGN_SIZE,
48 "PerCpu size should not exceed cache line size");
49
52 etl::singleton<std::array<PerCpu, SIMPLEKERNEL_MAX_CORE_COUNT>>;
53
55static __always_inline auto GetCurrentCore() -> PerCpu& {
56 return PerCpuArraySingleton::instance()[cpu_io::GetCurrentCoreId()];
57}
58
59} // namespace per_cpu
auto GetCurrentCoreId() -> size_t
Definition cpu_io.h:26
etl::singleton< std::array< PerCpu, SIMPLEKERNEL_MAX_CORE_COUNT > > PerCpuArraySingleton
PerCpu 数组单例类型
Definition per_cpu.hpp:52
struct per_cpu::PerCpu __attribute__((aligned(SIMPLEKERNEL_PER_CPU_ALIGN_SIZE)))
static __always_inline auto GetCurrentCore() -> PerCpu &
获取当前核心的 PerCpu 数据
Definition per_cpu.hpp:55
CpuSchedData * sched_data
调度数据 (RunQueue) 指针
Definition per_cpu.hpp:8
~PerCpu()=default
TaskControlBlock * idle_task
空闲任务
Definition per_cpu.hpp:6
TaskControlBlock * running_task
当前运行的任务
Definition per_cpu.hpp:4
size_t core_id
核心 ID
Definition per_cpu.hpp:1
PerCpu()=default
auto operator=(const PerCpu &) -> PerCpu &=default
每个核心的调度数据 (RunQueue)
任务控制块,管理进程/线程的核心数据结构

◆ ~PerCpu()

__attribute__::~PerCpu ( )
default

Variable Documentation

◆ core_id

size_t core_id {0}

核心 ID

Definition at line 1 of file per_cpu.hpp.

◆ idle_task

TaskControlBlock* idle_task {nullptr}

空闲任务

Definition at line 6 of file per_cpu.hpp.

◆ running_task

TaskControlBlock* running_task {nullptr}

当前运行的任务

Definition at line 4 of file per_cpu.hpp.

◆ sched_data

CpuSchedData* sched_data {nullptr}

调度数据 (RunQueue) 指针

Definition at line 8 of file per_cpu.hpp.