哪些任务与Linux内核调度程序相对应? [英] Which tasks correspond to the Linux kernel scheduler?

查看:95
本文介绍了哪些任务与Linux内核调度程序相对应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux内核级别,我们具有线程/任务(属于内核和用户),例如,

In Linux at Kernel level we have threads/tasks (belonging to Kernel and user), e.g.,

swapper:是内核线程(进程0),是所有进程的始祖,在Linux的初始化阶段由start_kernel()函数从头开始创建.还有

swapper: is a kernel thread (process 0), the ancestor of all processes, created from scratch during the initialization phase of Linux by the start_kernel() function. Also

init:另一个内核线程,进程1(init进程)

init: an additional kernel thread, process 1 (init process)

HelloWorld:用户程序的线程

HelloWorld: A thread for user program

我的问题是有关内核调度程序的,它执行以下工作:

My question is about the Kernel scheduler, that performs the following jobs:

-在固定的时间内安排任务(即上下文切换)

-Schedule tasks within a fixed amount of time (i.e. context-switching)

-动态计算时间片(基于长/短vs优先级)

-Calculate the timeslices dynamically (short/long vs priority based)

-(在需要时)动态分配流程优先级

-Assigns process priorities dynamically (when needed)

-监控其工作流程 (这还包括吗?)

-Monitoring the processes to its jobs (does this include any further?)

更具体地说,我的问题变成:内核级别上的哪个线程/任务与调度程序相对应?应该是调度程序"等吗?还是内核中的其他任何任务都能完成工作?

More specifically my questions becomes: Which thread/task(s) at Kernel level correspond to the scheduler? Should it be 'scheduler' etc or Does any other task from kernel do its job?

P.S .:

内核中的交换器"是具有最低优先级(暂停)[1]的空闲线程/任务.除了降压"以外,这还有什么作用吗?

"swapper" in kernel is an idle thread/task with lowest priority (halt) [1]. Does this do anything other than "step-down"?

Linux是否为多核系统中的每个核创建专用的调度程序实例?如果没有,那么如何在多核上运行?

Does Linux create a dedicated instance of scheduler for each core in multi-core system? If no, then how it does on multicore?

[1] 为什么我们需要在其中执行交换任务linux?

推荐答案

Linux调度程序没有与其对应的任务或线程.当用于调度的计时器发出中断或在内核代码中显式调用该中断时(例如,作为系统调用的一部分),将运行Linux调度程序代码(主要是schedule()函数).

The Linux scheduler does not have a task or thread corresponding to it. The Linux scheduler code, mainly the schedule() function, is run when the timer used for scheduling issues an interrupt or when it is explicitly called in the kernel code (e.g. as part of a system call).

在多核上,调度程序代码在每个核上独立运行.通常,通过使用IPI(处理器间中断)将内核0上收到的定时器中断广播给其他内核.如果平台具有每CPU计时器,那么Linux通常会使用这些计时器发出调度所需的中断,而不是使用IPI.

On multicore, the scheduler code is run independently on each core. The timer interrupt received on Core 0 is usually broadcast by using IPIs (Inter-Processor Interrupts) to the other cores. If the platform has per CPU timers, then Linux usually uses these to issue the interrupt required for scheduling instead of using IPIs.

这篇关于哪些任务与Linux内核调度程序相对应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆