Midterm Exam Amy Murphy 19 March 2003

Size: px
Start display at page:

Download "Midterm Exam Amy Murphy 19 March 2003"

Transcription

1 University of Rochester Midterm Exam Amy Murphy 19 March 2003 Computer Systems (CSC2/456) Read before beginning: Please write clearly. Illegible answers cannot be graded. Be sure to identify all of your answers in your blue book (e.g., 1a, 2b, etc). All questions are worth 10 points, numbers in parenthesis indicate relative point values. While I have tried to make the questions as unambiguous as possible, if you need to make any assumptions in order to continue, state these as clearly as possible as part of your answer. In the name of fairness, I would like to avoid answering questions during the exam. CSC256: Students enrolled in 256 must choose 6 of the 8 questions to answer. For up to 10 extra credit points, you may answer one of the other 2 questions, indicating clearly on the front of the bluebook which question is to be counted as extra credit. If you do not specify, I will assume the first 6 in your bluebook are for normal credit and the next one (if any) is extra. If you answer all 8 questions, only 7 of them will be counted toward your grade. Grades will be assigned 0-60 (with 10 possible extra credit). CSC456: Students enrolled in 456 must choose 7 of the 8 questions to answer. For extra credit, you may answer the 8th question, but you must clearly identify which question is to be counted as extra. If you do not indicate any, I will assume the 8th answer (if any) is extra. Grades will be assigned 0-70 (with 10 possible extra credit) 1. Short answer. Your responses for each part should be at most 3-4 lines of text: (a) (3) What is the difference between deadlock and starvation? In a deadlock situation, none of the involved processes can possibly make progress. In a starvation situation, a process is ready to execute, but it is not being allowed to execute. (b) (3) What is the difference between a process and a thread? Every process has its own address space, but multiple threads inside a process share part of the memory with their parent process. There is less context switching overhead to switch among threads when compared to switching among threads. (c) (4) What are two types of low-level operations that higher-level synchronization operations (e.g., semaphores and monitors) can be built upon? test-and-set. compare-and-swap. atomic reads and writes. Other atomic operations. enabling and disabling interrupts. 2. Device management. You were just hired to work on a research project with a graphics professor. He has a program that takes an input image and searches through a bunch of images in a database in order to find matching images. It does not need to look at every image, but it must look at a large percentage of the images. Further, not all of the images will fit into memory, so the program spends most of its time doing disk read operations. You are given a single-threaded version of this program that works and it is your job is to make it run faster. (a) (5) Your first idea: arrange the images on the disk so that the ones that are queried tend to be located together on the disk. This requires you to change the file management portion of the OS in order to control the data layout, but you re an intelligent OS student (who has been all the way through the course, including the part on file management) and this is an easy task. After the modifications, the program runs faster! Why? 1

2 This has the effect of reducing the seek time to move the head to the desired data. By reducing the head movement, the I/O accesses are faster and the program, which is I/O bound, runs faster. (b) (5) Even though you achieved some speedup, the professor isn t happy because you modified the OS. This means that his program now runs fast only on specific machines, and he wants it to run on any machine. So, back to the drawing board. Your second idea: add multiple threads. Although all the machines you are working on are single-processor, you amazingly still achieve a speedup. Why? A minor speedup is obtained because you now have a I/O and CPU operations occurring in parallel. A larger speedup is gained because the disk manager now has a larger set of disk locations to choose from for retrieving data, and it can optimize the order in which they are served to minimize head movement and maximize the disk bandwidth, again speeding up the program. 3. Processes lifetime. (10) The figure below shows a simple state transition diagram for sequential processes. Suppose that the operating system wishes to implement the two system calls SUSPEND and RESUME. The SUSPEND call can be used by one process to suspend the execution of another process. (A process cannot SUSPEND itself.) The suspended process remains suspended until it is RESUMEd by the process that originally suspended it. While a process is suspended it cannot run. Redraw the figure in your bluebook, adding transitions and/or states to account for the SUSPEND and RESUME system calls. Label any new transitions to indicate what caused the transition to occur, much as the existing transitions are already labeled. Label any new states you add and briefly describe their purpose. scheduled RUN READY quantum expires suspended RUN scheduled READY requested resource un resource resume quantum expires requested resource un resource suspended AND SUSPENDED resumed resource SUSPENDED The suspended state holds any process that is not waiting on any resources, it is only waiting to be resumed. The Blocked and Suspended state holds any process that was both suspended by another process AND it is waiting on some resource. It is possible for a resource to be granted to a suspended process, so the link between Blocked and Suspended and Suspended is necessary. 2

3 4. Scheduling. Suppose a processor uses a prioritized round robin scheduling policy. New processes are assigned an initial quantum of length q. Whenever a process uses its entire quantum without blocking, its new quantum is set to twice its current quantum. If a process blocks before its quantum expires, its new quantum is reset to q. For the purposes of this question, assume that every process requires a finite total amount of CPU time. (a) (5) Suppose the scheduler gives higher priority to processes that have larger quanta. Is starvation possible in this system? Why or why not? No, starvation is not possible. Because we assume that a process will terminate, the worst that can happen is that a CPU bound process will continue to execute until it completes. When it finishes, one of the lower priority processes will execute. Because the I/O bound processes will sit on the low priority queue, they will eventually make it to the head of the queue and will not starve. (b) (5) Suppose instead that the scheduler gives higher priority to processes that have smaller quanta. Is starvation possible in this system? Why or why not? Yes, starvation is possible. Suppose a CPU bound process runs on the processor, uses its entire quantum, and has its quantum doubled. Suppose a steady stream of I/O bound processes enter the system. Since they will always have a lower quantum and will be selected for execution before the process with the doubled quantum, they will starve the original process. 5. Nice. The other day I was using my Linux workstation in the CS department, and suddenly, everything I was doing started to slow down. Sometimes it took several seconds to change from an emacs window to a web browser, or even to a terminal window. When I finally ran top, I saw that Myrosia (one of the graduate students in AI) was running an application on my machine, and it was taking nearly 99% of the CPU. I could see that she had increased the nice value of her process significantly, but my work was still being significantly slowed. Another day, I was working, and for no particular reason, ran top and found that Grigoris (a graduate student in systems) was using my machine. His process was also taking nearly 99% of the CPU and he had increased the nice value of his process, but my work was not being affected. (a) (6) What do you think was the difference between the two processes? In other words, how could Myrosia s process be affecting me while Grigoris did not? Justify your answer. Nice only affects CPU usage, not memory usage. It turns out the Myrosia s process is a memory hog, and her processes were taking all of my memory. Grigoris process was using only a small amount of memory. While both were using almost all of the CPU, my tasks were so small that they easily fit into the remaining 1% of the CPU, but the lack of memory control slowed me down. (b) (4) How can the situation be fixed? In other words, what mechanism can be used to still allow Myrosia s process to run without affecting me as much? You need only describe the mechanism. A mechanism needs to be added to limit the maximum amount of memory for a process. Nice does not do this. 3

4 6. Synchronization. The following Java code samples describe two Lock classes with two methods each: acquire() and release(). You can assume that the application calls lock.acquire() before entering a critical section and lock.release() after exiting the critical section. For the implementations that require a tid (i.e., thread id), you can assume that the tid of each thread is either 0 or 1. class LockA { class LockB { private int turn = 0; public void acquire(int tid) { while (turn == (1 - tid)); public void release(int tid) { turn = (1 - tid); public void acquire() { disableinterrupts(); public void release() { enableinterrupts(); (6) For each lock, answer the following three questions. Be sure that your answers clearly indicate whether you are referring to LockA or LockB. (a) Does the code guarantee mutual exclusion? (Simply answer yes or no) (b) Does the code guarantee progress? (Simply answer yes or no) (c) List all other limitations that exist for each implementation. Issues you might consider include (but are not limited to) the following: generality, efficiency, and fairness. (Note: You can skip this part of the question when the implementation fails to provide mutual exclusion or progress.) LockA (a) Yes, guarantees mutual exclusion; only the thread with tid matching turn is able to acquire the lock. (b) No, does not guarantee progress; if thread 0 never tries to acquire the lock (it is executing other code), thread 1 will not be able to acquire the lock. (c) Limitations (Not required): Only works with two processes, uses busy waiting. LockB (a) Guarantees mutual exclusion on a uniprocessor, but not on a multiprocessor. On a uniprocessor, once the timer interrupt is disabled, the scheduler won t be able to switch to another process (assuming the scheduled process doesn t voluntarily relinquish the CPU). However, on a multiprocessor, it is possible for the other CPU to be running a process that also acquires the lock. (b) Yes, guarantees progress; once a process is scheduled, it is able to acquire the lock without incident. (c) Limitations: Only works on uniprocessors; allows user processes to disable interrupts for an arbitrary long period; cannot service other important interrupts during critical section (e.g., I/O); cannot schedule any other processes when lock is held, even those not contending for the lock. (4) Also answer the following general question: Locks are often implemented by maintaining a list of processes (or threads) that are waiting to acquire the lock. What are all of the advantages of this approach (compared to a correct implementation of a lock that does not use a list)? fairness and efficiency. Fairness comes from the fact that the queue can provide the lock to the processes in the order they request it. Efficiency comes from the elimination of the spin lock, and reliance on a notification mechanism to wake-up a process. 4

5 7. Scheduling and Synchronization. Suppose two processes compete for access to a critical section using simple spin locks. Prior to entering the critical section, the process executes the following: while (TAS(t)); and after exiting the critical section it executes t=1. (a) (5) Suppose a priority scheduler where high priority processes always execute before any lower priority processes. Can the described scheme lead to deadlock? If no, why not. If yes, describe a case. Yes, deadlock is possible. If a low priority process acquires the lock. Then a high priority process starts, gets the processor and requests the lock. The high priority process will keep the processor, spinning on the lock that the low priority process is holding. Because the low priority process cannot get the processor, it cannot release the lock, and we have a deadlock scenario. (b) (5) Suppose a round robin scheduler. Can the described scheme lead to deadlock? If no, why not. If yes, describe a case. No, deadlock is not possible. A round robin, preemptive scheduler will alternate among processes, so every process will have a chance to execute, and eventually the holding process will release the lock. 8. Deadlock prevention. (a) (6) What are the necessary conditions for deadlock? (1) mutual exclusion - at least one resource is non-sharable (2) hold and wait - a process is holding some resource while waiting for another (3) no preemption - cannot take resource away (4) circular wait - P0 waits for P1 waits... Pn waits P0 (b) (3) Fix the following code to avoid the possible deadlock: acquire(l1) acquire(l2) release(l2) release(l1) acquire(l2) acquire(l1) release(l1) release(l2) You could have changed this many ways. One possibility is to remove circular wait and make both processes acquire the resources in the same order. Another possibility is to remove hold-and-wait and have the processes release the first resource before they acquire another. Although this changes the semantics of the program, I accepted it as a solution. (c) (1) What condition from (a) did you remove by making your change. 5

Midterm Exam Amy Murphy 6 March 2002

Midterm Exam Amy Murphy 6 March 2002 University of Rochester Midterm Exam Amy Murphy 6 March 2002 Computer Systems (CSC2/456) Read before beginning: Please write clearly. Illegible answers cannot be graded. Be sure to identify all of your

More information

Midterm Exam Solutions Amy Murphy 28 February 2001

Midterm Exam Solutions Amy Murphy 28 February 2001 University of Rochester Midterm Exam Solutions Amy Murphy 8 February 00 Computer Systems (CSC/56) Read before beginning: Please write clearly. Illegible answers cannot be graded. Be sure to identify all

More information

CMPS 111 Spring 2003 Midterm Exam May 8, Name: ID:

CMPS 111 Spring 2003 Midterm Exam May 8, Name: ID: CMPS 111 Spring 2003 Midterm Exam May 8, 2003 Name: ID: This is a closed note, closed book exam. There are 20 multiple choice questions and 5 short answer questions. Plan your time accordingly. Part I:

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

Scheduling. The Basics

Scheduling. The Basics The Basics refers to a set of policies and mechanisms to control the order of work to be performed by a computer system. Of all the resources in a computer system that are scheduled before use, the CPU

More information

CS140 Operating Systems and Systems Programming Midterm Exam

CS140 Operating Systems and Systems Programming Midterm Exam CS140 Operating Systems and Systems Programming Midterm Exam October 31 st, 2003 (Total time = 50 minutes, Total Points = 50) Name: (please print) In recognition of and in the spirit of the Stanford University

More information

CMPS 111 Spring 2013 Prof. Scott A. Brandt Midterm Examination May 6, Name: ID:

CMPS 111 Spring 2013 Prof. Scott A. Brandt Midterm Examination May 6, Name: ID: CMPS 111 Spring 2013 Prof. Scott A. Brandt Midterm Examination May 6, 2013 Name: ID: This is a closed note, closed book exam. There are 23 multiple choice questions, 6 short answer questions. Plan your

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

Computer Science 161

Computer Science 161 Computer Science 161 150 minutes/150 points Fill in your name, logname, and TF s name below. Name Logname The points allocated to each problem correspond to how much time we think the problem should take.

More information

Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5

Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5 Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5 Multiple Processes OS design is concerned with the management of processes and threads: Multiprogramming Multiprocessing Distributed processing

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

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

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

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

Remaining Contemplation Questions

Remaining Contemplation Questions Process Synchronisation Remaining Contemplation Questions 1. The first known correct software solution to the critical-section problem for two processes was developed by Dekker. The two processes, P0 and

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

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

CPSC/ECE 3220 Summer 2018 Exam 2 No Electronics.

CPSC/ECE 3220 Summer 2018 Exam 2 No Electronics. CPSC/ECE 3220 Summer 2018 Exam 2 No Electronics. Name: Write one of the words or terms from the following list into the blank appearing to the left of the appropriate definition. Note that there are more

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

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

CSL373: Lecture 5 Deadlocks (no process runnable) + Scheduling (> 1 process runnable)

CSL373: Lecture 5 Deadlocks (no process runnable) + Scheduling (> 1 process runnable) CSL373: Lecture 5 Deadlocks (no process runnable) + Scheduling (> 1 process runnable) Past & Present Have looked at two constraints: Mutual exclusion constraint between two events is a requirement that

More information

Chapter 6: Process [& Thread] Synchronization. CSCI [4 6] 730 Operating Systems. Why does cooperation require synchronization?

Chapter 6: Process [& Thread] Synchronization. CSCI [4 6] 730 Operating Systems. Why does cooperation require synchronization? Chapter 6: Process [& Thread] Synchronization CSCI [4 6] 730 Operating Systems Synchronization Part 1 : The Basics Why is synchronization needed? Synchronization Language/Definitions:» What are race conditions?»

More information

Unit 3 : Process Management

Unit 3 : Process Management Unit : Process Management Processes are the most widely used units of computation in programming and systems, although object and threads are becoming more prominent in contemporary systems. Process management

More information

CHAPTER 6: PROCESS SYNCHRONIZATION

CHAPTER 6: PROCESS SYNCHRONIZATION CHAPTER 6: PROCESS SYNCHRONIZATION The slides do not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams. TOPICS Background

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

Example: CPU-bound process that would run for 100 quanta continuously 1, 2, 4, 8, 16, 32, 64 (only 37 required for last run) Needs only 7 swaps

Example: CPU-bound process that would run for 100 quanta continuously 1, 2, 4, 8, 16, 32, 64 (only 37 required for last run) Needs only 7 swaps Interactive Scheduling Algorithms Continued o Priority Scheduling Introduction Round-robin assumes all processes are equal often not the case Assign a priority to each process, and always choose the process

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

(b) External fragmentation can happen in a virtual memory paging system.

(b) External fragmentation can happen in a virtual memory paging system. Alexandria University Faculty of Engineering Electrical Engineering - Communications Spring 2015 Final Exam CS333: Operating Systems Wednesday, June 17, 2015 Allowed Time: 3 Hours Maximum: 75 points Note:

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

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

Suggested Solutions (Midterm Exam October 27, 2005)

Suggested Solutions (Midterm Exam October 27, 2005) Suggested Solutions (Midterm Exam October 27, 2005) 1 Short Questions (4 points) Answer the following questions (True or False). Use exactly one sentence to describe why you choose your answer. Without

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

CSCE Operating Systems Scheduling. Qiang Zeng, Ph.D. Fall 2018

CSCE Operating Systems Scheduling. Qiang Zeng, Ph.D. Fall 2018 CSCE 311 - Operating Systems Scheduling Qiang Zeng, Ph.D. Fall 2018 Resource Allocation Graph describing the traffic jam CSCE 311 - Operating Systems 2 Conditions for Deadlock Mutual Exclusion Hold-and-Wait

More information

Operating Systems EDA092, DIT 400 Exam

Operating Systems EDA092, DIT 400 Exam Chalmers University of Technology and Gothenburg University Operating Systems EDA092, DIT 400 Exam 2015-04-14 Date, Time, Place: Tuesday 2015/04/14, 14:00 18:00, Väg och vatten -salar Course Responsible:

More information

CS604 - Operating System Solved Subjective Midterm Papers For Midterm Exam Preparation

CS604 - Operating System Solved Subjective Midterm Papers For Midterm Exam Preparation CS604 - Operating System Solved Subjective Midterm Papers For Midterm Exam Preparation The given code is as following; boolean flag[2]; int turn; do { flag[i]=true; turn=j; while(flag[j] && turn==j); critical

More information

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 University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science CS 162 Spring 2010 I. Stoica FIRST MIDTERM EXAMINATION Tuesday, March 9, 2010 INSTRUCTIONS

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

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

University of Waterloo Midterm Examination Model Solution CS350 Operating Systems

University of Waterloo Midterm Examination Model Solution CS350 Operating Systems University of Waterloo Midterm Examination Model Solution CS350 Operating Systems Fall, 2003 1. (10 total marks) Suppose that two processes, a and b, are running in a uniprocessor system. a has three threads.

More information

CPSC/ECE 3220 Summer 2017 Exam 2

CPSC/ECE 3220 Summer 2017 Exam 2 CPSC/ECE 3220 Summer 2017 Exam 2 Name: Part 1: Word Bank Write one of the words or terms from the following list into the blank appearing to the left of the appropriate definition. Note that there are

More information

CSL373: Lecture 6 CPU Scheduling

CSL373: Lecture 6 CPU Scheduling CSL373: Lecture 6 CPU Scheduling First come first served (FCFS or FIFO) Simplest scheduling algorithm cpu cpu 0 0 Run jobs in order that they arrive Disadvantage: wait time depends on arrival order. Unfair

More information

Concurrent Processes Rab Nawaz Jadoon

Concurrent Processes Rab Nawaz Jadoon Concurrent Processes Rab Nawaz Jadoon DCS COMSATS Institute of Information Technology Assistant Professor COMSATS Lahore Pakistan Operating System Concepts Concurrent Processes If more than one threads

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

Interprocess Communication By: Kaushik Vaghani

Interprocess Communication By: Kaushik Vaghani Interprocess Communication By: Kaushik Vaghani Background Race Condition: A situation where several processes access and manipulate the same data concurrently and the outcome of execution depends on the

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

CSCI [4 6] 730 Operating Systems. Example Execution. Process [& Thread] Synchronization. Why does cooperation require synchronization?

CSCI [4 6] 730 Operating Systems. Example Execution. Process [& Thread] Synchronization. Why does cooperation require synchronization? Process [& Thread] Synchronization CSCI [4 6] 730 Operating Systems Synchronization Part 1 : The Basics Why is synchronization needed? Synchronization Language/Definitions: What are race conditions? What

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

! Why is synchronization needed? ! Synchronization Language/Definitions: ! How are locks implemented? Maria Hybinette, UGA

! Why is synchronization needed? ! Synchronization Language/Definitions: ! How are locks implemented? Maria Hybinette, UGA Chapter 6: Process [& Thread] Synchronization CSCI [4 6] 730 Operating Systems Synchronization Part 1 : The Basics! Why is synchronization needed?! Synchronization Language/Definitions:» What are race

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

Synchronization I. Jo, Heeseung

Synchronization I. Jo, Heeseung Synchronization I Jo, Heeseung Today's Topics Synchronization problem Locks 2 Synchronization Threads cooperate in multithreaded programs To share resources, access shared data structures Also, to coordinate

More information

Locks. Dongkun Shin, SKKU

Locks. Dongkun Shin, SKKU Locks 1 Locks: The Basic Idea To implement a critical section A lock variable must be declared A lock variable holds the state of the lock Available (unlocked, free) Acquired (locked, held) Exactly one

More information

Concurrency. Chapter 5

Concurrency. Chapter 5 Concurrency 1 Chapter 5 2 Concurrency Is a fundamental concept in operating system design Processes execute interleaved in time on a single processor Creates the illusion of simultaneous execution Benefits

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

CS 31: Introduction to Computer Systems : Threads & Synchronization April 16-18, 2019

CS 31: Introduction to Computer Systems : Threads & Synchronization April 16-18, 2019 CS 31: Introduction to Computer Systems 22-23: Threads & Synchronization April 16-18, 2019 Making Programs Run Faster We all like how fast computers are In the old days (1980 s - 2005): Algorithm too slow?

More information

Lecture Topics. Announcements. Today: Uniprocessor Scheduling (Stallings, chapter ) Next: Advanced Scheduling (Stallings, chapter

Lecture Topics. Announcements. Today: Uniprocessor Scheduling (Stallings, chapter ) Next: Advanced Scheduling (Stallings, chapter Lecture Topics Today: Uniprocessor Scheduling (Stallings, chapter 9.1-9.3) Next: Advanced Scheduling (Stallings, chapter 10.1-10.4) 1 Announcements Self-Study Exercise #10 Project #8 (due 11/16) Project

More information

Process behavior. Categories of scheduling algorithms.

Process behavior. Categories of scheduling algorithms. Week 5 When a computer is multiprogrammed, it frequently has multiple processes competing for CPU at the same time. This situation occurs whenever two or more processes are simultaneously in the ready

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 CS3502 Spring Processor Scheduling. Chapter 5

OPERATING SYSTEMS CS3502 Spring Processor Scheduling. Chapter 5 OPERATING SYSTEMS CS3502 Spring 2018 Processor Scheduling Chapter 5 Goals of Processor Scheduling Scheduling is the sharing of the CPU among the processes in the ready queue The critical activities are:

More information

Announcements. Program #1. Program #0. Reading. Is due at 9:00 AM on Thursday. Re-grade requests are due by Monday at 11:59:59 PM.

Announcements. Program #1. Program #0. Reading. Is due at 9:00 AM on Thursday. Re-grade requests are due by Monday at 11:59:59 PM. Program #1 Announcements Is due at 9:00 AM on Thursday Program #0 Re-grade requests are due by Monday at 11:59:59 PM Reading Chapter 6 1 CPU Scheduling Manage CPU to achieve several objectives: maximize

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

Chapter 6: Process Synchronization

Chapter 6: Process Synchronization Chapter 6: Process Synchronization Chapter 6: Synchronization 6.1 Background 6.2 The Critical-Section Problem 6.3 Peterson s Solution 6.4 Synchronization Hardware 6.5 Mutex Locks 6.6 Semaphores 6.7 Classic

More information

Lesson 6: Process Synchronization

Lesson 6: Process Synchronization Lesson 6: Process Synchronization Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks Semaphores Classic Problems of Synchronization

More information

Process Synchronisation (contd.) Deadlock. Operating Systems. Spring CS5212

Process Synchronisation (contd.) Deadlock. Operating Systems. Spring CS5212 Operating Systems Spring 2009-2010 Outline Process Synchronisation (contd.) 1 Process Synchronisation (contd.) 2 Announcements Presentations: will be held on last teaching week during lectures make a 20-minute

More information

Process & Thread Management II. Queues. Sleep() and Sleep Queues CIS 657

Process & Thread Management II. Queues. Sleep() and Sleep Queues CIS 657 Process & Thread Management II CIS 657 Queues Run queues: hold threads ready to execute Not a single ready queue; 64 queues All threads in same queue are treated as same priority Sleep queues: hold threads

More information

Process & Thread Management II CIS 657

Process & Thread Management II CIS 657 Process & Thread Management II CIS 657 Queues Run queues: hold threads ready to execute Not a single ready queue; 64 queues All threads in same queue are treated as same priority Sleep queues: hold threads

More information

SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (II)

SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (II) SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (II) Shan He School for Computational Science University of Birmingham Module 06-19321: SSC Outline Outline of Topics

More information

Operating Systems Antonio Vivace revision 4 Licensed under GPLv3

Operating Systems Antonio Vivace revision 4 Licensed under GPLv3 Operating Systems Antonio Vivace - 2016 revision 4 Licensed under GPLv3 Process Synchronization Background A cooperating process can share directly a logical address space (code, data) or share data through

More information

Resource management. Real-Time Systems. Resource management. Resource management

Resource management. Real-Time Systems. Resource management. Resource management Real-Time Systems Specification Implementation Verification Mutual exclusion is a general problem that exists at several levels in a real-time system. Shared resources internal to the the run-time system:

More information

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems Processes CS 475, Spring 2018 Concurrent & Distributed Systems Review: Abstractions 2 Review: Concurrency & Parallelism 4 different things: T1 T2 T3 T4 Concurrency: (1 processor) Time T1 T2 T3 T4 T1 T1

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

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

Operating Systems. Synchronization

Operating Systems. Synchronization Operating Systems Fall 2014 Synchronization Myungjin Lee myungjin.lee@ed.ac.uk 1 Temporal relations Instructions executed by a single thread are totally ordered A < B < C < Absent synchronization, instructions

More information

MCS-378 Intraterm Exam 1 Serial #:

MCS-378 Intraterm Exam 1 Serial #: MCS-378 Intraterm Exam 1 Serial #: This exam is closed-book and mostly closed-notes. You may, however, use a single 8 1/2 by 11 sheet of paper with hand-written notes for reference. (Both sides of the

More information

Chapter 6: Synchronization. Chapter 6: Synchronization. 6.1 Background. Part Three - Process Coordination. Consumer. Producer. 6.

Chapter 6: Synchronization. Chapter 6: Synchronization. 6.1 Background. Part Three - Process Coordination. Consumer. Producer. 6. Part Three - Process Coordination Chapter 6: Synchronization 6.1 Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure

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

Lecture #7: Implementing Mutual Exclusion

Lecture #7: Implementing Mutual Exclusion Lecture #7: Implementing Mutual Exclusion Review -- 1 min Solution #3 to too much milk works, but it is really unsatisfactory: 1) Really complicated even for this simple example, hard to convince yourself

More information

CS153: Midterm (Fall 16)

CS153: Midterm (Fall 16) Name: CS153: Midterm (Fall 16) Answer all questions. State any assumptions clearly. Problem 1: (16 points + 2 bonus; 10 minutes) Mark any 8 of the following statements as True or False. Answer all 10 to

More information

Midterm Exam Solutions March 7, 2001 CS162 Operating Systems

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

More information

CSE 451: Operating Systems Winter Lecture 7 Synchronization. Steve Gribble. Synchronization. Threads cooperate in multithreaded programs

CSE 451: Operating Systems Winter Lecture 7 Synchronization. Steve Gribble. Synchronization. Threads cooperate in multithreaded programs CSE 451: Operating Systems Winter 2005 Lecture 7 Synchronization Steve Gribble Synchronization Threads cooperate in multithreaded programs to share resources, access shared data structures e.g., threads

More information

Operating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017

Operating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017 Operating Systems Lecture 4 - Concurrency and Synchronization Adrien Krähenbühl Master of Computer Science PUF - Hồ Chí Minh 2016/2017 Mutual exclusion Hardware solutions Semaphores IPC: Message passing

More information

Real-Time Systems. Lecture #4. Professor Jan Jonsson. Department of Computer Science and Engineering Chalmers University of Technology

Real-Time Systems. Lecture #4. Professor Jan Jonsson. Department of Computer Science and Engineering Chalmers University of Technology Real-Time Systems Lecture #4 Professor Jan Jonsson Department of Computer Science and Engineering Chalmers University of Technology Real-Time Systems Specification Resource management Mutual exclusion

More information

Announcements. Program #1. Reading. Due 2/15 at 5:00 pm. Finish scheduling Process Synchronization: Chapter 6 (8 th Ed) or Chapter 7 (6 th Ed)

Announcements. Program #1. Reading. Due 2/15 at 5:00 pm. Finish scheduling Process Synchronization: Chapter 6 (8 th Ed) or Chapter 7 (6 th Ed) Announcements Program #1 Due 2/15 at 5:00 pm Reading Finish scheduling Process Synchronization: Chapter 6 (8 th Ed) or Chapter 7 (6 th Ed) 1 Scheduling criteria Per processor, or system oriented CPU utilization

More information

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable What s An OS? Provides environment for executing programs Process abstraction for multitasking/concurrency scheduling Hardware abstraction layer (device drivers) File systems Communication Do we need an

More information

ECE469 - Operating Systems Engineering Exam # March 25

ECE469 - Operating Systems Engineering Exam # March 25 ECE469 - Operating Systems Engineering Exam #1 2004 March 25 A computer lets you make more mistakes faster than any invention in human history with the possible exceptions of handguns and tequila. Mitch

More information

10/17/ Gribble, Lazowska, Levy, Zahorjan 2. 10/17/ Gribble, Lazowska, Levy, Zahorjan 4

10/17/ Gribble, Lazowska, Levy, Zahorjan 2. 10/17/ Gribble, Lazowska, Levy, Zahorjan 4 Temporal relations CSE 451: Operating Systems Autumn 2010 Module 7 Synchronization Instructions executed by a single thread are totally ordered A < B < C < Absent synchronization, instructions executed

More information

Tasks. Task Implementation and management

Tasks. Task Implementation and management Tasks Task Implementation and management Tasks Vocab Absolute time - real world time Relative time - time referenced to some event Interval - any slice of time characterized by start & end times Duration

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 6: Synchronization. Operating System Concepts 8 th Edition,

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

More information

Starting the Threads

Starting the Threads NachOS Example Administrivia You ve just been hired by Mother Nature to help her out with the chemical reaction to form water, which she doesn t seem to be able to get right due to synchronization problems.

More information

CPS 110 Midterm. Spring 2011

CPS 110 Midterm. Spring 2011 CPS 110 Midterm Spring 2011 Ola! Greetings from Puerto Rico, where the air is warm and salty and the mojitos are cold and sweet. Please answer all questions for a total of 200 points. Keep it clear and

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

CPU Scheduling. The scheduling problem: When do we make decision? - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s)

CPU Scheduling. The scheduling problem: When do we make decision? - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s) CPU Scheduling The scheduling problem: - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s) When do we make decision? 1 / 39 CPU Scheduling new admitted interrupt exit terminated

More information

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 1019 L12 Synchronization Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Critical section: shared

More information

First Midterm Exam Solutions October 1, 2018 CS162 Operating Systems

First Midterm Exam Solutions October 1, 2018 CS162 Operating Systems University of California, Berkeley College of Engineering Computer Science Division EECS Fall 2018 Ion Stoica First Midterm Exam Solutions October 1, 2018 CS162 Operating Systems Your Name: SID AND 162

More information

Scheduling - Overview

Scheduling - Overview Scheduling - Overview Quick review of textbook scheduling Linux 2.4 scheduler implementation overview Linux 2.4 scheduler code Modified Linux 2.4 scheduler Linux 2.6 scheduler comments Possible Goals of

More information

EECE.4810/EECE.5730: Operating Systems Spring Midterm Exam March 8, Name: Section: EECE.4810 (undergraduate) EECE.

EECE.4810/EECE.5730: Operating Systems Spring Midterm Exam March 8, Name: Section: EECE.4810 (undergraduate) EECE. EECE.4810/EECE.5730: Operating Systems Spring 2017 Midterm Exam March 8, 2017 Name: Section: EECE.4810 (undergraduate) EECE.5730 (graduate) For this exam, you may use two 8.5 x 11 double-sided page of

More information

Mutual Exclusion and Synchronization

Mutual Exclusion and Synchronization Mutual Exclusion and Synchronization Concurrency Defined Single processor multiprogramming system Interleaving of processes Multiprocessor systems Processes run in parallel on different processors Interleaving

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

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