Operating Systems and Networks Course: International University Bremen Date: Dr. Jürgen Schönwälder Deadline:

Size: px
Start display at page:

Download "Operating Systems and Networks Course: International University Bremen Date: Dr. Jürgen Schönwälder Deadline:"

Transcription

1 Operating Systems and Networks Course: International University Bremen Date: Dr. Jürgen Schönwälder Deadline: Midterm Examination Problem M.1: processes (10 points) Indicate which of the following statements are correct or incorrect by marking the appropriate boxes. For every correctly marked box, you will earn 2 points. For every incorrectly marked box, you will loose 2 points. Statements which are not marked or which are marked as and will be ignored. The minimum number of points you can achieve is zero. Every system call leads to a context switch. A preemptive scheduler can interrupt a process running in user mode at any point. The contents of semaphores must be saved during context switches so that the correct values can be restored when the process resumes its execution. Forgetting to call the up() operation on a semaphore can lead to deadlocks. Short time slices improve the responsiveness of interactive programs. Solution: Every system call leads to a context switch. A preemptive scheduler can interrupt a process running in user mode at any point. The contents of semaphores must be saved during context switches so that the correct value can be restored when the process resumes its execution. Forgetting to call the up() operation on a semaphore can lead to deadlocks. Short time slices improve the responsiveness of interactive programs. Problem M.2: synchronization (30 points) Another classical synchronization problem takes place in a barber shop. The barber shop has one barber, one barber chair, and N chairs for waiting customers, if any, to sit in. If there are no customers present, the barber sits down in the barber chair and falls asleep. When a customer arrives, he has to wake up the sleeping barber. If additional customers arrive while the barber is cutting a customer s hair, they either sit down (if there are empty chairs) or leave the shop (if all chairs are full). The problem is to program the barber and the customer without getting into race conditions. The following pseudo code fragment of a solution without the calls of the semaphore operations is provided for your convenience. Fill in the missing semaphore operations in the barber() and customer() functions to make the example work. const int N; semaphore customers = 0; semaphore barbers = 0; semaphore mutex = 1; shared int waiting = 0;

2 void barber() while () waiting--; cut_hair(); void customer() if (waiting < N) waiting++; get_haircut(); Solution: const int N; semaphore customers = 0; semaphore barbers = 0; semaphore mutex = 1; shared int waiting = 0; void barber() while () down(&customers) down(&mutex) waiting--; up(&barbers); up(&mutex); cut_hair(); void customer() down(&mutex); if (waiting < N) waiting++; up(&customers); up(&mutex); down(&barbers); get_haircut(); else up(&mutex) Problem M.3: deadlock avoidance ( =20 points) An operating system uses the banker s algorithm to avoid deadlocks. The system supports four different resource types (R 1, R 2, R 3, R 4 ) with 6, 8, 10 and 12 instances. There are five processes (P 1, P 2, P 3, P 4, P 5 ) in the system with the following maximum resource requirements: Max =

3 a) Draw the resource allocation diagram (RAG) for the state given by the following allocation matrix Alloc = Note: It is sufficient to draw the resource assignments. You do not have to draw arrows for resource claims or resource requests. b) Can the system reach the state given in a)? Provide a reason for your answer. c) Assume the system is in the state described by the following matrix Alloc = How does the operating system react if process P 4 requests an instance of resource type R 4? d) Assume the operating system is in the state given in c). Process P 2 releases all its instances of R 4 and process P 5 allocates its maximum number of resource type R 4. Can this request be granted? If it is granted, does the new situation necessarily lead to a deadlock? Discuss the cases that are possible. Solution: a) The following resource graphs describes the current state: R1 R2 P1 P2 P3 P4 P5 R3 R4 b) Avail = (1, 2, 2, 6) Need = The state is unsafe since it is impossible to satisfy the maximum resource requests for all processes. Hence, the system may never reach this state.

4 c) Alloc = Avail Action (1, 4, 0, 1) P 3 terminates (2, 6, 3, 2) P 2 terminates (3, 7, 5, 7) P 1 terminates (4, 7, 7, 8) P 5 terminates (5, 7, 9, 10) P 4 terminates (6, 8, 10, 12) stop Need = = The following state is safe. Hence, the resource request can be granted d) Alloc = Need = Avail Action (1, 4, 0, 0) P 3 terminates (2, 6, 3, 1) stop = The following state is unsafe. Hence, the resource request must be denied. If the resource request would be granted, a deadlock condition may occur. However, a deadlock does not have to occur because processes may not use their maximum resource claims or they might release enough resource instances in time so that all processes can complete without a deadlock. Problem M.4: virtual memory and working set ( =30 points) Consider an operating system with virtual memory based on demand paging. The physical memory has a size of four frames which are initially unused. The processes P 1, P 2 and P 3 produce the following reference strings: P 1 : r[t] = 11, 11, 12, 12, 13 P 2 : r[t] = 25, 21, 22, 28, 23 P 3 : r[t] = 31, 32, 31, 32, 31 a) Determine the contents of the page table and the number of page faults produced by the processes P 1, P 2 and P 3. The page replacement strategy used is least recently used and the processes alternate in accessing the memory pages (P 1, P 2, P 3, P 1, P 2, P 3, P 1...). b) Determine the minimum number of page faults that can be achieved in the given situation by the optimal page replacement algorithm. Like in a), show the contents of the page table. (If multiple pages have the same forward distance, then the page which has not been used for the longest period of time is selected. If there are still multiple pages satisfying this condition, the page with the smallest number is chosen.) c) Consider the application of the working set model to improve the performance of the system. For each process P i, determine the working set W i (t, T ) = r[t T ], r[t T + 1],..., r[t 1] with T = 3 for t = t 1,... t 5 where t j refers to the jth memory access. d) Which fundamental change compared to a) and b) is caused by the application of the working set model in the described situation?

5 Solution: a) 13 page faults (3 caused by P 1, 5 by P 2 and 5 by P 3 : P1 P2 P3 P2 P3 P1 P2 P3 P2 P3 P1 P2 P3 b) 10 page faults (3 caused by P 1, 5 by P 3 and 2 by P 3 : P1 P2 P3 P2 P3 P1 P2 P2 P1 P2 c) Process P 1 : W 1 (t 1, 3) = W 1 (t 2, 3) = 11 W 1 (t 3, 3) = 11 W 1 (t 4, 3) = 11, 12 W 1 (t 5, 3) = 11, 12 Process P 2 : W 2 (t 1, 3) = W 2 (t 2, 3) = 25 W 2 (t 3, 3) = 21, 25 W 2 (t 4, 3) = 21, 22, 25 W 2 (t 5, 3) = 21, 22, 28 Process P 3 : W 3 (t 1, 3) = W 3 (t 2, 3) = 31 W 3 (t 3, 3) = 31, 32 W 3 (t 4, 3) = 31, 32 W 3 (t 5, 3) = 31, 32 d) The working sets of the three processes cannot be kept in physical memory. As a consequence, at least one process will be removed from the run queue, which will significantly change the order in which the CPU is assigned to processes. Problem M.5: file systems (10 points) Indicate which of the following statements are correct or incorrect by marking the appropriate boxes. For every correctly marked box, you will earn 2 points. For every incorrectly marked box, you will loose 2 points. Statements which are not marked or which are marked as and will be ignored. The minimum number of points you can achieve is zero. Disk striping is a mechanism to improve data availability. A regular file known under three different names (hard links) has 3 inodes on a BSD Unix file system. A symbolic link is resolved whenever data is read from the file (pointed to by the symbolic link) using the read() system call. The unlink() system call erases the data contained in the file on the hard disk. A free block bit map is always more space efficient than a free block list.

6 Solution: Disk striping is a mechanism to improve data availability. A regular file known under three different names (so called hard links) has 3 inodes on a BSD Unix file system. A symbolic link is resolved whenever data is read from the file (pointed to by the symbolic link) using the read() system call. The unlink() system call erases the data contained in the file on the hard disk. A free block bit map is always more space efficient than a free block list.

Computer Architecture and Operating Systems Course: International University Bremen Date: Final Examination

Computer Architecture and Operating Systems Course: International University Bremen Date: Final Examination Computer Architecture and Operating Systems Course: 320202 International University Bremen Date: 2006-05-22 Dr. Jürgen Schönwälder Type: open book Final Examination Problem F.1: operating systems (2+2+2+2+2=10

More information

For 100% Result Oriented IGNOU Coaching and Project Training Call CPD: ,

For 100% Result Oriented IGNOU Coaching and Project Training Call CPD: , Question 2: (15 Marks) The Sleeping-Barber Problem: A barbershop consists of a waiting room with n chairs, and the barber room containing the barber chair. If there are no customers to be served, the barber

More information

CS450 OPERATING SYSTEMS FINAL EXAM ANSWER KEY

CS450 OPERATING SYSTEMS FINAL EXAM ANSWER KEY CS450 OPERATING SYSTEMS FINAL EXAM KEY 1. Provide Java class definitions for each of the components of a monitor. Include specifications for local data and methods (names and arguments, not implementation);

More information

Interprocess Communication and Synchronization

Interprocess Communication and Synchronization Chapter 2 (Second Part) Interprocess Communication and Synchronization Slide Credits: Jonathan Walpole Andrew Tanenbaum 1 Outline Race Conditions Mutual Exclusion and Critical Regions Mutex s Test-And-Set

More information

Puzzle: Write synchronization code for oxygen and hydrogen molecules that enforces these constraints.

Puzzle: Write synchronization code for oxygen and hydrogen molecules that enforces these constraints. Problem 2: H 2 O Building Problem There are two kinds of threads, oxygen and hydrogen. In order to assemble these threads into water molecules, we have to create a barrier that makes each thread wait until

More information

Example: Sleeping Barber (Midterm 2002)

Example: Sleeping Barber (Midterm 2002) CS 372H Spring 2010 February 23, 2010 Potentially useful, if convoluted, example, to test your understanding of how to do concurrent programming. [Thanks to Mike Dahlin.] Example: Sleeping Barber (Midterm

More information

Process Management And Synchronization

Process Management And Synchronization Process Management And Synchronization In a single processor multiprogramming system the processor switches between the various jobs until to finish the execution of all jobs. These jobs will share the

More information

Operating Systems Comprehensive Exam. Fall Student ID # 10/31/2013

Operating Systems Comprehensive Exam. Fall Student ID # 10/31/2013 Operating Systems Comprehensive Exam Fall 2013 Student ID # 10/31/2013 You must complete all of Section I You must complete two of the problems in Section II If you need more space to answer a question,

More information

Last Class: Deadlocks. Today

Last Class: Deadlocks. Today Last Class: Deadlocks Necessary conditions for deadlock: Mutual exclusion Hold and wait No preemption Circular wait Ways of handling deadlock Deadlock detection and recovery Deadlock prevention Deadlock

More information

PROCESS SYNCHRONIZATION

PROCESS SYNCHRONIZATION PROCESS SYNCHRONIZATION Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization Monitors Synchronization

More information

First Midterm Exam September 28, 2017 CS162 Operating Systems

First Midterm Exam September 28, 2017 CS162 Operating Systems University of California, Berkeley College of Engineering Computer Science Division EECS Fall 2017 Ion Stoica First Midterm Exam September 28, 2017 CS162 Operating Systems Your Name: SID AND 162 Login

More information

Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - X Deadlocks - I. University at Buffalo. Synchronization structures

Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - X Deadlocks - I. University at Buffalo. Synchronization structures CSE 421/521 - Operating Systems Fall 2012 Lecture - X Deadlocks - I Tevfik Koşar University at Buffalo October 2nd, 2012 1 Roadmap Synchronization structures Problems with Semaphores Monitors Condition

More information

Roadmap. Problems with Semaphores. Semaphores. Monitors. Monitor - Example. Tevfik Koşar. CSE 421/521 - Operating Systems Fall 2012

Roadmap. Problems with Semaphores. Semaphores. Monitors. Monitor - Example. Tevfik Koşar. CSE 421/521 - Operating Systems Fall 2012 CSE 421/521 - Operating Systems Fall 2012 Lecture - X Deadlocks - I Tevfik Koşar Synchronization structures Problems with Semaphores Monitors Condition Variables Roadmap The Deadlock Problem Characterization

More information

Outline. Monitors. Barrier synchronization The sleeping barber problem Readers and Writers One-way tunnel. o Monitors in Java

Outline. Monitors. Barrier synchronization The sleeping barber problem Readers and Writers One-way tunnel. o Monitors in Java Outline Monitors o Monitors in Java Barrier synchronization The sleeping barber problem Readers and Writers One-way tunnel 1 Monitors - higher-level synchronization (Hoare, Hansen, 1974-5) Semaphores and

More information

5 Classical IPC Problems

5 Classical IPC Problems OPERATING SYSTEMS CLASSICAL IPC PROBLEMS 2 5 Classical IPC Problems The operating systems literature is full of interesting problems that have been widely discussed and analyzed using a variety of synchronization

More information

Classical Synchronization Problems. Copyright : University of Illinois CS 241 Staff 1

Classical Synchronization Problems. Copyright : University of Illinois CS 241 Staff 1 Classical Synchronization Problems 1 1 This lecture Goals: Topics Introduce classical synchronization problems Producer-Consumer Problem Reader-Writer Problem Dining Philosophers Problem Sleeping Barber

More information

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006 Operating Systems Comprehensive Exam Spring 2006 Student ID # 3/16/2006 You must complete all of part I (60%) You must complete two of the three sections in part II (20% each) In Part I, circle or select

More information

R13 SET - 1 2. Answering the question in Part-A is compulsory 1 a) Define Operating System. List out the objectives of an operating system. [3M] b) Describe different attributes of the process. [4M] c)

More information

Problem Set: Concurrency

Problem Set: Concurrency Lecture Notes on Operating Systems Problem Set: Concurrency 1. Answer yes/no, and provide a brief explanation. (a) Is it necessary for threads in a process to have separate stacks? (b) Is it necessary

More information

Fall 2015 COMP Operating Systems. Lab 06

Fall 2015 COMP Operating Systems. Lab 06 Fall 2015 COMP 3511 Operating Systems Lab 06 Outline Monitor Deadlocks Logical vs. Physical Address Space Segmentation Example of segmentation scheme Paging Example of paging scheme Paging-Segmentation

More information

STUDENT NAME: STUDENT ID: Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Total

STUDENT NAME: STUDENT ID: Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Total University of Minnesota Department of Computer Science CSci 5103 - Fall 2016 (Instructor: Tripathi) Midterm Exam 1 Date: October 17, 2016 (4:00 5:15 pm) (Time: 75 minutes) Total Points 100 This exam contains

More information

Operating Systems Comprehensive Exam. Spring Student ID # 3/20/2013

Operating Systems Comprehensive Exam. Spring Student ID # 3/20/2013 Operating Systems Comprehensive Exam Spring 2013 Student ID # 3/20/2013 You must complete all of Section I You must complete two of the problems in Section II If you need more space to answer a question,

More information

QUESTION BANK UNIT I

QUESTION BANK UNIT I QUESTION BANK Subject Name: Operating Systems UNIT I 1) Differentiate between tightly coupled systems and loosely coupled systems. 2) Define OS 3) What are the differences between Batch OS and Multiprogramming?

More information

Lecture 9: Midterm Review

Lecture 9: Midterm Review Project 1 Due at Midnight Lecture 9: Midterm Review CSE 120: Principles of Operating Systems Alex C. Snoeren Midterm Everything we ve covered is fair game Readings, lectures, homework, and Nachos Yes,

More information

COMP 3361: Operating Systems 1 Midterm Winter 2009

COMP 3361: Operating Systems 1 Midterm Winter 2009 COMP 3361: Operating Systems 1 Midterm Winter 2009 Name: Instructions This is an open book exam. The exam is worth 100 points, and each question indicates how many points it is worth. Read the exam from

More information

Deadlocks. Dr. Yingwu Zhu

Deadlocks. Dr. Yingwu Zhu Deadlocks Dr. Yingwu Zhu Deadlocks Synchronization is a live gun we can easily shoot ourselves in the foot Incorrect use of synchronization can block all processes You have likely been intuitively avoiding

More information

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University CS 571 Operating Systems Midterm Review Angelos Stavrou, George Mason University Class Midterm: Grading 2 Grading Midterm: 25% Theory Part 60% (1h 30m) Programming Part 40% (1h) Theory Part (Closed Books):

More information

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - XI Deadlocks - II. Louisiana State University

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - XI Deadlocks - II. Louisiana State University CSC 4103 - Operating Systems Fall 2009 Lecture - XI Deadlocks - II Tevfik Ko!ar Louisiana State University September 29 th, 2009 1 Roadmap Classic Problems of Synchronization Bounded Buffer Readers-Writers

More information

Roadmap. Bounded-Buffer Problem. Classical Problems of Synchronization. Bounded Buffer 1 Semaphore Soln. Bounded Buffer 1 Semaphore Soln. Tevfik Ko!

Roadmap. Bounded-Buffer Problem. Classical Problems of Synchronization. Bounded Buffer 1 Semaphore Soln. Bounded Buffer 1 Semaphore Soln. Tevfik Ko! CSC 4103 - Operating Systems Fall 2009 Lecture - XI Deadlocks - II Roadmap Classic Problems of Synchronization Bounded Buffer Readers-Writers Dining Philosophers Sleeping Barber Deadlock Prevention Tevfik

More information

This exam paper contains 8 questions (12 pages) Total 100 points. Please put your official name and NOT your assumed name. First Name: Last Name:

This exam paper contains 8 questions (12 pages) Total 100 points. Please put your official name and NOT your assumed name. First Name: Last Name: CSci 4061: Introduction to Operating Systems (Spring 2013) Final Exam May 14, 2013 (4:00 6:00 pm) Open Book and Lecture Notes (Bring Your U Photo Id to the Exam) This exam paper contains 8 questions (12

More information

Chapter 7: Deadlocks. Operating System Concepts 8 th Edition,

Chapter 7: Deadlocks. Operating System Concepts 8 th Edition, Chapter 7: Deadlocks, Silberschatz, Galvin and Gagne 2009 Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks To present a number

More information

COMP 3361: Operating Systems 1 Final Exam Winter 2009

COMP 3361: Operating Systems 1 Final Exam Winter 2009 COMP 3361: Operating Systems 1 Final Exam Winter 2009 Name: Instructions This is an open book exam. The exam is worth 100 points, and each question indicates how many points it is worth. Read the exam

More information

COMP 300E Operating Systems Fall Semester 2011 Midterm Examination SAMPLE. Name: Student ID:

COMP 300E Operating Systems Fall Semester 2011 Midterm Examination SAMPLE. Name: Student ID: COMP 300E Operating Systems Fall Semester 2011 Midterm Examination SAMPLE Time/Date: 5:30 6:30 pm Oct 19, 2011 (Wed) Name: Student ID: 1. Short Q&A 1.1 Explain the convoy effect with FCFS scheduling algorithm.

More information

CS450/550 Operating Systems

CS450/550 Operating Systems CS450/550 Operating Systems Lecture 3 Deadlocks Dr. Xiaobo Zhou Department of Computer Science CS450/550 Deadlocks.1 Review: Summary of Chapter 2 Sequential process model Multi-threading: user-space vs.

More information

Process Synchronization

Process Synchronization CS307 Process Synchronization Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2018 Background Concurrent access to shared data may result in data inconsistency

More information

Operating Systems. Synchronization, part 3 Monitors, classical sync. problems

Operating Systems. Synchronization, part 3 Monitors, classical sync. problems Operating Systems Synchronization, part 3 Monitors, classical sync. problems 1 Monitor Monitor a synchronization primitive A monitor is a collection of procedures, variables and data structures, grouped

More information

Roadmap. Readers-Writers Problem. Readers-Writers Problem. Readers-Writers Problem (Cont.) Dining Philosophers Problem.

Roadmap. Readers-Writers Problem. Readers-Writers Problem. Readers-Writers Problem (Cont.) Dining Philosophers Problem. CSE 421/521 - Operating Systems Fall 2011 Lecture - X Process Synchronization & Deadlocks Roadmap Classic Problems of Synchronization Readers and Writers Problem Dining-Philosophers Problem Sleeping Barber

More information

Sleeping Barber CSCI 201 Principles of Software Development

Sleeping Barber CSCI 201 Principles of Software Development Sleeping Barber CSCI 201 Principles of Software Development Jeffrey Miller, Ph.D. jeffrey.miller@usc.edu Sleeping Barber Outline USC CSCI 201L Sleeping Barber Overview The Sleeping Barber problem contains

More information

Last Class: Synchronization Problems. Need to hold multiple resources to perform task. CS377: Operating Systems. Real-world Examples

Last Class: Synchronization Problems. Need to hold multiple resources to perform task. CS377: Operating Systems. Real-world Examples Last Class: Synchronization Problems Reader Writer Multiple readers, single writer In practice, use read-write locks Dining Philosophers Need to hold multiple resources to perform task Lecture 10, page

More information

CSE 120. Fall Lecture 8: Scheduling and Deadlock. Keith Marzullo

CSE 120. Fall Lecture 8: Scheduling and Deadlock. Keith Marzullo CSE 120 Principles of Operating Systems Fall 2007 Lecture 8: Scheduling and Deadlock Keith Marzullo Aministrivia Homework 2 due now Next lecture: midterm review Next Tuesday: midterm 2 Scheduling Overview

More information

Midterm Exam #2 Solutions October 25, 2016 CS162 Operating Systems

Midterm Exam #2 Solutions October 25, 2016 CS162 Operating Systems University of California, Berkeley College of Engineering Computer Science Division EECS all 2016 Anthony D. Joseph Midterm Exam #2 Solutions October 25, 2016 CS162 Operating Systems Your Name: SID AND

More information

Operating Systems Comprehensive Exam. Spring Student ID # 2/17/2011

Operating Systems Comprehensive Exam. Spring Student ID # 2/17/2011 Operating Systems Comprehensive Exam Spring 2011 Student ID # 2/17/2011 You must complete all of Section I You must complete two of the problems in Section II If you need more space to answer a question,

More information

518 Lecture Notes Week 7

518 Lecture Notes Week 7 518 Lecture Notes Week 7 (October 13, 2014) 1/9 518 Lecture Notes Week 7 1 Topics Semaphores Messages Monitors Race conditions, deadlock and starvation Banker's Algorithm Dining Philosophers Java Threads

More information

Q 1. (10 Points) Assume that a process executes the following pseudo codes:

Q 1. (10 Points) Assume that a process executes the following pseudo codes: CS630: Operating System Design Second Exam, Spring 2014 Q 1. (10 Points) Assume that a process executes the following pseudo codes: #4 #5 #6 #7 #10 main (int argc, char *argv[ ]) { int I, *input; n = argc

More information

Interprocess Communication

Interprocess Communication Chapter 6 Interprocess Communication 6.1 Introduction Processes frequently need to communicate with other processes. For example, in a shell pipeline, the output of the first process must be passed to

More information

Back to synchronization

Back to synchronization Back to synchronization The dining philosophers problem Deadlocks o Modeling deadlocks o Dealing with deadlocks Operating Systems, 28, I. Dinur, D. Hendler and R. Iakobashvili The Dining Philosophers Problem

More information

Yet another synchronization problem

Yet another synchronization problem Yet another synchronization problem The dining philosophers problem Deadlocks o Modeling deadlocks o Dealing with deadlocks Operating Systems, 25, Meni Adler, Danny Hendler & Roie Zivan The Dining Philosophers

More information

PESIT SOUTHCAMPUS. Question Bank

PESIT SOUTHCAMPUS. Question Bank Faculty:Sudhakar No. Of Hours:2 Question Bank UNIT : INTRODUCTION TO OPERATING SYSTEMS & THEIR CLASSIFICATION Objective: The main objective of this chapter is to study the Operating system basics & Classifications..

More information

What is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem?

What is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem? What is the Race Condition? And what is its solution? Race Condition: Where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular

More information

CISC 7310X. C10: Deadlocks. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 4/12/2018 CUNY Brooklyn College

CISC 7310X. C10: Deadlocks. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 4/12/2018 CUNY Brooklyn College CISC 7310X C10: Deadlocks Hui Chen Department of Computer & Information Science CUNY Brooklyn College 4/12/2018 CUNY Brooklyn College 1 Outline Concept of deadlock Necessary conditions Models of deadlocks

More information

Deadlock Risk Management

Deadlock Risk Management Lecture 6: Deadlocks, Deadlock Risk Management Readers and Writers with Readers Priority Shared data semaphore wrt, readcountmutex; int readcount Initialization wrt = 1; readcountmutex = 1; readcount =

More information

SNS COLLEGE OF ENGINEERING

SNS COLLEGE OF ENGINEERING SNS COLLEGE OF ENGINEERING Coimbatore. Department of Computer Science and Engineering Question Bank- Even Semester 2015-2016 CS6401 OPERATING SYSTEMS Unit-I OPERATING SYSTEMS OVERVIEW 1. Differentiate

More information

Operating Systems: Quiz2 December 15, Class: No. Name:

Operating Systems: Quiz2 December 15, Class: No. Name: Operating Systems: Quiz2 December 15, 2006 Class: No. Name: Part I (30%) Multiple Choice Each of the following questions has only one correct answer. Fill the correct one in the blank in front of each

More information

Midterm Exam. October 20th, Thursday NSC

Midterm Exam. October 20th, Thursday NSC CSE 421/521 - Operating Systems Fall 2011 Lecture - XIV Midterm Review Tevfik Koşar University at Buffalo October 18 th, 2011 1 Midterm Exam October 20th, Thursday 9:30am-10:50am @215 NSC Chapters included

More information

First Midterm Exam September 28, 2017 CS162 Operating Systems

First Midterm Exam September 28, 2017 CS162 Operating Systems University of California, Berkeley College of Engineering Computer Science Division EECS Fall 2017 Ion Stoica First Midterm Exam September 28, 2017 CS162 Operating Systems Your Name: SID AND 162 Login

More information

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008. CSC 4103 - Operating Systems Spring 2008 Lecture - XII Midterm Review Tevfik Ko!ar Louisiana State University March 4 th, 2008 1 I/O Structure After I/O starts, control returns to user program only upon

More information

The Deadlock Problem (1)

The Deadlock Problem (1) Deadlocks The Deadlock Problem (1) A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set. Example System has 2 disk drives. P 1 and P 2

More information

Chapter 6: Process Synchronization. Operating System Concepts 8 th Edition,

Chapter 6: Process Synchronization. Operating System Concepts 8 th Edition, Chapter 6: Process Synchronization, Silberschatz, Galvin and Gagne 2009 Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores

More information

4.5 Cigarette smokers problem

4.5 Cigarette smokers problem 4.5 Cigarette smokers problem The cigarette smokers problem problem was originally presented by Suhas Patil [8], who claimed that it cannot be solved with semaphores. That claim comes with some qualifications,

More information

The Deadlock Problem

The Deadlock Problem The Deadlock Problem A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set. Example System has 2 disk drives. P 1 and P 2 each hold one

More information

Deadlocks. Copyright : University of Illinois CS 241 Staff 1

Deadlocks. Copyright : University of Illinois CS 241 Staff 1 Deadlocks 1 Addressing Deadlock Prevention Design the system so that deadlock is impossible Avoidance Construct a model of system states, then choose a strategy that, when resources are assigned to processes,

More information

Chapter 7: Deadlocks

Chapter 7: Deadlocks Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock Chapter

More information

Operating System: Chap7 Deadlocks. National Tsing-Hua University 2016, Fall Semester

Operating System: Chap7 Deadlocks. National Tsing-Hua University 2016, Fall Semester Operating System: Chap7 Deadlocks National Tsing-Hua University 2016, Fall Semester Overview System Model Deadlock Characterization Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from

More information

Department of Computer applications. [Part I: Medium Answer Type Questions]

Department of Computer applications. [Part I: Medium Answer Type Questions] Department of Computer applications BBDNITM, Lucknow MCA 311: OPERATING SYSTEM [Part I: Medium Answer Type Questions] UNIT 1 Q1. What do you mean by an Operating System? What are the main functions of

More information

MC7204 OPERATING SYSTEMS

MC7204 OPERATING SYSTEMS MC7204 OPERATING SYSTEMS QUESTION BANK UNIT I INTRODUCTION 9 Introduction Types of operating systems operating systems structures Systems components operating systems services System calls Systems programs

More information

The Deadlock Problem

The Deadlock Problem Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock The Deadlock

More information

Concurrency: Deadlock and Starvation

Concurrency: Deadlock and Starvation Concurrency: Deadlock and Starvation Chapter 6 E&CE 354: Processes 1 Deadlock Deadlock = situation in which every process from a set is permanently blocked, i.e. cannot proceed with execution Common cause:

More information

Operating Systems CMPSC 473 Midterm 2 Review April 15, Lecture 21 Instructor: Trent Jaeger

Operating Systems CMPSC 473 Midterm 2 Review April 15, Lecture 21 Instructor: Trent Jaeger Operating Systems CMPSC 473 Midterm Review April 15, 8 - Lecture 1 Instructor: Trent Jaeger Scope Chapter 6 -- Synchronization Chapter 7 -- Deadlocks Chapter 8 -- Main Memory (Physical) Chapter 9 -- Virtual

More information

Chapter 7: Deadlocks

Chapter 7: Deadlocks Chapter 7: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock Combined Approach to Deadlock

More information

CS 318 Principles of Operating Systems

CS 318 Principles of Operating Systems CS 318 Principles of Operating Systems Fall 2017 Midterm Review Ryan Huang 10/12/17 CS 318 Midterm Review 2 Midterm October 17 th Tuesday 9:00-10:20 am at classroom Covers material before virtual memory

More information

Programming Languages

Programming Languages Programming Languages Tevfik Koşar Lecture - XXVI April 27 th, 2006 1 Roadmap Shared Memory Synchronization Spin Locks Barriers Semaphores Monitors 2 1 Memory Architectures Distributed Memory Shared Memory

More information

Chapter 7: Deadlocks. Operating System Concepts 8 th Edition,! Silberschatz, Galvin and Gagne 2009!

Chapter 7: Deadlocks. Operating System Concepts 8 th Edition,! Silberschatz, Galvin and Gagne 2009! Chapter 7: Deadlocks Operating System Concepts 8 th Edition,! Silberschatz, Galvin and Gagne 2009! Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling

More information

ECE519 Advanced Operating Systems

ECE519 Advanced Operating Systems IT 540 Operating Systems ECE519 Advanced Operating Systems Prof. Dr. Hasan Hüseyin BALIK (6 th Week) (Advanced) Operating Systems 6. Concurrency: Deadlock and Starvation 6. Outline Principles of Deadlock

More information

Filesystems (just a bit): File allocation tables, free-bitmaps, free-lists, inodes, and performance considerations.

Filesystems (just a bit): File allocation tables, free-bitmaps, free-lists, inodes, and performance considerations. CSCI 346 Final Exam Review Questions -- Solutions The final exam will be Tuesday, May 17, 11:30-2:00 PM, in Swords 328. If you have not made arrangements with me and confirmed by email, you must take the

More information

Lecture #10: Synchronization wrap up

Lecture #10: Synchronization wrap up Lecture #10: Synchronization wrap up Review -- 1 min Monitor = lock + condition variables Mesa v. Hoare semantics Advice/Summary Fall 2001 midterm: Every program with incorrect semantic behavior violated

More information

CS 550 Operating Systems Spring Concurrency Semaphores, Condition Variables, Producer Consumer Problem

CS 550 Operating Systems Spring Concurrency Semaphores, Condition Variables, Producer Consumer Problem 1 CS 550 Operating Systems Spring 2018 Concurrency Semaphores, Condition Variables, Producer Consumer Problem Semaphore Semaphore is a fundamental synchronization primitive used for Locking around critical

More information

UNIT:2. Process Management

UNIT:2. Process Management 1 UNIT:2 Process Management SYLLABUS 2.1 Process and Process management i. Process model overview ii. Programmers view of process iii. Process states 2.2 Process and Processor Scheduling i Scheduling Criteria

More information

CSC 1600: Chapter 6. Synchronizing Threads. Semaphores " Review: Multi-Threaded Processes"

CSC 1600: Chapter 6. Synchronizing Threads. Semaphores  Review: Multi-Threaded Processes CSC 1600: Chapter 6 Synchronizing Threads with Semaphores " Review: Multi-Threaded Processes" 1 badcnt.c: An Incorrect Program" #define NITERS 1000000 unsigned int cnt = 0; /* shared */ int main() pthread_t

More information

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy Operating Systems Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. AL-AZHAR University Website : eaymanelshenawy.wordpress.com Email : eaymanelshenawy@yahoo.com Reference

More information

Lecture 7 Deadlocks (chapter 7)

Lecture 7 Deadlocks (chapter 7) Bilkent University Department of Computer Engineering CS342 Operating Systems Lecture 7 Deadlocks (chapter 7) Dr. İbrahim Körpeoğlu http://www.cs.bilkent.edu.tr/~korpe 1 References The slides here are

More information

CS630 Operating System Design, Second Exam, Fall 2014

CS630 Operating System Design, Second Exam, Fall 2014 CS630 Operating System Design, Second Exam, Fall 2014 Problem 1. (25 Points) Assume that a process executes the following pseudo codes: #5 #6 #7 main (int argc, char *argv[ ]) { int i, keyin; /* the last

More information

Chapter 7: Deadlocks. Operating System Concepts 8 th Edition,

Chapter 7: Deadlocks. Operating System Concepts 8 th Edition, Chapter 7: Deadlocks, Silberschatz, Galvin and Gagne 2009 Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance

More information

CS153: Midterm (Winter 19)

CS153: Midterm (Winter 19) CS153: Midterm (Winter 19) Name: Student ID: Answer all questions. State any assumptions clearly. Problem 1: (24 points; 5 minutes) Indicate whether each of the following statements is true or false: (T)

More information

CSE306 - Homework2 and Solutions

CSE306 - Homework2 and Solutions CSE306 - Homework2 and Solutions Note: your solutions must contain enough information to enable the instructor to judge whether you understand the material or not. Simple yes/no answers do not count. A

More information

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING UNIT I

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING UNIT I DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Year and Semester : II / IV Subject Code : CS6401 Subject Name : Operating System Degree and Branch : B.E CSE UNIT I 1. Define system process 2. What is an

More information

OPERATING SYSTEMS. Prescribed Text Book. Operating System Principles, Seventh Edition. Abraham Silberschatz, Peter Baer Galvin and Greg Gagne

OPERATING SYSTEMS. Prescribed Text Book. Operating System Principles, Seventh Edition. Abraham Silberschatz, Peter Baer Galvin and Greg Gagne OPERATING SYSTEMS Prescribed Text Book Operating System Principles, Seventh Edition By Abraham Silberschatz, Peter Baer Galvin and Greg Gagne 1 DEADLOCKS In a multi programming environment, several processes

More information

PESIT Bangalore South Campus

PESIT Bangalore South Campus INTERNAL ASSESSMENT TEST II Date: 04/04/2018 Max Marks: 40 Subject & Code: Operating Systems 15CS64 Semester: VI (A & B) Name of the faculty: Mrs.Sharmila Banu.A Time: 8.30 am 10.00 am Answer any FIVE

More information

CSE 120 Principles of Operating Systems

CSE 120 Principles of Operating Systems CSE 120 Principles of Operating Systems Fall 2016 Lecture 8: Scheduling and Deadlock Geoffrey M. Voelker Administrivia Thursday Friday Monday Homework #2 due at start of class Review material for midterm

More information

Chapter 7: Deadlocks. Chapter 7: Deadlocks. The Deadlock Problem. Chapter Objectives. System Model. Bridge Crossing Example

Chapter 7: Deadlocks. Chapter 7: Deadlocks. The Deadlock Problem. Chapter Objectives. System Model. Bridge Crossing Example Silberschatz, Galvin and Gagne 2009 Chapter 7: Deadlocks Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance

More information

OPERATING SYSTEMS. Deadlocks

OPERATING SYSTEMS. Deadlocks OPERATING SYSTEMS CS3502 Spring 2018 Deadlocks Chapter 7 Resource Allocation and Deallocation When a process needs resources, it will normally follow the sequence: 1. Request a number of instances of one

More information

Chapter 7: Deadlocks. Operating System Concepts 8th Edition, modified by Stewart Weiss

Chapter 7: Deadlocks. Operating System Concepts 8th Edition, modified by Stewart Weiss Chapter 7: Deadlocks, Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance (briefly) Deadlock Detection

More information

Operating Systems ECE344. Ding Yuan

Operating Systems ECE344. Ding Yuan Operating Systems ECE344 Ding Yuan Deadlock Synchronization is a live gun we can easily shoot ourselves in the foot Incorrect use of synchronization can block all processes We have talked about this problem

More information

1995 Paper 10 Question 7

1995 Paper 10 Question 7 995 Paper 0 Question 7 Why are multiple buffers often used between producing and consuming processes? Describe the operation of a semaphore. What is the difference between a counting semaphore and a binary

More information

CSE 153 Design of Operating Systems

CSE 153 Design of Operating Systems CSE 153 Design of Operating Systems Winter 2018 Midterm Review Midterm in class on Monday Covers material through scheduling and deadlock Based upon lecture material and modules of the book indicated on

More information

Deadlocks. Thomas Plagemann. With slides from C. Griwodz, K. Li, A. Tanenbaum and M. van Steen

Deadlocks. Thomas Plagemann. With slides from C. Griwodz, K. Li, A. Tanenbaum and M. van Steen Deadlocks Thomas Plagemann With slides from C. Griwodz, K. Li, A. Tanenbaum and M. van Steen Preempting Scheduler Activations Scheduler activations are completely preemptable User" space" Kernel " space"

More information

OPERATING SYSTEMS. After A.S.Tanenbaum, Modern Operating Systems, 3rd edition. Uses content with permission from Assoc. Prof. Florin Fortis, PhD

OPERATING SYSTEMS. After A.S.Tanenbaum, Modern Operating Systems, 3rd edition. Uses content with permission from Assoc. Prof. Florin Fortis, PhD OPERATING SYSTEMS #4 After A.S.Tanenbaum, Modern Operating Systems, 3rd edition Uses content with permission from Assoc. Prof. Florin Fortis, PhD DEADLOCKS General Information DEADLOCKS RESOURCE T YPE

More information

1. Consider the following page reference string: 1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3, 6.

1. Consider the following page reference string: 1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3, 6. 1. Consider the following page reference string: 1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3, 6. What will be the ratio of page faults for the following replacement algorithms - FIFO replacement

More information

Deadlock Risk Management

Deadlock Risk Management Lecture 5: Deadlocks, Deadlock Risk Management Contents The Concept of Deadlock Resource Allocation Graph Approaches to Handling Deadlocks Deadlock Avoidance Deadlock Detection Recovery from Deadlock AE3B33OSD

More information

Chapter 7 : 7: Deadlocks Silberschatz, Galvin and Gagne 2009 Operating System Concepts 8th Edition, Chapter 7: Deadlocks

Chapter 7 : 7: Deadlocks Silberschatz, Galvin and Gagne 2009 Operating System Concepts 8th Edition, Chapter 7: Deadlocks Chapter 7: Deadlocks, Silberschatz, Galvin and Gagne 2009 Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance

More information

CS 318 Principles of Operating Systems

CS 318 Principles of Operating Systems CS 318 Principles of Operating Systems Fall 2017 Lecture 8: Deadlock Ryan Huang Administrivia Lab 1 deadline extended - Friday 09/29 11:59 pm - Saturday 09/30 11:59 pm [Hard] HW2 out - should try to solve

More information