overview
DESCRIPTION
Overview. Assignment 10: hints Deadlocks & Scheduling Assignment 9: solution Scheduling. A10 Ex1 – Deadlocks. Give a real-life example of deadlock. Is it possible to have a deadlock with one process/thread only? Hint: think of types of locks. A10 Ex2 – Synchronization Primitives. - PowerPoint PPT PresentationTRANSCRIPT
1
Overview Assignment 10: hints
Deadlocks & Scheduling Assignment 9: solution
Scheduling
2
A10 Ex1 – Deadlocks Give a real-life example of deadlock. Is it possible to have a deadlock with one
process/thread only?
Hint: think of types of locks
3
A10 Ex2 – Synchronization Primitives
Assumption: OS with only a yield() system call
Your task: give a pseudo-code implementation of lock, unlock, wait, and notify
Hint: keep track of the threads and their state
4
A10 Ex3 – Scheduling Implement a scheduler simulator
Input: comma separated list of [time, priority]Output: average turnaround and response
time for First come first served Shortest job first Longest response ratio Highest priority first Round Robin (Hood)
5
Overview Assignment 10: hints
Deadlocks & Scheduling Assignment 9: solution
Scheduling
6
A9 Ex1 - Scheduling 5 jobs arrive at the same time
Process turnaround time: the time elapsed from the submission of the job until the job was done
Job Time Priority RR Prio FCFS SJF
A 10 3 30 24 10 30
B 6 5 23 6 16 12
C 2 2 8 26 18 2
D 4 1 17 30 22 6
E 8 4 28 14 30 20
Avg. 21.2 20 19.2 14
7
A9 Ex2 - MultithreadingDifference between kernel threads and user-space threads User level threads:
Managed by an application (customizable)No preemption, cooperativeOnly one CPU
Kernel threads:Managed by kernelUser-space Kernel-space more
expensive
8
A9 Ex3 - Processes Process: has its own address space Thread: shares the address space with
some other thread/s
Context switch: Threads: save PC, SP, FP, regs Processes: save PC, SP, FP, regs, PT Coroutines: save PC, SP, FP