Lab 4: Linux Process Scheduling
Jan. 31/Feb. 1, 2007
[153 Home]      [Introduction]      [Information]      [Call Graph]      [Resources]

Introduction (kernel version 2.6.x)
  1. Process Management
    • the process descriptor: struct task_struct
    • the task list: a circular doubly linked list
    • the current macro: the current running task
    • system call and interrupts
  2. Process States
    • TASK_RUNNING
    • TASK_INTERRUPTIBLE
    • TASK_UNINTERRUPTIBLE
    • TASK_STOPPED
    • TASK_TRACED
    • EXIT_ZOMBIE
    • EXIT_DEAD
  3. Linux Scheduler (the schedule() function in <linux/sched.c>)
    • When the scheduler is called?
    • What does the scheduler do?
  4. The Scheduling Policy: Time-Sharing, Preemptive Priority Scheduling
    • I/O-bound v.s. CPU-bound processes
    • Process Preemption: determined by both priority and timeslice
    • An example: a text-editor and a video encoder
  5. The Scheduling Algorithm: the O(1) algorithm
    • Runqueues and the priority arrays
    • Calculating priority and timeslice

Important Information
  1. Data Structures
    • struct task_struct (<linux/sched.h>)
    • struct runqueue (<linux/sched.c>)
    • struct prio_array (<linux/sched.c>)
  2. System Calls
    • nice()
    • getpriority()
    • setpriority()
    • sched_getscheduler()
    • sched_setscheduler()
    • sched_yield()

The Call Graph (generated using DOT)

Resources
  1. Online Source Code: Cross-Referencing Linux
  2. Online Book: Understanding the Linux Kernel, 3rd Edition
  3. Lab Manual: p.24-31, p155-166