Somethings about the Process scheduler in Linux

Some concepts

The process scheduler decides which process runs and for how long.it is responsible for best utilizing the system and giving users the impression that multiple processes are executing simultaneously.

Multitasking

The Multitasking systems come in two flavors:cooperative multitasking and preemptive multitasking.Linux is preemptive multitasking,the system uses timeslice to mange the processes but in the cooperative multitasking,a process doesn’t stop running until it voluntary decides to do so,the scheduler can’t make global decisions regarding how long processes run.So now most of the systems are designed with preemptive multitasking.

Linux’s Process Scheduler

the 2.5 kernel updates a new scheduler called o(1) scheduler,introducing a constant-time algorithm for timeslice calculation and per-processor runqueues .But it lacks interactive processes.
2.6 kernel aims at improving the interactive performance of the o(1) scheduler and the most notable is Rotating Staircase Deadline scheduler which introduced the concept of fair scheduler.

Policy

The policy is the behavior of the scheduler that determines what runs when.

The scheduling policy in a system must attempt to satisfy two conflicting goals:fast process time(low latency) and maximal system utilization(high throughput)

The Linux aims to provide good interactive response and desktop performance,optimizes for process response(low latency),thus favoring I/O bound process over processor-bound.

I/O bound and Processor-bound Processes

I/O Bound:the process that spends lots of time submitting and waiting the I/O request.Most graphical user interface(GUI)applications are I/O Bound
Processor bound:spend much of its time in executing code.A scheduler policy for processor-bound processes tends to run such processes less frequently but for longer durations.

Process priority

a common type of scheduling algorithm is priority-based scheduling.The higher priority ones also have a longer time slice.But the shortcoming is that the low priority ones will be starved all the time

The Linux implements two separate priority ranges:
- the first is nice value,default value is 0,range is -20 to 19.the larger the value,the priority lower,the possibility to be executed by the kernel is lower.
- the second range is real-time-priority,range from 0 to 99,higher real-time priority values correspond to a greater priority

The kernel will compute the final priority depend on nice value and real-time-priority.

Timeslice

The I/O Bound processes want a shorter timeslice but the processor-Bound want the longer one.
The linux’s CFS assigns processes a proportion of the processor and the timeslice is affected by the nice value,Higher the nice value(a lower priority),smaller proportion of the processor.

The linux is preemptive,under the new CFS scheduler,if the newly runnable processor consumed a smaller proportion of the processor than the currently executing process,it runs immediately,preempting the current process.If not,it is to run at a later time.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值