gpt4 book ai didi

linux - 警报 Linux 的实时 FIFO 调度程序

转载 作者:太空宇宙 更新时间:2023-11-04 03:56:42 25 4
gpt4 key购买 nike

我正在尝试更改 3.13.3 中实时调度程序的实现。据我所知,在实时先进先出调度中,内核只是保留一个具有相同优先级的进程队列,并将CPU分配给队列末尾(头)的进程,并将进程添加到尾部......我想在PCB结构(task_struct)中添加一个额外的字段,以便内核根据这个新字段对队列进行排序。假设我们将这个新字段定义为 int extra_priority ,我希望每当从队列中选择下一个进程来执行时,内核都会优先考虑具有更高 extra_priority 的进程...我想知道,整个“从队列中弹出进程”和“将新进程推到队列尾部”发生在哪里?因此,每当队列发生变化时,我都可以调用“sort by extra_priority”,以保持队列始终排序。

最佳答案

我没有修改实时进程的进程调度。根据理解 Linux 内核一书中的以下段落,您可以通过修改 scheduler_tick() 函数来改变实时 FIFO 进程的顺序来实现这一点。

Updating the time slice of a real-time process

If the current process is a FIFO real-time process, scheduler_tick() has nothing to do. In this case, in fact, current cannot be preempted by lower or equal priority processes, thus it does not make sense to keep its time slice counter up-to-date. If current is a Round Robin real-time process, scheduler_tick() decreases its time slice counter and checks whether the quantum is exhausted:

if (current->policy == SCHED_RR && !--current->time_slice) {
current->time_slice = task_timeslice(current);
current->first_time_slice = 0;
set_tsk_need_resched(current);
list_del(&current->run_list);
list_add_tail(&current->run_list,
this_rq()->active->queue+current->prio);
}

关于linux - 警报 Linux 的实时 FIFO 调度程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24453234/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com