Linux Kernel development (1)

asm/thread_info.h

linux/threads.h   /proc/sys/kernel/pid_max

linux/sched.h

kernel/fork.c

linux/kthread.h    struct task_struct *kthread_create

Process Priority

  1. Process Priority
  2. Timeslice
  3. The Scheduling Policy in Action

Specifically, CFS determines that the text editor has run for less time than the video encoder. Attempting to give all processes a fair share of the processor, it then preempts the video encoder and enables the text editor to run.

Scheduler Classes

  1. Process Scheduling in Unix Systems
  2. Fair Scheduling

Each scheduler class has a priority.The base scheduler code, which is defined in kernel/sched.c, iterates over each scheduler class in order of priority.

CFS is defined in kernel/sched_fair.c.

The Linux Scheduling Implementation

With the discussion of the motivation for and logic of CFS behind us, we can now explore CFS’s actual implementation, which lives in kernel/sched_fair.c.

  1. Time Accounting: The Scheduler Entity Structure; The Virtual Runtime
  2. Process Selection: Picking the Next Task; Adding Processes to the Tree; Removing Processes from the Tree
          This is, in fact, the core of CFS’s scheduling algorithm: Pick the task with the smallest vruntime.That’s it!
  3. The Scheduler Entry Point:
         The main entry point into the process schedule is the function schedule(), defined in kernel/sched.c.
  4. Sleeping and Waking Up: Wait Queues, Waking Up

Preemption and Context Switching

  1. User Preemption
    Calls switch_to(), declared in , to switch the processor state from the previous process’s to the current’s.
  2. Kernel Preemption

Real-Time Scheduling Policies

Via the scheduling classes framework, these real-time policies are managed not by the Completely Fair Scheduler, but by a special real-time scheduler, defined in kernel/sched_rt.c.

Scheduler-Related System Calls

Scheduling Policy and Priority-Related System Calls

Processor Affinity System Calls

Yielding Processor Time

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值