CS450 OPERATING SYSTEMS FINAL EXAM ANSWER KEY

Size: px
Start display at page:

Download "CS450 OPERATING SYSTEMS FINAL EXAM ANSWER KEY"

Transcription

1 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); method names should adhere to the interface defined in class. Make sure to document each method by saying what it should do. Be brief! Hint: you should have two different object classes.( Points 15) : Class Lock { ThreadQueue Q; Acquire(); //fun to acquire lock Release(); //fun to release lock Class ConditionVar { ThreadQueue Q; Sleep(Lock lock); /* sleep thread until someone wakes it up */ Wake(); /* wake one sleeping thread */ WakeAll(); /* wake all sleeping threads */ Also accepted: Wait(Lock lock); Signal(); Broadcast(); 2. Six jobs are waiting to be run. Their expected running times are 10, 8, 6, 3, 1, and X. In what order should they be run to minimize average completion time? State the scheduling algorithm that should be used AND the order in which the jobs should be run. (Your answer will depend on X). (Points 10) Shortest Job First or Shortest Remaining Processing Time X <= 1 X, 1, 3, 6, 8, 10 Answers that mentioned something about scheduling X by 1 < X <= 3 1, X, 3, 6, 8, 10 ordering the processes in ascending order by running times 3 < X <= 6 1, 3, X, 6, 8, 10 were accepted. 6 < X <= 8 1, 3, 6, X, 8, 10 8 < X <= 10 1, 3, 6, 8, X, 10 X > 10 1, 3, 6, 8, 10, X CS450 FINAL EXAM KEY PAGE - 1

2 3. Here is a table of processes and their associated running times. All of the processes arrive in numerical order at time 0. Process ID CPU Running Time Process 1 2 Process 2 6 Process 3 1 Process 4 4 Process 5 3 Show the scheduling order for these processes under 3 policies: First Come First Serve (FCFS), Shortest-Remaining-Time-First (SRTF), Round-Robin (RR) with time slice quantum = 1 (Points 10) Time Slot FCFS SRTF RR Concurrency problem: Dining Philosophers. You are expected to implement a solution to the Dining Philosophers Problem using monitors instead of semaphores. Create a method Dine(), which Waits until a diner has two chopsticks and can eat, then calls Eat(), and then releases the chopsticks before returning. Your solution should allow multiple philosophers to eat at the same time (as long as there are sufficient chopsticks in a pile in the middle of the table). a. Specify the correctness constraints. Be succinct and explicit in your answer.( Points 5) CS450 FINAL EXAM KEY PAGE - 2

3 1) A diner waits for two chopsticks. 2) Only one thread accesses shared state at a time b. Implement the Dine() method. Specify any state variables that you use (Points 20) State variables: Chopsticks: Number of chopsticks left Initial value N Monitor: waitingp Lock: lock Dine() { lock.acquire(); while (chopsticks < 2) { waitingp.wait() chopsticks -= 2; lock.release(); Eat(); lock.acquire(); chopsticks +=2; waitingp.broadcast(); or signal lock.release(); 5. Assume 4 processes are ready nearly simultaneously but in the order listed below. For each scheduling algorithm, draw a Gantt chart and calculate average wait time and average turn around time. (Points 20) Burst Time Priority (higher # = higher priority) P1 6 1 P2 3 2 P P4 4 4 FCFS p1 p1 p1 p1 p1 p1 p2 p2 p2 p3 p3 p3 p3 p3 p3 p3 p3 p3 p3 p3 p3 p4 p4 CS450 FINAL EXAM KEY PAGE - 3

4 Average Time = =36/4 Average Turn around Time = =61/4 SJF p2 p2 p2 p4 p4 p4 p4 p1 p1 p1 p1 p1 p1 p3 p3 p3 p3 p3 p3 p3 p3 p3 p3 Average Time = =23/4 Average Turn around Time = =48/4 Priority p4 p4 p4 P4 p3 p3 p3 p3 p3 p3 p3 p3 p3 p3 p3 p3 p2 p2 p2 p1 p1 p1 p1 Average Time = =39/4 Average Turn around Time = =64/4 RR (Quantum=3) p1 p1 p1 P2 p2 p2 p3 p3 p3 p4 p4 p4 p1 p1 p1 p3 p3 p3 p4 p3 p3 p3 p3 Average Time = =40/4 Average Turn around Time = =65/4 6. Another classical IPC 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 in the barber chair and goes to sleep. 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. Below is pseudocode representing the variables and semaphores needed, and the method for the barber. Using the data allready defined, write the method for a customer (customer s equivalent of cut_hair() is get_haircut() ) (Points 20) #define CHAIRS 5 /* # chairs for waiting customers */ semaphore customers=0; /* # of customers waiting for service */ semaphore barbers=0; /* # of barbers waiting for customers */ semaphore mutex=1; /* for mutual exclusion */ int waiting=0; /* customers are waiting but not being cut */ CS450 FINAL EXAM KEY PAGE - 4

5 void barber(void) { while (TRUE) { wait(customers); /* go to sleep if # of customers is 0 */ wait(mutex); /* acquire access to waiting */ waiting=waiting-1;/* decrement count of waiting customers */ signal(barbers); /* one barber is now ready to cut hair */ signal(mutex); /* release waiting */ cut_hair(); /* cut hair */ void customer(void) { wait(mutex); if(waiting<chairs) { waiting++; signal(customers); signal(mutex); wait(barbers); get_haircut(); else { signal(mutex); CS450 FINAL EXAM KEY PAGE - 5

Homework Assignment #5

Homework Assignment #5 Homework Assignment #5 Question 1: Scheduling a) Which of the following scheduling algorithms could result in starvation? For those algorithms that could result in starvation, describe a situation in which

More information

COMP 346 WINTER Tutorial 5 MONITORS

COMP 346 WINTER Tutorial 5 MONITORS COMP 346 WINTER 2018 1 Tutorial 5 MONITORS WHY DO WE NEED MONITORS? Semaphores are very useful for solving concurrency problems But it s easy to make mistakes! If proper usage of semaphores is failed by

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

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

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

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

Last Class: CPU Scheduling! Adjusting Priorities in MLFQ!

Last Class: CPU Scheduling! Adjusting Priorities in MLFQ! Last Class: CPU Scheduling! Scheduling Algorithms: FCFS Round Robin SJF Multilevel Feedback Queues Lottery Scheduling Review questions: How does each work? Advantages? Disadvantages? Lecture 7, page 1

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

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

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

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

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

OS Structure. User mode/ kernel mode. System call. Other concepts to know. Memory protection, privileged instructions

OS Structure. User mode/ kernel mode. System call. Other concepts to know. Memory protection, privileged instructions Midterm Review OS Structure User mode/ kernel mode Memory protection, privileged instructions System call Definition, examples, how it works? Other concepts to know Monolithic kernel vs. Micro kernel 2

More information

Operating Systems (1DT020 & 1TT802)

Operating Systems (1DT020 & 1TT802) Uppsala University Department of Information Technology Name: Perso. no: Operating Systems (1DT020 & 1TT802) 2009-05-27 This is a closed book exam. Calculators are not allowed. Answers should be written

More information

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

Operating Systems and Networks Course: International University Bremen Date: Dr. Jürgen Schönwälder Deadline: Operating Systems and Networks Course: 320202 International University Bremen Date: 2004-03-26 Dr. Jürgen Schönwälder Deadline: 2004-03-26 Midterm Examination Problem M.1: processes (10 points) Indicate

More information

OS Structure. User mode/ kernel mode (Dual-Mode) Memory protection, privileged instructions. Definition, examples, how it works?

OS Structure. User mode/ kernel mode (Dual-Mode) Memory protection, privileged instructions. Definition, examples, how it works? Midterm Review OS Structure User mode/ kernel mode (Dual-Mode) Memory protection, privileged instructions System call Definition, examples, how it works? Other concepts to know Monolithic kernel vs. Micro

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

Processes The Process Model. Chapter 2. Processes and Threads. Process Termination. Process Creation

Processes The Process Model. Chapter 2. Processes and Threads. Process Termination. Process Creation Chapter 2 Processes The Process Model Processes and Threads 2.1 Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling Multiprogramming of four programs Conceptual

More information

Chapter 2 Processes and Threads. Interprocess Communication Race Conditions

Chapter 2 Processes and Threads. Interprocess Communication Race Conditions Chapter 2 Processes and Threads [ ] 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling 85 Interprocess Communication Race Conditions Two processes want to access shared memory at

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

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

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

CS 537 Lecture 8 Monitors. Thread Join with Semaphores. Dining Philosophers. Parent thread. Child thread. Michael Swift

CS 537 Lecture 8 Monitors. Thread Join with Semaphores. Dining Philosophers. Parent thread. Child thread. Michael Swift CS 537 Lecture 8 Monitors Michael Swift Two Classes of Synchronization Problems Uniform resource usage with simple scheduling constraints No other variables needed to express relationships Use one semaphore

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

Processes The Process Model. Chapter 2 Processes and Threads. Process Termination. Process States (1) Process Hierarchies

Processes The Process Model. Chapter 2 Processes and Threads. Process Termination. Process States (1) Process Hierarchies Chapter 2 Processes and Threads Processes The Process Model 2.1 Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling Multiprogramming of four programs Conceptual

More information

CS 370 Operating Systems

CS 370 Operating Systems NAME S.ID. # CS 370 Operating Systems Mid-term Example Instructions: The exam time is 50 minutes. CLOSED BOOK. 1. [24 pts] Multiple choice. Check one. a. Multiprogramming is: An executable program that

More information

Deadlock and Monitors. CS439: Principles of Computer Systems September 24, 2018

Deadlock and Monitors. CS439: Principles of Computer Systems September 24, 2018 Deadlock and Monitors CS439: Principles of Computer Systems September 24, 2018 Bringing It All Together Processes Abstraction for protection Define address space Threads Share (and communicate) through

More information

Real-Time Operating Systems M. 5. Process Synchronization

Real-Time Operating Systems M. 5. Process Synchronization Real-Time Operating Systems M 5. Process Synchronization Notice The course material includes slides downloaded from: http://codex.cs.yale.edu/avi/os-book/ and (slides by Silberschatz, Galvin, and Gagne,

More information

CMPT 300: Operating Systems I Assignment 1

CMPT 300: Operating Systems I Assignment 1 POLICIES: CMPT 300: Operating Systems I Assignment 1 Sample Solution 1. Coverage Chapters 1-6 2. Grade 10 points, 100% counted into the final grade 3. Individual or Group Individual based, but group discussion

More information

More Synchronization; Concurrency in Java. CS 475, Spring 2018 Concurrent & Distributed Systems

More Synchronization; Concurrency in Java. CS 475, Spring 2018 Concurrent & Distributed Systems More Synchronization; Concurrency in Java CS 475, Spring 2018 Concurrent & Distributed Systems Review: Semaphores Synchronization tool that provides more sophisticated ways (than Mutex locks) for process

More information

Chapter 2 Processes and Threads

Chapter 2 Processes and Threads MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 2 Processes and Threads The Process Model Figure 2-1. (a) Multiprogramming of four programs. (b) Conceptual model of four independent,

More information

Synchronization. CS 475, Spring 2018 Concurrent & Distributed Systems

Synchronization. CS 475, Spring 2018 Concurrent & Distributed Systems Synchronization CS 475, Spring 2018 Concurrent & Distributed Systems Review: Threads: Memory View code heap data files code heap data files stack stack stack stack m1 m1 a1 b1 m2 m2 a2 b2 m3 m3 a3 m4 m4

More information

KEY CENG 334. Midterm. Question 1. Question 2. Question 3. Question 4. Question 5. Question 6. Total. Name, SURNAME and ID

KEY CENG 334. Midterm. Question 1. Question 2. Question 3. Question 4. Question 5. Question 6. Total. Name, SURNAME and ID 00 11 00 11 01 01 01 01 01 01 00 11 00 11 Name, SURNAME and ID Middle East Technical University Department of Computer Engineering KEY CENG 334 Section 2 and 3 Spring 2010-2011 Midterm Duration: 120 minutes.

More information

Review. Preview. Three Level Scheduler. Scheduler. Process behavior. Effective CPU Scheduler is essential. Process Scheduling

Review. Preview. Three Level Scheduler. Scheduler. Process behavior. Effective CPU Scheduler is essential. Process Scheduling Review Preview Mutual Exclusion Solutions with Busy Waiting Test and Set Lock Priority Inversion problem with busy waiting Mutual Exclusion with Sleep and Wakeup The Producer-Consumer Problem Race Condition

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

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

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

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

Department of CSIT ( G G University, Bilaspur ) Model Answer 2013 (Even Semester) - AR-7307

Department of CSIT ( G G University, Bilaspur ) Model Answer 2013 (Even Semester) - AR-7307 Department of CSIT ( G G University, Bilaspur ) Model Answer 2013 (Even Semester) - AR-7307 Class: MCA Semester: II Year:2013 Paper Title: Principles of Operating Systems Max Marks: 60 Section A: (All

More information

What's wrong with Semaphores?

What's wrong with Semaphores? Next: Monitors and Condition Variables What is wrong with semaphores? Monitors What are they? How do we implement monitors? Two types of monitors: Mesa and Hoare Compare semaphore and monitors Lecture

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

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 8: Semaphores, Monitors, & Condition Variables

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 8: Semaphores, Monitors, & Condition Variables CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2004 Lecture 8: Semaphores, Monitors, & Condition Variables 8.0 Main Points: Definition of semaphores Example of use

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

Deadlock and Monitors. CS439: Principles of Computer Systems February 7, 2018

Deadlock and Monitors. CS439: Principles of Computer Systems February 7, 2018 Deadlock and Monitors CS439: Principles of Computer Systems February 7, 2018 Last Time Terminology Safety and liveness Atomic Instructions, Synchronization, Mutual Exclusion, Critical Sections Synchronization

More information

Synchronization. CSE 2431: Introduction to Operating Systems Reading: Chapter 5, [OSC] (except Section 5.10)

Synchronization. CSE 2431: Introduction to Operating Systems Reading: Chapter 5, [OSC] (except Section 5.10) Synchronization CSE 2431: Introduction to Operating Systems Reading: Chapter 5, [OSC] (except Section 5.10) 1 Outline Critical region and mutual exclusion Mutual exclusion using busy waiting Sleep and

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

Maximum CPU utilization obtained with multiprogramming. CPU I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait

Maximum CPU utilization obtained with multiprogramming. CPU I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Thread Scheduling Operating Systems Examples Java Thread Scheduling Algorithm Evaluation CPU

More information

Lecture 7: CVs & Scheduling

Lecture 7: CVs & Scheduling Lecture 7: CVs & Scheduling CSE 120: Principles of Operating Systems Alex C. Snoeren HW 2 Due 10/17 Monitors A monitor is a programming language construct that controls access to shared data Synchronization

More information

King Saud University. College of Computer & Information Sciences. Information Technology Department. IT425: Operating Systems.

King Saud University. College of Computer & Information Sciences. Information Technology Department. IT425: Operating Systems. King Saud University College of Computer & Information Sciences Information Technology Department IT425: Operating Systems Assignment 6 Second Semester 1433/1434H 2012/2013 Homework policy: 1) Copying

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

CPU Scheduling Algorithms

CPU Scheduling Algorithms CPU Scheduling Algorithms Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating Systems Concepts with Java, by Silberschatz, Galvin, and Gagne (2007).

More information

Midterm I October 11 th, 2006 CS162: Operating Systems and Systems Programming

Midterm I October 11 th, 2006 CS162: Operating Systems and Systems Programming University of California, Berkeley College of Engineering Computer Science Division EECS Fall 2006 John Kubiatowicz Midterm I October 11 th, 2006 CS162: Operating Systems and Systems Programming Your Name:

More information

Today: Synchronization. Recap: Synchronization

Today: Synchronization. Recap: Synchronization Today: Synchronization Synchronization Mutual exclusion Critical sections Example: Too Much Milk Locks Synchronization primitives are required to ensure that only one thread executes in a critical section

More information

CSE 120 Principles of Computer Operating Systems Fall Quarter, 2002 Halloween Midterm Exam. Instructor: Geoffrey M. Voelker

CSE 120 Principles of Computer Operating Systems Fall Quarter, 2002 Halloween Midterm Exam. Instructor: Geoffrey M. Voelker CSE 120 Principles of Computer Operating Systems Fall Quarter, 2002 Halloween Midterm Exam Instructor: Geoffrey M. Voelker Name Student ID Attention: This exam has six questions worth a total of 70 points.

More information

QUESTION BANK. UNIT II: PROCESS SCHEDULING AND SYNCHRONIZATION PART A (2 Marks)

QUESTION BANK. UNIT II: PROCESS SCHEDULING AND SYNCHRONIZATION PART A (2 Marks) QUESTION BANK DEPARTMENT: EEE SEMESTER VII SUBJECT CODE: CS2411 SUBJECT NAME: OS UNIT II: PROCESS SCHEDULING AND SYNCHRONIZATION PART A (2 Marks) 1. What is deadlock? (AUC NOV2010) A deadlock is a situation

More information

UNIT 2 Basic Concepts of CPU Scheduling. UNIT -02/Lecture 01

UNIT 2 Basic Concepts of CPU Scheduling. UNIT -02/Lecture 01 1 UNIT 2 Basic Concepts of CPU Scheduling UNIT -02/Lecture 01 Process Concept An operating system executes a variety of programs: **Batch system jobs **Time-shared systems user programs or tasks **Textbook

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

Midterm Exam March 13, 2013 CS162 Operating Systems

Midterm Exam March 13, 2013 CS162 Operating Systems University of California, Berkeley College of Engineering Computer Science Division EECS Spring 2013 Anthony D. Joseph Midterm Exam March 13, 2013 CS162 Operating Systems Your Name: SID AND 162 Login:

More information

What are they? How do we represent them? Scheduling Something smaller than a process? Threads Synchronizing and Communicating Classic IPC problems

What are they? How do we represent them? Scheduling Something smaller than a process? Threads Synchronizing and Communicating Classic IPC problems Processes What are they? How do we represent them? Scheduling Something smaller than a process? Threads Synchronizing and Communicating Classic IPC problems Processes The Process Model a) Multiprogramming

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

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

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

CS 333 Introduction to Operating Systems. Class 6 Monitors and Message Passing. Jonathan Walpole Computer Science Portland State University

CS 333 Introduction to Operating Systems. Class 6 Monitors and Message Passing. Jonathan Walpole Computer Science Portland State University CS 333 Introduction to Operating Systems Class 6 Monitors and Message Passing Jonathan Walpole Computer Science Portland State University 1 But first Continuation of Class 5 Classical Synchronization Problems

More information

CS630 Operating System Design, First Exam, Spring 2017,

CS630 Operating System Design, First Exam, Spring 2017, First Exam, Spring 2017, Problem 1. (35 Points) Assume that P A, P B and P C are three distinctive programs. When P A is executed, it forks new processes executing P B at tick-marks 2, 5 and 7 and its

More information

Threads. Threads The Thread Model (1) CSCE 351: Operating System Kernels Witawas Srisa-an Chapter 4-5

Threads. Threads The Thread Model (1) CSCE 351: Operating System Kernels Witawas Srisa-an Chapter 4-5 Threads CSCE 351: Operating System Kernels Witawas Srisa-an Chapter 4-5 1 Threads The Thread Model (1) (a) Three processes each with one thread (b) One process with three threads 2 1 The Thread Model (2)

More information

Last class: Today: CPU Scheduling. CPU Scheduling Algorithms and Systems

Last class: Today: CPU Scheduling. CPU Scheduling Algorithms and Systems 1 Last class: CPU Scheduling Today: CPU Scheduling Algorithms and Systems 2 Scheduling Algorithms First-come, First-serve (FCFS) Non-preemptive Does not account for waiting time (or much else) Convoy problem

More information

Introduction to Operating Systems

Introduction to Operating Systems Introduction to Operating Systems Lecture 4: Process Synchronization MING GAO SE@ecnu (for course related communications) mgao@sei.ecnu.edu.cn Mar. 18, 2015 Outline 1 The synchronization problem 2 A roadmap

More information

Semaphores. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Semaphores. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University Semaphores Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu EEE3052: Introduction to Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) Synchronization

More information

Operating systems. Lecture 12

Operating systems. Lecture 12 Operating systems. Lecture 12 Michał Goliński 2018-12-18 Introduction Recall Critical section problem Peterson s algorithm Synchronization primitives Mutexes Semaphores Plan for today Classical problems

More information

CS Mid term Exam Maximum points 100; Maximum time allowed: 75 minutes

CS Mid term Exam Maximum points 100; Maximum time allowed: 75 minutes CS 470 - Mid term Exam Maximum points 100; Maximum time allowed: 75 minutes Name: Note: Answer all questions. Your answers should be brief and precise to the point. Note that a statement is true means

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

Properties of Processes

Properties of Processes CPU Scheduling Properties of Processes CPU I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait. CPU burst distribution: CPU Scheduler Selects from among the processes that

More information

Semaphores (by Dijkstra)

Semaphores (by Dijkstra) CSCI 4401 Principles of Operating Systems I Process Synchronization II: Classic Problems Vassil Roussev vassil@cs.uno.edu Semaphores (by Dijkstra) A higher-level way of doing synchronization between threads/processes

More information

CS-537: Midterm Exam (Spring 2001)

CS-537: Midterm Exam (Spring 2001) CS-537: Midterm Exam (Spring 2001) Please Read All Questions Carefully! There are seven (7) total numbered pages Name: 1 Grading Page Points Total Possible Part I: Short Answers (12 5) 60 Part II: Long

More information

Student Name: University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science

Student Name: University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science CS 162 Spring 2011 I. Stoica FIRST MIDTERM EXAMINATION Wednesday, March 9, 2011 INSTRUCTIONS

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

( B ) 4. Which is not able to solve the race condition? (A) Test and Set Lock (B) Shared memory (C) Semaphore (D) Monitor

( B ) 4. Which is not able to solve the race condition? (A) Test and Set Lock (B) Shared memory (C) Semaphore (D) Monitor CS 540 - Operating Systems - Final Exam - Name: Date: Monday, May 12, 2003 Part 1: (80 + 8 (bonus) points - 4 points for each problem) ( C ) 1. In an operating system a utility which reads commands from

More information

CS 153 Design of Operating Systems Winter 2016

CS 153 Design of Operating Systems Winter 2016 CS 153 Design of Operating Systems Winter 2016 Lecture 12: Scheduling & Deadlock Priority Scheduling Priority Scheduling Choose next job based on priority» Airline checkin for first class passengers Can

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

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

ECE 462 Object-Oriented Programming using C++ and Java. Scheduling and Critical Section

ECE 462 Object-Oriented Programming using C++ and Java. Scheduling and Critical Section ECE 462 Object-Oriented Programming g using C++ and Java Scheduling and Critical Section Yung-Hsiang Lu yunglu@purdue.edu d YHL Scheduling and Critical Section 1 Thread States born terminated ready running

More information

OS 1 st Exam Name Solution St # (Q1) (19 points) True/False. Circle the appropriate choice (there are no trick questions).

OS 1 st Exam Name Solution St # (Q1) (19 points) True/False. Circle the appropriate choice (there are no trick questions). OS 1 st Exam Name Solution St # (Q1) (19 points) True/False. Circle the appropriate choice (there are no trick questions). (a) (b) (c) (d) (e) (f) (g) (h) (i) T_ The two primary purposes of an operating

More information

Sample Questions. Amir H. Payberah. Amirkabir University of Technology (Tehran Polytechnic)

Sample Questions. Amir H. Payberah. Amirkabir University of Technology (Tehran Polytechnic) Sample Questions Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir H. Payberah (Tehran Polytechnic) Sample Questions 1393/8/10 1 / 29 Question 1 Suppose a thread

More information

Chapter 6: CPU Scheduling

Chapter 6: CPU Scheduling Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Thread Scheduling Operating Systems Examples Java Thread Scheduling

More information

Operating Systems. Week 7 5 th Semester, 2012 IN Fei Peng PAI Group University of Fribourg

Operating Systems. Week 7 5 th Semester, 2012 IN Fei Peng PAI Group University of Fribourg Operating Systems Week 7 5 th Semester, 2012 IN. 5012 Fei Peng PAI Group University of Fribourg 6.1 Dining Philosophers Problem a. In the solution to the dining philosophers problem (Fig. 2-20), why is

More information

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst Operating Systems CMPSCI 377 Spring 2017 Mark Corner University of Massachusetts Amherst Clicker Question #1 If we have 100 threads and 100 processors, how often does Hello get printed? (A) 100 times per

More information

COMP SCI 3SH3: Operating System Concepts (Term 2 Winter 2006) Test 2 February 27, 2006; Time: 50 Minutes ;. Questions Instructor: Dr.

COMP SCI 3SH3: Operating System Concepts (Term 2 Winter 2006) Test 2 February 27, 2006; Time: 50 Minutes ;. Questions Instructor: Dr. COMP SCI 3SH3: Operating System Concepts (Term 2 Winter 2006) Test 2 February 27, 2006; Time: 50 Minutes ;. Questions Instructor: Dr. Kamran Sartipi Name: Student ID: Question 1 (Disk Block Allocation):

More information

Midterm Exam #1 February 28, 2018 CS162 Operating Systems

Midterm Exam #1 February 28, 2018 CS162 Operating Systems University of California, Berkeley College of Engineering Computer Science Division EECS Spring 2018 Anthony D. Joseph and Jonathan Ragan-Kelley Midterm Exam #1 February 28, 2018 CS162 Operating Systems

More information

Midterm I October 12 th, 2005 CS162: Operating Systems and Systems Programming

Midterm I October 12 th, 2005 CS162: Operating Systems and Systems Programming University of California, Berkeley College of Engineering Computer Science Division EECS Fall 2005 John Kubiatowicz Midterm I October 12 th, 2005 CS162: Operating Systems and Systems Programming Your Name:

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

AC59/AT59/AC110/AT110 OPERATING SYSTEMS & SYSTEMS SOFTWARE DEC 2015

AC59/AT59/AC110/AT110 OPERATING SYSTEMS & SYSTEMS SOFTWARE DEC 2015 Q.2 a. Explain the following systems: (9) i. Batch processing systems ii. Time sharing systems iii. Real-time operating systems b. Draw the process state diagram. (3) c. What resources are used when a

More information

EECE.4810/EECE.5730: Operating Systems Spring 2017 Homework 3 Solution

EECE.4810/EECE.5730: Operating Systems Spring 2017 Homework 3 Solution 1. (16 points) Consider the following set of processes, with the length of the CPU-burst time given in milliseconds: Process Burst Priority P1 20 4 P2 5 3 P3 30 2 P4 2 3 P5 5 1 a. (12 points) Assume the

More information

CS370 Operating Systems Midterm Review. Yashwant K Malaiya Spring 2019

CS370 Operating Systems Midterm Review. Yashwant K Malaiya Spring 2019 CS370 Operating Systems Midterm Review Yashwant K Malaiya Spring 2019 1 1 Computer System Structures Computer System Operation Stack for calling functions (subroutines) I/O Structure: polling, interrupts,

More information

ALL the assignments (A1, A2, A3) and Projects (P0, P1, P2) we have done so far.

ALL the assignments (A1, A2, A3) and Projects (P0, P1, P2) we have done so far. Midterm Exam Reviews ALL the assignments (A1, A2, A3) and Projects (P0, P1, P2) we have done so far. Particular attentions on the following: System call, system kernel Thread/process, thread vs process

More information

Last Class: Synchronization. Review. Semaphores. Today: Semaphores. MLFQ CPU scheduler. What is test & set?

Last Class: Synchronization. Review. Semaphores. Today: Semaphores. MLFQ CPU scheduler. What is test & set? Last Class: Synchronization Review Synchronization Mutual exclusion Critical sections Example: Too Much Milk Locks Synchronization primitives are required to ensure that only one thread executes in a critical

More information

Last Class: Synchronization

Last Class: Synchronization Last Class: Synchronization Synchronization primitives are required to ensure that only one thread executes in a critical section at a time. Concurrent programs Low-level atomic operations (hardware) load/store

More information

Operating Systems (Classroom Practice Booklet Solutions)

Operating Systems (Classroom Practice Booklet Solutions) Operating Systems (Classroom Practice Booklet Solutions) 1. Process Management I 1. Ans: (c) 2. Ans: (c) 3. Ans: (a) Sol: Software Interrupt is generated as a result of execution of a privileged instruction.

More information

CSC 716 Advanced Operating System Fall 2007 Exam 1. Answer all the questions. The maximum credit for each question is as shown.

CSC 716 Advanced Operating System Fall 2007 Exam 1. Answer all the questions. The maximum credit for each question is as shown. CSC 716 Advanced Operating System Fall 2007 Exam 1 Answer all the questions. The maximum credit for each question is as shown. 1. (15) Multiple Choice(3 points for each): 1) Which of the following statement

More information

1.1 CPU I/O Burst Cycle

1.1 CPU I/O Burst Cycle PROCESS SCHEDULING ALGORITHMS As discussed earlier, in multiprogramming systems, there are many processes in the memory simultaneously. In these systems there may be one or more processors (CPUs) but the

More information