5#ifndef SIMPLEKERNEL_TESTS_UNIT_TEST_MOCKS_TEST_ENVIRONMENT_STATE_HPP_
6#define SIMPLEKERNEL_TESTS_UNIT_TEST_MOCKS_TEST_ENVIRONMENT_STATE_HPP_
12#include <unordered_map>
void ClearCurrentThreadEnvironment()
清除当前线程的环境实例指针
void UnregisterTaskContext(void *context_ptr)
注销任务上下文
TestEnvironmentState(const TestEnvironmentState &)=delete
auto FindTaskByContext(void *context_ptr) -> TaskControlBlock *
通过上下文指针查找任务
auto GetCore(size_t core_id) -> CoreEnvironment &
获取指定核心的环境
std::unordered_map< std::thread::id, size_t > thread_to_core_map_
void BindThreadToCore(std::thread::id tid, size_t core_id)
将指定线程绑定到核心
void InitializeCores(size_t num_cores)
初始化指定数量的核心
auto GetAllSwitchHistory() const -> std::vector< CoreEnvironment::SwitchEvent >
获取所有核心的切换历史,按时间戳排序
static auto GetCurrentThreadEnvironment() -> TestEnvironmentState *
获取当前线程的环境实例指针(供 Mock 层调用)
TestEnvironmentState(TestEnvironmentState &&)=delete
void ClearSwitchHistory()
清空所有核心的切换历史
void DumpAllCoreStates() const
打印所有核心的状态信息
~TestEnvironmentState()=default
void ResetAllCores()
重置所有核心状态(中断、页表、历史记录)
std::unordered_map< void *, TaskControlBlock * > context_to_task_map_
TestEnvironmentState()=default
auto GetCurrentCoreEnv() -> CoreEnvironment &
获取当前线程的核心环境
auto GetCoreIdForThread(std::thread::id tid) -> size_t
获取线程对应的核心 ID
auto GetCoreCount() const -> size_t
获取核心数量
void SetCurrentThreadEnvironment()
设置当前线程的环境实例指针
auto operator=(const TestEnvironmentState &) -> TestEnvironmentState &=delete
void RegisterTaskContext(void *context_ptr, TaskControlBlock *task)
注册任务上下文,建立上下文指针到任务的映射
auto operator=(TestEnvironmentState &&) -> TestEnvironmentState &=delete
std::vector< CoreEnvironment > cores_
CoreEnvironment(size_t id=0)
std::vector< SwitchEvent > switch_history
std::thread::id thread_id