CS 149: Operating Systems March 19 Class Meeting

Slides:



Advertisements
Similar presentations
CS 149: Operating Systems February 3 Class Meeting
Advertisements

Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Operating Systems Lecture 10 Issues in Paging and Virtual Memory Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing.
Chapter 6: Process Synchronization
5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 5: CPU Scheduling.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 3 Memory Management Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
CS 149: Operating Systems February 24 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
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.
CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
CS 153 Design of Operating Systems Spring 2015
Review: Process Management Objective: –Enable fair multi-user, multiprocess computing on limited physical resources –Security and efficiency Process: running.
Concurrent Processes Lecture 5. Introduction Modern operating systems can handle more than one process at a time System scheduler manages processes and.
Modified from Silberschatz, Galvin and Gagne Lecture 13 Chapter 7: Deadlocks.
CMPT 300: Operating Systems Review THIS REIVEW SHOULD NOT BE USED AS PREDICTORS OF THE ACTUAL QUESTIONS APPEARING ON THE FINAL EXAM.
Chapter 11 Operating Systems
©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi.
1 Concurrency: Deadlock and Starvation Chapter 6.
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Concurrency: Deadlock and Starvation Chapter 6. Goal and approach Deadlock and starvation Underlying principles Solutions? –Prevention –Detection –Avoidance.
CS 149: Operating Systems February 5 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
Operating System A program that controls the execution of application programs An interface between applications and hardware 1.
CS 149: Operating Systems February 17 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall –
CS 149: Operating Systems January 29 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
CS 149: Operating Systems February 26 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
1 Previous lecture review n Out of basic scheduling techniques none is a clear winner: u FCFS - simple but unfair u RR - more overhead than FCFS may not.
CS 149: Operating Systems March 12 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
CS 153 Design of Operating Systems Spring 2015 Lecture 11: Scheduling & Deadlock.
CS 149: Operating Systems April 14 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
1 Chapter 2: Computer-System Structures  Computer System Operation  I/O Structure  Storage Structure  Storage Hierarchy  Hardware Protection  General.
CS 149: Operating Systems April 9 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
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.
1 Announcements The fixing the bug part of Lab 4’s assignment 2 is now considered extra credit. Comments for the code should be on the parts you wrote.
Computers Operating System Essentials. Operating Systems PROGRAM HARDWARE OPERATING SYSTEM.
CS 149: Operating Systems March 3 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
Operating Systems David Goldschmidt, Ph.D. Computer Science The College of Saint Rose CIS 432.
CSE 451: Operating Systems Section 5 Midterm review.
1 MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 6 Deadlocks Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc.
CS 151: Object-Oriented Design November 21 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
Review for Quiz-2 Applied Operating System Concepts Chap.s 1,2,6,7 - ECE3055b, Spring 2005.
CENG334 Introduction to Operating Systems Erol Sahin Dept of Computer Eng. Middle East Technical University Ankara, TURKEY URL:
CS 152: Programming Language Paradigms April 30 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak.
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.
CS 149: Operating Systems March 5 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
Operating Systems COMP 4850/CISG 5550 Deadlocks Dr. James Money.
What is a Process ? A program in execution.
Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 5: Process Synchronization.
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.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Introduction to Operating Systems Concepts
Chapter 2 Scheduling.
Virtual Memory Networks and Communication Department.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Chapter 9: Virtual-Memory Management
Operating Systems.
Concurrency: Mutual Exclusion and Process Synchronization
What is Concurrent Programming?
Operating Systems Lecture 1.
February 5, 2004 Adrienne Noble
CMPE 135: Object-Oriented Analysis and Design April 30 Class Meeting
CSE 153 Design of Operating Systems Winter 2019
COMP755 Advanced Operating Systems
CS 144 Advanced C++ Programming May 7 Class Meeting
EECE.4810/EECE.5730 Operating Systems
Presentation transcript:

CS 149: Operating Systems March 19 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak www.cs.sjsu.edu/~mak

Midterm Solution: Question 1 Briefly explain why Round Robin (RR) process scheduling is ideal for interactive systems. Good response time Fair and consistent

Midterm Solution: Question 2 Briefly describe a situation where, with preemptive Highest Priority First (HPF) process scheduling, a low priority process can block a high priority process. The low priority process can hold a non-preemptable resource (such as the printer) needed by the high priority process. This situation is called priority inversion.

Midterm Solution: Question 3 Assume the following processes all arrived at time 0. In a hard real-time system, each process must complete by its deadline. Schedule the processes so that each one finishes the earliest before its deadline. Timeline: Process CPU Burst Deadline P0 350 575 P1 125 550 P2 475 1050 P3 250 none P4 75 200 Process Start time End time P0 200 550 P1 75 P2 1025 P3 1275 P4 P4 P1 P0 P2 P3 75 200 550 1025 1275

Midterm Solution: Question 4 Briefly describe a situation where an application requires more than one mutex. A multithreaded application accesses more than one shared resource, each of which requires mutual exclusion. Therefore, each thread can have multiple critical regions, one per shared resource. Each critical region needs to be protected by a separate mutex.

Midterm Solution: Question 5 Consider the teacher’s office hour multithreaded simulation program. Why was it necessary to lock a mutex before printing an event line and then unlock that mutex after printing the line? Each event line was constructed by multiple calls to printf(). Without the mutex, events happening simultaneously would cause their printf() calls to be interleaved, causing the event line to be corrupted.

Midterm Solution: Question 5, cont’d Suppose Prof. Zemma Fore team-teaches a class with Dr. Wayton Post. They have adjacent offices, and they hold their office hours at the same time for their joint class. Now there are six chairs outside their offices for waiting students. Briefly describe what changes you will need to make to the simulation program to accommodate the addition of Dr. Post. Increase constant CHAIR_COUNT to 6 Start a second teacher thread for Dr. Post. A student can meet with either Prof. Fore or Dr. Post.

Midterm Solution: Question 6 Consider the following resource allocation graph. Which processes (if any) are only temporarily blocked, and why? Processes P1 and P2 are temporarily blocked. Either P1 or P2 (or both at the same time) can acquire an R2 resource and complete. Which processes (if any) are deadlocked, and why? Processes P3 and P4 are deadlocked. Each is trying to acquire a resource held by the other.

Midterm Solution: Question 7 1. Mutual exclusion 2. Hold and wait 3. No preemption 4. Circular wait Consider the Dining Philosophers problem with five philosophers, and the four conditions that must hold for a deadlock to occur. For each of the following strategies to prevent a deadlock, identify which of the four conditions is it breaking and explain how. Philosophers 1 through 4 each acquires the left fork first and then the right fork. Philosopher 5 must first acquire the right fork and then the left fork. This imposes an ordering on forks to break circular wait.

Midterm Solution: Question 7, cont’d 1. Mutual exclusion 2. Hold and wait 3. No preemption 4. Circular wait A more senior philosopher can take a fork away from a less senior neighbor. This breaks no preemption. A philosopher can acquire the left and right forks only if both forks are available. No philosopher can grab one fork and then wait for another fork. This breaks hold and wait.

Midterm Solution: Question 8 The theoretical optimal page replacement algorithm serves as a bottom-line reference for the other algorithms. Whenever a page fault occurs, it looks ahead into the future and chooses the page that will not be referenced the longest to be the victim. Given the page reference string and the three page frames, fill in the page numbers for the algorithm. Check the circle if a page fault occurred. 1 2 3 4 5 6 7 Page reference string Check if page fault arbitrary choices

Midterm Solution: Question 9 Briefly explain the mechanism by which a 20-bit address in a machine instruction can at run time address a terabyte of physical memory. Part of the 20-bit address is an index to a page table entry and the rest is an offset into a page. The indexed entry in the page table can contain a wide enough address (the starting address of a page frame) that when combined with the offset from the 20-bit address, the effective address can address a terabyte of physical memory.

Midterm Solution: Question 10 Why is a process’s working set only an approximation of the process’s locality? A process can have multiple localities during its execution. The localities can have different sizes (as measured by time or number of page references). A working set has a fixed size as determined by its Δ parameter.

Linux Kernel Memory Allocation, cont’d Object caches consist of pointers to one or more slabs which can store a number of objects of the same type. Operating Systems Concepts, 9th edition Silberschatz, Galvin, and Gagne (c) 2013 John Wiley & Sons. All rights reserved. 978-1-118-06333-0

Operating System Design Goals Define the right abstractions Processes and threads Semaphores and mutexes Virtual memory File systems Pipes

Operating System Design Goals, cont’d Provide primitive operations System calls Start and stop processes and threads Signal and wait Read and write files

Operating System Design Goals, cont’d Ensure isolation Handle multiple users Protection mechanisms Isolate faults Manage the hardware I/O devices Memory management unit Interrupt controllers

Design Challenges Operating systems live for a very long time. Operating systems have become extremely large. Designers need to provide for considerable generality. No one can predict how systems will be used. Need to be portable and run on different platforms.

Design Challenges Need to be backward compatible with some previous operating system. Must deal with concurrency. Must deal with potentially hostile users. Many users want to share some of their information and resources with selected other users.

Principles for Interface Design Simplicity Perfection is reached not when there is no longer anything to add, but when there is no longer anything to take away. Antoine de St. Exupery Completeness Everything should be as simple as possible, but no simpler. Albert Einstein Efficiency If a feature or system call cannot be implemented efficiently, it is probably not worth having. Tanenbaum

A Layered OS Architecture A possible design for a modern layered operating system. Modern Operating Systems, 3rd ed. Andrew Tanenbaum (c) 2008 Prentice-Hall, Inc.. 0-13-600663-9 All rights reserved

Hide the Low-Level Hardware Hide word-length dependencies during compilation: #include "config.h" init( ) #if (CPU = PENTIUM) ... #endif #if (CPU = SPARC) #include "config.h" #if (WORD_LENGTH == 32) typedef int Register #endif #if (WORD_LENGTH == 64) typedef long Register Register R0, R1, R3;

Performance Why are operating systems slow? What should be optimized? Space-time tradeoffs Caching Exploiting locality Optimize the common case

Example Space-Time Tradeoff Count bits in a byte: Procedure Macro Table lookup Modern Operating Systems, 3rd ed. Andrew Tanenbaum (c) 2008 Prentice-Hall, Inc.. 0-13-600663-9 All rights reserved

Lessons from The Mythical Man Month The classic book about designing OS/360 for a large IBM mainframe computer during the mid 1960s. http://www.amazon.com/Mythical-Man-Month-Software-Engineering-Anniversary/dp/0201835959/ref=sr_1_1?s=books&ie=UTF8&qid=1395217138&sr=1-1&keywords=mythical+man+month Large project design 1/3 planning 1/6 coding 1/4 module testing 1/4 system testing

Lessons from The Mythical Man Month People and time not interchangeable. Work cannot be fully parallelized. Work must be partitioned into large numbers of modules. Debugging is highly sequential. “Adding manpower to a late software project makes it later.”

Operating System Trends Virtualization Multicore chips Large address space Networking Parallel and distributed systems Multimedia Mobile computers Embedded systems Sensor networks