Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux kernel 当队列中没有任务时,linux调度程序返回什么_Linux Kernel_Scheduler - Fatal编程技术网

Linux kernel 当队列中没有任务时,linux调度程序返回什么

Linux kernel 当队列中没有任务时,linux调度程序返回什么,linux-kernel,scheduler,Linux Kernel,Scheduler,linux调度程序调用调度程序算法,该算法在任务列表中查找下一个任务 如果没有剩余任务,调度算法返回什么 下面是一段代码 struct rt_info*sched_something(struct list_head*head,int标志) { /*一些逻辑*/ 返回一些_task;//如果没有剩余任务,任务的值是多少。 } 有一个特殊的“空闲”任务,PID=0,有时它被称为交换程序()。当没有其他任务准备运行时,此任务被调度到CPU核心。有几个空闲任务-每个CPU核心一个 Sourcekern

linux调度程序调用调度程序算法,该算法在任务列表中查找下一个任务

如果没有剩余任务,调度算法返回什么

下面是一段代码

struct rt_info*sched_something(struct list_head*head,int标志)
{
/*一些逻辑*/
返回一些_task;//如果没有剩余任务,任务的值是多少。
}

有一个特殊的“空闲”任务,PID=0,有时它被称为
交换程序
()。当没有其他任务准备运行时,此任务被调度到CPU核心。有几个空闲任务-每个CPU核心一个

Source
kernel/sched/core.c

因此,指向此任务的指针存储在runqueue(
struct rq
)中:

sched/core.c中有一些init代码:

4517 /**
4518  * init_idle - set up an idle thread for a given CPU
4519  * @idle: task in question
4520  * @cpu: cpu the idle task belongs to
4524  */
4525 void init_idle(struct task_struct *idle, int cpu)
我认为,空闲任务将运行某种带有特殊asm命令的循环,以通知CPU核心没有有用的作业

这篇文章说空闲任务执行
cpu\u idle\u loop
(可能有用于arch和cpu的自定义版本的loop-使用->):

早期空闲:“
rest_init(){/*init进程,pid=1*/kernel_线程(init,NULL,CLONE_FS | CLONE_文件| CLONE_信号);unlock_kernel();current->need_resched=1;/*空闲进程,pid=0*/cpu_idle();/*永不返回*/}
”“
/*在空闲循环中使用;sti需要一个指令周期来完成*/#define safe_halt()uuu asm_uuu_uuvolatile_uu(“sti;hlt”)::::“内存”)CPU将在从中断处理程序返回时使用“hlt”后面的指令恢复代码执行。
“另外”该列表用于优先排序不同类型的任务。。。完整列表如下所示:stop_sched_类→ rt_sched_类→ 普通班→ 空闲调度类→ 空停止和空闲是特殊的调度类。Stop用于调度每cpu停止任务,该任务先占所有内容,可以不先占任何内容,Idle用于调度每cpu空闲任务(也称为交换任务),该任务在没有其他任务可运行的情况下运行。“谢谢osgx:)这就是我要找的。
502  * This is the main, per-CPU runqueue data structure. ...  */
508 struct rq {
557         struct task_struct *curr, *idle, *stop;
4517 /**
4518  * init_idle - set up an idle thread for a given CPU
4519  * @idle: task in question
4520  * @cpu: cpu the idle task belongs to
4524  */
4525 void init_idle(struct task_struct *idle, int cpu)
 40 #define cpu_relax()     asm volatile("rep; nop")
 45 static inline int cpu_idle_poll(void)
 ..
 50         while (!tif_need_resched())
 51                 cpu_relax();

221                         if (cpu_idle_force_poll || tick_check_broadcast_expired())
222                                 cpu_idle_poll();
223                         else
224                                 cpuidle_idle_call();