Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 153 Design of Operating Systems Winter 2015 Midterm Review.

Similar presentations


Presentation on theme: "CSE 153 Design of Operating Systems Winter 2015 Midterm Review."— Presentation transcript:

1 CSE 153 Design of Operating Systems Winter 2015 Midterm Review

2 CSE 153 – Midterm Review2 Midterm l in class on Tuesday l Covers material through scheduling and deadlock l Based upon lecture material and Chapters 1 to 7 u Closed book. No additional sheets of notes

3 CSE 153 – Midterm Review3 Overview l Architectural support for Oses l Processes l Threads l Synchronization l Scheduling

4 CSE 153 – Midterm Review4 Arch Support for OSes l Types of architecture support u Manipulating privileged machine state u Generating and handling events

5 CSE 153 – Midterm Review5 Privileged Instructions l What are privileged instructions? u Who gets to execute them? u How does the CPU know whether they can be executed? u Difference between user and kernel mode l Why do they need to be privileged? l What do they manipulate? u Protected control registers u Memory management u I/O devices

6 CSE 153 – Midterm Review6 Events l Events u Synchronous: faults (exceptions), system calls u Asynchronous: interrupts l What are faults, and how are they handled? l What are system calls, and how are they handled? l What are interrupts, and how are they handled? u How do I/O devices use interrupts? l What is the difference between exceptions and interrupts?

7 CSE 153 – Midterm Review7 Processes l What is a process? l What resource does it virtualize? l What is the difference between a process and a program? l What is contained in a process?

8 CSE 153 – Midterm Review8 Process Data Structures l Process Control Blocks (PCBs) u What information does it contain? u How is it used in a context switch? l State queues u What are process states? u What is the process state graph? u When does a process change state? u How does the OS use queues to keep track of processes?

9 CSE 153 – Midterm Review9 Process Manipulation l What does CreateProcess on Windows do? l What does fork() on Unix do? u What does it mean for it to “return twice”? l What does exec() on Unix do? u How is it different from fork? l How are fork and exec used to implement shells?

10 CSE 153 – Midterm Review10 Threads l What is a thread? u What is the difference between a thread and a process? u How are they related? l Why are threads useful? l What is the difference between user-level and kernel- level threads? u What are the advantages/disadvantages of one over another?

11 CSE 153 – Midterm Review11 Thread Implementation l How are threads managed by the run-time system? u Thread control blocks, thread queues u How is this different from process management? l What operations do threads support? u Fork, yield, sleep, etc. u What does thread yield do? l What is a context switch? l What is the difference between non-preemptive scheduling and preemptive thread scheduling? u Voluntary and involuntary context switches

12 CSE 153 – Midterm Review12 Synchronization l Why do we need synchronization? u Coordinate access to shared data structures u Coordinate thread/process execution l What can happen to shared data structures if synchronization is not used? u Race condition u Corruption u Bank account example l When are resources shared? u Global variables, static objects u Heap objects

13 CSE 153 – Midterm Review13 Mutual Exclusion l What is mutual exclusion? l What is a critical section? u What guarantees do critical sections provide? u What are the requirements of critical sections? »Mutual exclusion (safety) »Progress (liveness) »Bounded waiting (no starvation: liveness) »Performance l How does mutual exclusion relate to critical sections? l What are the mechanisms for building critical sections? u Locks, semaphores, monitors, condition variables

14 CSE 153 – Midterm Review14 Locks l What does Acquire do? l What does Release do? l What does it mean for Acquire/Release to be atomic? l How can locks be implemented? u Spinlocks u Disable/enable interrupts l How does test-and-set work? u What kind of lock does it implement? l What are the limitations of using spinlocks, interrupts? u Inefficient, interrupts turned off too long

15 CSE 153 – Midterm Review15 Semaphores l What is a semaphore? u What does Wait/P/Decrement do? u What does Signal/V/Increment do? u How does a semaphore differ from a lock? u What is the difference between a binary semaphore and a counting semaphore? l When do threads block on semaphores? l When are they woken up again? l Using semaphores to solve synchronization problems u Readers/Writers problem u Bounded Buffers problem

16 CSE 153 – Midterm Review16 Monitors l What is a monitor? u Shared data u Procedures u Synchronization l In what way does a monitor provide mutual exclusion? u To what extent is it provided? l How does a monitor differ from a semaphore? l How does a monitor differ from a lock? l What kind of support do monitors require? u Language, run-time support

17 CSE 153 – Midterm Review17 Condition Variables l What is a condition variable used for? u Coordinating the execution of threads u Not mutual exclusion l Operations u What are the semantics of Wait? u What are the semantics of Signal? u What are the semantics of Broadcast? l How are condition variables different from semaphores?

18 CSE 153 – Midterm Review18 Implementing Monitors l What does the implementation of a monitor look like? u Shared data u Procedures u A lock for mutual exclusion to procedures (w/ a queue) u Queues for the condition variables l What is the difference between Hoare and Mesa monitors? u Semantics of signal (whether the woken up waiter gets to run immediately or not) u What are their tradeoffs? u What does Java provide?

19 CSE 153 – Midterm Review19 Scheduling l What kinds of scheduling is there? u Long-term scheduling u Short-term scheduling l Components u Scheduler (dispatcher) l When does scheduling happen? u Job changes state (e.g., waiting to running) u Interrupt, exception u Job creation, termination

20 CSE 153 – Midterm Review20 Scheduling Goals l Goals u Maximize CPU utilization u Maximize job throughput u Minimize turnaround time u Minimize waiting time u Minimize response time l What is the goal of a batch system? l What is the goal of an interactive system?

21 CSE 153 – Midterm Review21 Starvation l Starvation u Indefinite denial of a resource (CPU, lock) l Causes u Side effect of scheduling u Side effect of synchronization l Operating systems try to prevent starvation

22 CSE 153 – Midterm Review22 Scheduling Algorithms l What are the properties, advantages and disadvantages of the following scheduling algorithms? u First Come First Serve (FCFS)/First In First Out (FIFO) u Shortest Job First (SJF) u Priority u Round Robin u Multilevel feedback queues l What scheduling algorithm does Unix use? Why?

23 CSE 153 – Midterm Review23 Deadlock l Deadlock happens when processes are waiting on each other and cannot make progress l What are the conditions for deadlock? u Mutual exclusion u Hold and wait u No preemption u Circular wait l How to visualize, represent abstractly? u Resource allocation graph (RAG) u Waits for graph (WFG)

24 CSE 153 – Midterm Review24 Deadlock Approaches l Dealing with deadlock u Ignore it u Prevent it (prevent one of the four conditions) u Avoid it (have tight control over resource allocation) u Detect and recover from it l What is the Banker’s algorithm? u Which of the four approaches above does it implement?

25 Lets do some problems CSE 153 – Midterm Review25

26 CSE 153 – Midterm Review26

27 CSE 153 – Midterm Review27

28 CSE 153 – Midterm Review28

29 CSE 153 – Midterm Review29

30 CSE 153 – Midterm Review30

31 CSE 153 – Midterm Review31


Download ppt "CSE 153 Design of Operating Systems Winter 2015 Midterm Review."

Similar presentations


Ads by Google