Operating Systems (Scheduling) Flashcards
3 Basic concepts of OS Scheduling?
1) Max CPU utilization through multiprogramming.
2) CPU-I/O Burst Cycle
3) CPU burst distribution
CPU Scheduler selects from processes that are __ (2) when a process __(4)
1.1/2) In memory and ready to execute.
- 1) Switches from running to waiting state.
- 2) Switches from running to ready state.
- 3) Switches from waiting to ready.
- 4) Terminates.
Dispatcher gives control of CPU to __ (1) and this involves __ (3).
1) The process that was selected by the CPU scheduler.
- 1) switching context
- 2) switching to user mode
- 3) jumping to the proper location in the user program
Scheduling criteria (5)
1) CPU utilization
2) Throughput
3) Turnaround time
4) Waiting time
5) Response time
Optimization criteria (5)
- Max CPU utilisation
- Max throughput
- Min turnaround time
- Min waiting time
- Min response time
How can we (try) determine the length of the next CPU burst?
We estimate the length using exponential averaging:
tn = actual length of nth CPU burst. Tn+1 = predicted value of the next CPU burst.
For 0<=a<=1,
Tn+1 = atn + (1-a)*Tn
How can we (try) determine the length of the next CPU burst?
We estimate the length using exponential averaging:
tn = actual length of nth CPU burst. Tn+1 = predicted value of the next CPU burst.
For 0<=a<=1,
Tn+1 = atn + (1-a)*Tn
View the diagram in the notes.
Examples of Exponential Averaging
• α =0 • τn+1 = τn • Recent history does not count • α = 1 • τn+1 = αtn • Only the actual last CPU burst counts • If we expand the formula, we get: τn+1 = α τn+(1 - α)ατn -1 + … \+(1 - α )j ατn -j + … \+(1 - α )n +1 τ0
Priority scheduling:
- 2 Schemes
- SJF
- Problem and solution
1) Preemptive and Non-preemptive
2) SJF is a special case of priority scheduling
3) Problem - starvation;
Solution - aging
Round Robin (RR)
- Explanation
- What happens after this time has elapsed? (2)
- Performance (3)
1) Each process gets a unit of CPU time.
2) After, process preempted and added to the end of the ready queue.
3) q must be large w.r.t context switch time.
q too large => FIFO,
q too small => high overhead
Round Robin (RR)
- Explanation
- What happens after this time has elapsed? (2)
- Performance (3)
- RR vs SJF
1) Each process gets a unit of CPU time.
2) After, process preempted and added to the end of the ready queue.
3) q must be large w.r.t context switch time.
q too large => FIFO,
q too small => high overhead
4) • RR typically has • higher average turnaround than SJF, but • better response (diag.)
Multi-level queue:
1) Ready queue partitioning (2)
2) Queue scheduling algorithms
3) How is scheduling done between queues?
• Ready queue is partitioned into separate queues • foreground (interactive) • background (batch) • Each queue has its own scheduling algorithm • foreground – RR • background – FCFS • Scheduling must be done between the queues • Fixed priority scheduling • Foreground, then background: possibility of starvation. • Time slice • each queue gets a certain amount of CPU time • 80% to foreground in RR and • 20% to background in FCFS
see diagram with processes priority.
Multilevel Feedback Queue (2)
- Separation based on CPU bursts
- Process may move between queues
Diagram.
Thread Scheduling (2:2)
• Process Contention Scope 1) Local scheduling 2) Thread library schedules user threads on available kernel threads • System Contention Scope 1) Global Scheduling 2) Kernel schedules kernel threads onto CPU
Multiple-Processor Scheduling (6: 1, 2, 1, 1, 1, 2)
• Asymmetric multiprocessing
1) Master server - only one processor
accesses the system data structures,
alleviating the need for data sharing
• Symmetric multiprocessing
1) Each processor is self-scheduling
2) Multiple physical processors
• Processor Affinity
1) Hard / Soft
• Load balancing
1) Push / Pull
• Multiprocessing
1) Symmetric / Asymmetric
• Multithreaded Multicore Processors
1) Hardware thread
2) Appears as logical processor