CS 153 Design of Operating Systems Spring 2015 Midterm Review.

Slides:



Advertisements
Similar presentations
Operating Systems ECE344 Midterm review Ding Yuan
Advertisements

More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Basic Operating System Concepts
CAS3SH3 Midterm Review. The midterm 50 min, Friday, Feb 27 th Materials through CPU scheduling closed book, closed note Types of questions: True & False,
Chapter 6: Process Synchronization
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Process Synchronization. Module 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores.
Operating Systems ECE344 Ding Yuan Final Review Lecture 13: Final Review.
Review: Chapters 1 – Chapter 1: OS is a layer between user and hardware to make life easier for user and use hardware efficiently Control program.
Operating System Process Scheduling (Ch 4.2, )
Chapter 2: Processes Topics –Processes –Threads –Process Scheduling –Inter Process Communication (IPC) Reference: Operating Systems Design and Implementation.
1 CS318 Project #3 Preemptive Kernel. 2 Continuing from Project 2 Project 2 involved: Context Switch Stack Manipulation Saving State Moving between threads,
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
Concurrency: Mutual Exclusion, Synchronization, Deadlock, and Starvation in Representative Operating Systems.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
Process Description and Control A process is sometimes called a task, it is a program in execution.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
Operating System Process Scheduling (Ch 4.2, )
Intro to OS CUCS Mossé Processes and Threads What is a process? What is a thread? What types? A program has one or more locus of execution. Each execution.
1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Chapter 6: CPU Scheduling
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-3 CPU Scheduling Department of Computer Science and Software Engineering.
1 Lecture 4: Threads Operating System Fall Contents Overview: Processes & Threads Benefits of Threads Thread State and Operations User Thread.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
CS 153 Design of Operating Systems Spring 2015 Lecture 11: Scheduling & Deadlock.
Scheduling Basic scheduling policies, for OS schedulers (threads, tasks, processes) or thread library schedulers Review of Context Switching overheads.
Chapter 41 Processes Chapter 4. 2 Processes  Multiprogramming operating systems are built around the concept of process (also called task).  A process.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
1 CSE451 Scheduling Autumn 2002 Gary Kimura Lecture #6 October 11, 2002.
CE Operating Systems Lecture 11 Windows – Object manager and process management.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Mutual Exclusion.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Cpr E 308 Spring 2004 Real-time Scheduling Provide time guarantees Upper bound on response times –Programmer’s job! –Every level of the system Soft versus.
CSE 451: Operating Systems Section 5 Midterm review.
Operating Systems ECE344 Ding Yuan Final Review Lecture 13: Final Review.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Review for Quiz-2 Applied Operating System Concepts Chap.s 1,2,6,7 - ECE3055b, Spring 2005.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
CSE 153 Design of Operating Systems Winter 2015 Midterm Review.
Lecture Topics: 11/15 CPU scheduling: –Scheduling goals and algorithms.
What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program.
CE Operating Systems Lecture 8 Process Scheduling continued and an introduction to process synchronisation.
CPU Scheduling Operating Systems CS 550. Last Time Deadlock Detection and Recovery Methods to handle deadlock – Ignore it! – Detect and Recover – Avoidance.
Introduction to operating systems What is an operating system? An operating system is a program that, from a programmer’s perspective, adds a variety of.
Lecturer 5: Process Scheduling Process Scheduling  Criteria & Objectives Types of Scheduling  Long term  Medium term  Short term CPU Scheduling Algorithms.
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Processes and threads.
Copyright ©: Nahrstedt, Angrave, Abdelzaher
CSE 120 Principles of Operating
Sarah Diesburg Operating Systems COP 4610
Applied Operating System Concepts -
Section 10: Last section! Final review.
Chapter 2.2 : Process Scheduling
Process management Information maintained by OS for process management
Chapter 6: CPU Scheduling
Operating System Concepts
Midterm review: closed book multiple choice chapters 1 to 9
Process Description and Control
Lecture 2 Part 2 Process Synchronization
CSE 451: Operating Systems Spring 2005 Module 23 Course Review
February 5, 2004 Adrienne Noble
CS510 Operating System Foundations
CSE 153 Design of Operating Systems Winter 19
Chapter 6: Synchronization Tools
CSE 153 Design of Operating Systems Winter 2019
EECE.4810/EECE.5730 Operating Systems
CSE 542: Operating Systems
CSE 542: Operating Systems
Sarah Diesburg Operating Systems CS 3430
Presentation transcript:

CS 153 Design of Operating Systems Spring 2015 Midterm Review

2 Midterm l in class on Friday 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

Project 2 is out today l Three weeks to complete l Do not count on extensions! 3

4 Overview l Architectural support for Oses l Processes l Threads l Synchronization l Scheduling (including deadlock)

5 Arch Support for OSes l Types of architecture support u Manipulating privileged machine state u Generating and handling events

6 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

7 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?

8 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?

9 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?

10 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?

11 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?

12 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

13 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

14 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

15 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

16 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

17 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

18 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?

19 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?

20 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

21 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?

22 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

23 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?

24 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) P1 P2 P3 P1 P2 P3 R1 R2 R3

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

Question 1 l Most operating systems are designed for general-purpose computation. A proposal has been put forth for an OS that is optimized for running math-intensive programs. In MathOS, the kernel includes system calls for many useful mathematical operations, such as matrix arithmetic, Bessel functions, Euclidean distance, etc. These system calls are written in highly optimized assembly language for maximum performance. Is this concept for MathOS a good idea? Explain why or why not. l No! Math functions won’t benefit from running in the kernel. They do not need privileged instructions or special facilities. You’re putting crap in the kernel that has no reason to be there. Moreover: The overhead of calling them: mode switch + data copy is more time-consuming than a function call 26

Question 2 l What is the difference between a mode switch and a context switch? l Mode switch: change CPU execution mode from one privilege level to another e.g., user → kernel via a trap or syscall. l Context switch: save one process’ execution context & restore that of another process 27

Question 3 l What is the similarity and difference between faults (exceptions) and interrupts? l Both are unexpected, yet l Faults are synchronous l Interrupts are asynchronous 28

Question 4 l List two events that may take a process to a ready state. l Startup: created → ready l Preemption: running → ready l I/O complete: blocked → ready 29

Question 5 l Given that we can create user-level code to control access to critical sections (e.g., Peterson’s algorithm), why is it important for an operating system to provide synchronization facilities such as semaphores in the kernel? l Question is about offering sync services via the kernel than via user-level code. l To avoid busy waiting: the waiting thread can go to sleep u creates better CPU utilization; avoids priority inversion (if an issue) 30

Question 6 l What does a time-sharing system need that a multiprogramming system does not? (a) Trap mechanism (b) Kernel mode execution privileges (c) Shorter time slices (d) Interval Timer (d) 31

Question 7 l When does preemption take place? (a) When a quantum expires. (b) When a process issues an I/O request. (c) When a process exits. (d) All of the above. (a) 32

Question 8 l What information is stored in a thread control block (TCB)? (a) List of open files. (b) Stack pointer. (c) Memory map. (d) Thread owner ID. (b) 33

Question 9 l A test-and-set instruction allows you to: (a) Modify a memory location only if its contents match a given value. (b) Exchange the contents of two memory locations if their values are different. (c) Exchange the contents of two memory locations if a lock is not set. (d) Exchange the contents of two memory locations if a lock is set. (a) 34

Question 10 l A thread that is blocked on a semaphore is awakened when another thread: (a) Tries to decrement a semaphore’s value below 0. (b) Tries to increment the semaphore. (c) Causes the semaphore’s value to reach a specific number. (d) Tries to block on the same semaphore (b) 35

Question 11 l Switching among threads in the same process is more efficient than switching among processes. True of false? l True 36

Question 12 l The value of a semaphore can never be negative. True 37

Question 13 l Multilevel queues allow multiple processes to share the same priority level. True 38