Linux Kernel development (1)

Posted on 2011-04-12 16:36  Teddy Yan  阅读(207)  评论(0编辑  收藏  举报

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

Copyright © 2024 Teddy Yan
Powered by .NET 8.0 on Kubernetes