简体   繁体   English

如何确定任务是否在Linux内核中绑定了I / O?

[英]How to find out whether task is I/O bound in linux kernel?

I am trying to implement scheduler for linux kernel ( version 2.4.27 ) and I am trying to find out whether a task is CPU bound or I/O bound. 我正在尝试为Linux内核( version 2.4.27 )实现调度程序,并且试图找出某个任务是受CPU约束还是受I / O约束。 Are there any variables/function which I can use to get this information? 我可以使用任何变量/函数来获取此信息吗?

If talking about O(1) Scheduler: 如果谈论O(1)Scheduler:

A process can be determined as CPU bound or I/O bound based on the timeslice it runs on the CPU. 可以根据进程在CPU上运行的时间片将其确定为CPU绑定或I / O绑定。

Every process will have its default timeslice(100ms) set before allowing it to be scheduled on a processor. 每个进程都将设置其默认时间片(100ms),然后才能在处理器上进行调度。

A process is called a CPU bound process, if the very process consumes full time slice(runs for the entire time slice on the processor). 如果一个进程占用了整个时间片(在处理器上的整个时间片上运行),则该进程称为CPU绑定进程。

Similarly, any process that doesn't consume its entire timeslice, but would call sched_yield even before its timeslice has run-out, or , if the process waits/sleeps for any event to occur, then the scheduler will be invoked to push it to sleeping queue, which means it is waiting for some I/O to happen, is an I/O bound process. 同样,任何不消耗整个时间片的进程,甚至会在其时间片用完之前调用sched_yield, 或者 ,如果该进程等待/休眠任何事件的发生,则将调用调度程序将其推送到睡眠队列是一个受I / O约束的进程,它表示它正在等待某些I / O发生。

Every such CPU bound process will be penalized with priority, keeping the time slice same, and every such I/O bound process will be appreciated with a bonus of priority, keeping the time slice same. 每个此类受CPU限制的进程都将受到优先级的惩罚,保持时间片相同,而每个此类受I / O绑定的进程将受到优先级的奖励,使时间片保持相同。

So, on an GPOS(General Purpose Operating System), it is the effective_priority or dynamic_priority, that will tell you if the process is well-behaved(I/O bound) or ill-behaved(CPU bound process), as the default priority will be 20 for a new process, unless it is altered otherwise. 因此,在GPOS(通用操作系统)上,是valid_priority或dynamic_priority,它将告诉您该进程是行为良好的(I / O绑定)还是行为不良的(CPU绑定进程),作为默认优先级新流程将为20,除非另行更改。

There are some parameters based on which, you can determine the same. 根据一些参数,您可以确定相同的参数。

effective_prio: Returns the effective priority of a task (based on the static priority, but includes any rewards or penalties). effective_prio:返回任务的有效优先级(基于静态优先级,但包括任何奖励或惩罚)。

recalc_task_prio: Determines a task's bonus or penalty based on its idle time. recalc_task_prio:根据任务的空闲时间确定任务的奖励或惩罚。

Ref: https://www.cs.columbia.edu/~smb/classes/s06-4118/l13.pdf 参考: https : //www.cs.columbia.edu/~smb/classes/s06-4118/l13.pdf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM