Process Scheduling
-
可能時機
- running -> waiting
- running -> ready
- waiting -> ready
- running -> terminate
-
Process Scheduler
- Preemptive scheduler (Time slice)
- 可以被搶占
- Non-Preemptive scheduler
- 又稱 cooperative scheduling
- 只可能出現在時機 1 或 4
- Preemptive scheduler (Time slice)
-
Classification fo Processes(related to scheduling)
- Interactive Processes (50 - 150 ms)
- Batch Processes
- Real time Processes
- Hard
- Soft
-
Classification of Processes(related to CPU usage)
- CPU Bound
- I/O Bound
Standard Scheduling Algorithm
- FCFS
- SJF
- SRTF
- Priority Based
- Highest Response Ratio Next
- Round Robin
- Virtual RR
- Multi-Level Queue Scheduler
- Multi-Level Feed Back Queue Scheduler
- Rotating Staircase Deadline Scheduler
UNIX SVR3 Scheduler
有 32 個 runqueue,每個 runqueue 負責 4 個 priority values
-
128 Priority values
- 0-49: Kernel
- 50-127: User
-
$Priority_j=Base_j+CPU_j(i)+nice_j$
- Base: 0-127
- $CPU_j(i) = DR * CPU_j(i-1)$
- DR = $\frac{1}{2}$
- nice: -20 ~ +19
- 可以用 nice 和 renice 改 process nice value
Schedtool
-
Query & set per process scheduling parameters
- Scheduling Policy
- Real time
- SCHED_RR
- SCHED_FIFO
- Conventional
- SCHED_NORMAL (default)
- SCHED_BATCH (CPU intensive)
- SCHED_ISO (unused)
- SCHED_IDLEPRIO (low pri jobs)
- Real time
- Nice Value (-20 to +19)
- Static Priority (1-99)
- CPU affinity
- process 想運行在某個指定的 CPU 上,不被轉移到其他 CPU,才不會降低指定 CPU 的 cache 命中率
- soft CPU affinity
- hard CPU affinity
- cpus_allowed
- 一個用來指定 CPU 的 mask
- process 想運行在某個指定的 CPU 上,不被轉移到其他 CPU,才不會降低指定 CPU 的 cache 命中率
- Scheduling Policy
-
1
schedtool <PID>