Class 10 CS 439 14 Feburary 2013 On the board ------------ 1. Last time 2. mutexes/ spinlocks 3. scheduling --intro --------------------------------------------------------------------------- 1. Last time --threads --classification: user v kernel / cooperative-v-preemptive --implementation swtch() --NOTE: we covered the implementation of swtch() when threads yield voluntarily 2. mutexes and spinlocks --LOCK prefix --disable interrupts (only works on uniprocessor system) --xchg / spinlocks / etc. --ask how we can implement this. 3. Scheduling intro A. When do scheduling decisions happen? exit (iv) |-------->[terminated] admitted (ii) interrupt | [new] --> [ready] <-------------- [running] ^ ---------------> | I/O or event \ scheduler dispatch | completion (iii) \ ___________| \ / [waiting] v I/O or event wait (i) scheduling decisions take place when a process: (i) Switches from running to waiting state (ii) Switches from running to ready state (iii) Switches from waiting to ready (iv) Exits preemptive scheduling: at all four points nonpreemptive scheduling: at points (i), (iv), only (this is the definition of nonpreemptive scheduling) B. What are metrics and criteria? --system throughput # of processes that complete per unit time --turnaround time time for each process to complete --response time time from request to first response (e.g., key press to character echo, not launch to exit) --fairness different possible definitions: --freedom from starvation --all users get equal time on CPU --highest priority jobs get most of CPU --etc. [often conflicts with efficiency. true in life as well.] the above are affected by secondary criteria: --CPU utilization (fraction of time CPU is actually working) --waiting time (time each process waits in ready queue; this is pretty much the same thing as response time)