MCPcopy Create free account
hub / github.com/Simple-XX/SimpleKernel / test_cfs_preemption

Function test_cfs_preemption

tests/system_test/cfs_scheduler_test.cpp:184–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184auto test_cfs_preemption() -> bool {
185 klog::Info("Running test_cfs_preemption...");
186
187 CfsScheduler scheduler;
188
189 TaskControlBlock task1("Task1", 1, nullptr, nullptr);
190 task1.sched_data.cfs.weight = CfsScheduler::kDefaultWeight;
191 task1.sched_data.cfs.vruntime = 1000;
192
193 TaskControlBlock task2("Task2", 2, nullptr, nullptr);
194 task2.sched_data.cfs.weight = CfsScheduler::kDefaultWeight;
195 task2.sched_data.cfs.vruntime = 0; // 更小的 vruntime
196
197 scheduler.Enqueue(&task2);
198
199 // task1 运行时,应该被抢占
200 bool should_preempt = scheduler.OnTick(&task1);
201 EXPECT_TRUE(should_preempt, "Task with higher vruntime should be preempted");
202
203 klog::Info("test_cfs_preemption passed");
204 return true;
205}
206
207auto test_cfs_no_preemption() -> bool {
208 klog::Info("Running test_cfs_no_preemption...");

Callers 1

cfs_scheduler_testFunction · 0.85

Calls 3

InfoFunction · 0.85
EnqueueMethod · 0.45
OnTickMethod · 0.45

Tested by

no test coverage detected