Assignment-2 (TCS/TIT 503)
|
|
- Piers Jefferson
- 6 years ago
- Views:
Transcription
1 Assignment-2 (TCS/TIT 503) Topics covered: Threads, Process Synchronisation, Semaphores Submission dates: 1)CS A:Monday,26/10/2015 (Time: between 12 pm to 1 pm) 2)CS B:Monday,26/10/2015(in the lecture of OS) 3)IT:Monday,26/10/2015 (Time: between 12 pm to 1 pm in the cabin of Mr. Dilip kumar) The assignments will not be submitted after the due timings on the same day also(applicable for all sections). Q1) Can a multithreaded solution using multiple user-level threads achieves better performance on a multiprocessor system than on a single-processor system? Q2) What can be the circumstances under which a multithreaded solution using multiple kernel threads provide better performance than a single-threaded solution on a singleprocessor system? Q3) A web server is implemented using the following 2 approaches. Approach 1: For each connection request, create a new separate process to handle that request. Approach 2: A single process is running on server to listen the incoming request and then for each connection request, a new thread is created. The web server has 1 GB memory space in total. Each process which is created on server takes 10 MB of memory space. Each thread takes 100 KB of memory space. a) Find the maximum number of connections which can be created in approach 1 and approach 2, assuming no memory space is taken by OS on server. b) Repeat the part (a), assuming 2 MB of memory space is taken by OS on server. c) Which of the approach: approach 1 or approach 2 seems to be better and why?
2 Q4) The following is a set of three interacting processes that can access two shared semaphores: semaphore U = 3; semaphore V = 0; [Process 1] [Process 2] [Process 3] L1:wait(U) L2:wait(V) L3:wait(V) printf("c") printf("a") printf("d") signal(v) printf("b") goto L3 goto L1 signal(v) goto L2 Within each process the statements are executed sequentially, but statements from different processes can be interleaved in any order that is consistent with the constraints imposed by the semaphores. When answering the questions below assume that once execution begins, the processes will be allowed to run until all 3 processes are stuck in a wait() statement, at which point execution is halted. a) Assuming execution is eventually halted, how many C's are printed when the set of processes runs? b) Assuming execution is eventually halted, how many D's are printed when this set of processes runs? c) What is the smallest number of A's that might be printed when this set of processes runs? d) Is CABABDDCABCABD a possible output sequence when this set of processes runs? e) Is CABACDBCABDD a possible output sequence when this set of processes runs? f) Is it possible for execution to be halted with either U or V having a non-zero value? Q5) The following pair of processes share a common variable X: Process A Process B int Y; int Z; A1: Y = X*2; B1: Z = X+1; A2: X = Y; B2: X = Z; X is set to 5 before either process begins execution. As usual, statements within a process are executed sequentially, but statements in process A may execute in any order with respect to statements in process B. A. How many different values of X are possible after both processes finish executing?
3 B. Suppose the programs are modified as follows to use a shared binary semaphore S: Process A Process B int Y; int Z; wait(s); wait(s); A1: Y = X*2; B1: Z = X+1; A2: X = Y; B2: X = Z; signal(s); signal(s); S is set to 1 before either process begins execution and, as before, X is set to 5. Now, how many different values of X are possible after both processes finish executing? C. Finally, suppose the programs are modified as follows to use a shared binary semaphore T: Process A Process B int Y; int Z; A1: Y = X*2; B1: wait(t); A2: X = Y; B2: Z = X+1; signal(t); X = Z; T is set to 0 before either process begins execution and, as before, X is set to 5. Now, how many different values of X are possible after both processes finish executing? Q6) The following pair of processes share a common set of variables: "counter", "tempa" and "tempb": Process A Process B A1: tempa = counter + 1; B1: tempb = counter + 2; A2: counter = tempa; B2: counter = tempb; The variable "counter" initially has the value 10 before either process begins to execute. A. What different values of "counter" are possible when both processes have finished executing? Give an order of execution of statements from processes A and B that would yield each of the values you give. For example, execution order A1, A2, B1, B2 would yield the value 13.
4 B. Modify the above programs for processes A and B by adding appropriate signal and wait operations on the binary semaphore "sync" such that the only possible final value of "counter" is 13. Indicate what should be the initial value of the s emaphore "sync". D. Modify the original programs for processes A and B by adding binary semaphores and signal and wait operations to guarantee that the final result of executing the two processes will be counter = 11. Give the initial values for every semaphore you introduce. Q7) Write the producer-consumer solution using monitors with the explanation. Q8) Both busy waiting and blocking methods can be used as means to address critical section problems and process synchronization. Describe how blocking is different from busy waiting, and discuss the advantages and disadvantages of each. Q9) Do semaphores solve the problem of process synchronization completely? What are some of the things that might still go wrong in a solution that requires synchronization using semaphore? Q10) Consider the following program fragment: semaphore s1=1,s2=1; wait(s1); a++; wait(s2); v++; wait(s2); wait(s1); (s1, s2 are counting semaphores). Now, consider two processes(or threads ) running this fragment of code simultaneously, can there be a deadlock? Why, or why not? Q11) Consider the following code: shared int flag[2]=0,0, turn=0; Process 1: Process 2: flag[0]=1; turn=1; while(flag[1]==1&&turn==0) ; critical section; flag[0]=0; flag[1]=1; turn=1; while(flag[0]==1&&turn==1) ; critical section; flag[1]=0;
5 check the following code and tell which of the 3 requirements (Mutual exclusion, bounded waiting, progress) is violated. Q12) Answer the following semaphore regarding counting semaphore. Give brief explanation for each. a)can there ever be a process blocked one semaphore with non negative value? b)can a semaphore have negative value without having any process blocked on it? Q13) Two processes X and Y need to access a critical section. Consider the following synchronization construct used by both the processes Process X: Process Y: / *other codefor process X * / while (true) P= true; Q= true; while (Q== true) / *criticalsection*/ P=false; / *other codefor process X*/ / *other codefor process Y * / while (true) Q= true; P= true; while (P== true) / *criticalsection*/ Q=false; / *other codefor process Y*/ Here, P and Q are shared variables and both are initialized to false. Which one of the following statements is true? (A) The proposed solution prevents deadlock but fails to guarantee mutual exclusion (B) The proposed solution guarantees mutual exclusion but fails to prevent deadlock (C) The proposed solution guarantees mutual exclusion and prevents deadlock (D) The proposed solution fails to prevent deadlock and fails to guarantee mutual exclusion Give proper explanation for your answer.
6 Q14) The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0=1, S1=0, S2=0. Process P0 Process P1 Process P2 while (true) wait (S0); print (0); release (S1); release (S2); wait (S1); Release (S0); wait (S2); release (S0); How many times will process P0 print '0'? (a) At least twice (b) Exactly twice (c) Exactly thrice (d) Exactly once Give proper explanation for your answer. Q15) Consider a multiprocessor system and a multithreaded program written using the many-to-many threading model. Let the number of user-level threads in the program be more than the number of processors in the system. Discuss what will happen performance wise in the following scenarios. a. The number of kernel threads allocated to the program is less than the number of processors. b. The number of kernel threads allocated to the program is equal to the number of processors. c. The number of kernel threads allocated to the program is greater than the number of processors but less than the number of user level threads. Q16) A single-lane bridge connects the two villages,village A and Village B. Farmers in the two villages use this bridge to deliver their produce to the neighbouring town. The bridge can become deadlocked if both a northbound and a southbound farmer get on the bridge at the same time (Both village farmers are stubborn and are unable to back up). Using exactly one semaphore, design an algorithm that prevents deadlock. Do not be concerned about starvation and inefficiency. Q17) If the wait() and signal() semaphore operations are not executed atomically, then can mutual exclusion be violated? Why or why not?
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 information1. Consider the following page reference string: 1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3, 6.
1. Consider the following page reference string: 1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3, 6. What will be the ratio of page faults for the following replacement algorithms - FIFO replacement
More informationLecture Topics. Announcements. Today: Concurrency (Stallings, chapter , 5.7) Next: Exam #1. Self-Study Exercise #5. Project #3 (due 9/28)
Lecture Topics Today: Concurrency (Stallings, chapter 5.1-5.4, 5.7) Next: Exam #1 1 Announcements Self-Study Exercise #5 Project #3 (due 9/28) Project #4 (due 10/12) 2 Exam #1 Tuesday, 10/3 during lecture
More informationChapter 5 Asynchronous Concurrent Execution
Chapter 5 Asynchronous Concurrent Execution Outline 5.1 Introduction 5.2 Mutual Exclusion 5.2.1 Java Multithreading Case Study 5.2.2 Critical Sections 5.2.3 Mutual Exclusion Primitives 5.3 Implementing
More informationMS Windows Concurrency Mechanisms Prepared By SUFIAN MUSSQAA AL-MAJMAIE
MS Windows Concurrency Mechanisms Prepared By SUFIAN MUSSQAA AL-MAJMAIE 163103058 April 2017 Basic of Concurrency In multiple processor system, it is possible not only to interleave processes/threads but
More informationCSE 153 Design of Operating Systems
CSE 153 Design of Operating Systems Winter 19 Lecture 7/8: Synchronization (1) Administrivia How is Lab going? Be prepared with questions for this weeks Lab My impression from TAs is that you are on track
More informationHomework #3. CS 318/418/618, Fall Handout: 10/09/2017
CS 318/418/618, Fall 2017 Homework #3 Handout: 10/09/2017 1. Microsoft.NET provides a synchronization primitive called a CountdownEvent. Programs use CountdownEvent to synchronize on the completion of
More informationCS 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 information10/17/2011. Cooperating Processes. Synchronization 1. Example: Producer Consumer (3) Example
Cooperating Processes Synchronization 1 Chapter 6.1 4 processes share something (devices such as terminal, keyboard, mouse, etc., or data structures) and can affect each other non deterministic Not exactly
More informationPart II Process Management Chapter 6: Process Synchronization
Part II Process Management Chapter 6: Process Synchronization 1 Process Synchronization Why is synchronization needed? Race Conditions Critical Sections Pure Software Solutions Hardware Support Semaphores
More informationChapter 5: Process Synchronization. Operating System Concepts 9 th Edition
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks
More informationProcess 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 informationENGR 3950U / CSCI 3020U UOIT, Fall 2012 Quiz on Process Synchronization SOLUTIONS
Name: Student Number: SOLUTIONS ENGR 3950U / CSCI 3020U (Operating Systems) Quiz on Process Synchronization November 13, 2012, Duration: 40 Minutes (10 questions and 8 pages, 45 Marks) Instructor: Dr.
More informationInterprocess 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 informationSymmetric Multiprocessors: Synchronization and Sequential Consistency
Constructive Computer Architecture Symmetric Multiprocessors: Synchronization and Sequential Consistency Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology November
More informationCSE 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 informationRemaining 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 informationCS 153 Design of Operating Systems Winter 2016
CS 153 Design of Operating Systems Winter 2016 Lecture 7: Synchronization Administrivia Homework 1 Due today by the end of day Hopefully you have started on project 1 by now? Kernel-level threads (preemptable
More informationConcurrency: Mutual Exclusion and Synchronization. Concurrency
Concurrency: Mutual Exclusion and Synchronization Chapter 5 1 Concurrency Multiple applications Structured applications Operating system structure 2 1 Concurrency 3 Difficulties of Concurrency Sharing
More informationCSE 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 informationWhat 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 informationSynchronization 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( D ) 4. Which is not able to solve the race condition? (A) Test and Set Lock (B) Semaphore (C) Monitor (D) Shared memory
CS 540 - Operating Systems - Final Exam - Name: Date: Wenesday, May 12, 2004 Part 1: (78 points - 3 points for each problem) ( C ) 1. In UNIX a utility which reads commands from a terminal is called: (A)
More informationIntroduction to OS Synchronization MOS 2.3
Introduction to OS Synchronization MOS 2.3 Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Mahmoud El-Gayyar / Introduction to OS 1 Challenge How can we help processes synchronize with each other? E.g., how
More informationChapters 5 and 6 Concurrency
Operating Systems: Internals and Design Principles, 6/E William Stallings Chapters 5 and 6 Concurrency Patricia Roy Manatee Community College, Venice, FL 2008, Prentice Hall Concurrency When several processes/threads
More informationMutual 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 informationChapter 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 informationCSE 451: Operating Systems Winter Lecture 7 Synchronization. Hank Levy 412 Sieg Hall
CSE 451: Operating Systems Winter 2003 Lecture 7 Synchronization Hank Levy Levy@cs.washington.edu 412 Sieg Hall Synchronization Threads cooperate in multithreaded programs to share resources, access shared
More informationCS420: Operating Systems. Process Synchronization
Process Synchronization James Moscola Department of Engineering & Computer Science York College of Pennsylvania Based on Operating System Concepts, 9th Edition by Silberschatz, Galvin, Gagne Background
More informationChapter 6: Process Synchronization
Chapter 6: Process Synchronization Objectives Introduce Concept of Critical-Section Problem Hardware and Software Solutions of Critical-Section Problem Concept of Atomic Transaction Operating Systems CS
More informationImplementing Mutual Exclusion. Sarah Diesburg Operating Systems CS 3430
Implementing Mutual Exclusion Sarah Diesburg Operating Systems CS 3430 From the Previous Lecture The too much milk example shows that writing concurrent programs directly with load and store instructions
More informationDr. D. M. Akbar Hussain DE5 Department of Electronic Systems
Concurrency 1 Concurrency Execution of multiple processes. Multi-programming: Management of multiple processes within a uni- processor system, every system has this support, whether big, small or complex.
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 11 Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Multilevel Feedback Queue: Q0, Q1,
More informationChapter 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 informationCSC 1600: Chapter 6. Synchronizing Threads. Semaphores " Review: Multi-Threaded Processes"
CSC 1600: Chapter 6 Synchronizing Threads with Semaphores " Review: Multi-Threaded Processes" 1 badcnt.c: An Incorrect Program" #define NITERS 1000000 unsigned int cnt = 0; /* shared */ int main() pthread_t
More informationOperating 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 informationConcurrency. 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 informationProcess Synchronisation (contd.) Operating Systems. Autumn CS4023
Operating Systems Autumn 2017-2018 Outline Process Synchronisation (contd.) 1 Process Synchronisation (contd.) Synchronization Hardware 6.4 (SGG) Many systems provide hardware support for critical section
More information10/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 informationLecture Topics. Announcements. Today: Concurrency: Mutual Exclusion (Stallings, chapter , 5.7)
Lecture Topics Today: Concurrency: Mutual Exclusion (Stallings, chapter 5.1-5.4, 5.7) Next: Concurrency: Deadlock and Starvation (Stallings, chapter 6.1, 6.6-6.8) 1 Announcements Self-Study Exercise #5
More informationChapter 5: Process Synchronization. Operating System Concepts Essentials 2 nd Edition
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks
More informationa. A binary semaphore takes on numerical values 0 and 1 only. b. An atomic operation is a machine instruction or a sequence of instructions
CSE 306 -- Operating Systems Spring 2002 Solutions to Review Questions for the Final Exam 1. [20 points, 1 each] rue or False, circle or F. a. A binary semaphore takes on numerical values 0 and 1 only.
More informationCSE Traditional Operating Systems deal with typical system software designed to be:
CSE 6431 Traditional Operating Systems deal with typical system software designed to be: general purpose running on single processor machines Advanced Operating Systems are designed for either a special
More informationChapter 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 informationConcurrency: Mutual Exclusion and
Concurrency: Mutual Exclusion and Synchronization 1 Needs of Processes Allocation of processor time Allocation and sharing resources Communication among processes Synchronization of multiple processes
More informationMidterm on next week Tuesday May 4. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 9
CS 361 Concurrent programming Drexel University Fall 2004 Lecture 9 Bruce Char and Vera Zaychik. All rights reserved by the author. Permission is given to students enrolled in CS361 Fall 2004 to reproduce
More informationHomework #3. CS 318/418/618, Fall Ryan Huang Handout: 10/01/2018
CS 318/418/618, Fall 2018 Homework #3 Ryan Huang huang@cs.jhu.edu Handout: 10/01/2018 1. Microsoft.NET provides a synchronization primitive called a CountdownEvent. Programs use CountdownEvent to synchronize
More informationOperating 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 informationCS 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 informationChapter 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 informationChapter 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 informationCS350: Final Exam Review
University of Waterloo CS350: Final Exam Review Gwynneth Leece, Andrew Song, Rebecca Putinski Winter, 2010 Intro, Threads & Concurrency What are the three views of an operating system? Describe them. Define
More informationSynchronization I. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Synchronization I Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics Synchronization problem Locks 2 Synchronization Threads cooperate
More informationPESIT Bangalore South Campus
INTERNAL ASSESSMENT TEST II Date: 04/04/2018 Max Marks: 40 Subject & Code: Operating Systems 15CS64 Semester: VI (A & B) Name of the faculty: Mrs.Sharmila Banu.A Time: 8.30 am 10.00 am Answer any FIVE
More informationConcurrency. On multiprocessors, several threads can execute simultaneously, one on each processor.
Synchronization 1 Concurrency On multiprocessors, several threads can execute simultaneously, one on each processor. On uniprocessors, only one thread executes at a time. However, because of preemption
More informationLecture. DM510 - Operating Systems, Weekly Notes, Week 11/12, 2018
Lecture In the lecture on March 13 we will mainly discuss Chapter 6 (Process Scheduling). Examples will be be shown for the simulation of the Dining Philosopher problem, a solution with monitors will also
More informationConcurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and Synchronization 1 Needs of Processes Allocation of processor time Allocation and sharing resources Communication among processes Synchronization of multiple processes
More informationSynchronization. CS61, Lecture 18. Prof. Stephen Chong November 3, 2011
Synchronization CS61, Lecture 18 Prof. Stephen Chong November 3, 2011 Announcements Assignment 5 Tell us your group by Sunday Nov 6 Due Thursday Nov 17 Talks of interest in next two days Towards Predictable,
More informationCS-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! 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 informationResource 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 informationConcurrency: State Models & Design Patterns
Concurrency: State Models & Design Patterns Practical Session Week 02 1 / 13 Exercises 01 Discussion Exercise 01 - Task 1 a) Do recent central processing units (CPUs) of desktop PCs support concurrency?
More informationIT 540 Operating Systems ECE519 Advanced Operating Systems
IT 540 Operating Systems ECE519 Advanced Operating Systems Prof. Dr. Hasan Hüseyin BALIK (5 th Week) (Advanced) Operating Systems 5. Concurrency: Mutual Exclusion and Synchronization 5. Outline Principles
More informationChapter 5 Concurrency: Mutual Exclusion. and. Synchronization. Operating Systems: Internals. and. Design Principles
Operating Systems: Internals and Design Principles Chapter 5 Concurrency: Mutual Exclusion and Synchronization Seventh Edition By William Stallings Designing correct routines for controlling concurrent
More informationPre- and post- CS protocols. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 7. Other requirements for a mutual exclusion algorithm
CS 361 Concurrent programming Drexel University Fall 2004 Lecture 7 Bruce Char and Vera Zaychik. All rights reserved by the author. Permission is given to students enrolled in CS361 Fall 2004 to reproduce
More informationProcess Synchronization
Process Synchronization Concurrent access to shared data in the data section of a multi-thread process, in the shared memory of multiple processes, or in a shared file Although every example in this chapter
More informationReal-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 informationConcurrency: Mutual Exclusion (Locks)
Concurrency: Mutual Exclusion (Locks) Questions Answered in this Lecture: What are locks and how do we implement them? How do we use hardware primitives (atomics) to support efficient locks? How do we
More informationProcess Synchronization
Process Synchronization Concurrent access to shared data may result in data inconsistency Multiple threads in a single process Maintaining data consistency requires mechanisms to ensure the orderly execution
More informationSynchronization. Race Condition. The Critical-Section Problem Solution. The Synchronization Problem. Typical Process P i. Peterson s Solution
Race Condition Synchronization CSCI 315 Operating Systems Design Department of Computer Science A race occurs when the correctness of a program depends on one thread reaching point x in its control flow
More informationSynchronization Spinlocks - Semaphores
CS 4410 Operating Systems Synchronization Spinlocks - Semaphores Summer 2013 Cornell University 1 Today How can I synchronize the execution of multiple threads of the same process? Example Race condition
More informationSynchronization for Concurrent Tasks
Synchronization for Concurrent Tasks Minsoo Ryu Department of Computer Science and Engineering 2 1 Race Condition and Critical Section Page X 2 Algorithmic Approaches Page X 3 Hardware Support Page X 4
More informationUniversity 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 informationOperating 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 informationCS3733: Operating Systems
Outline CS3733: Operating Systems Topics: Synchronization, Critical Sections and Semaphores (SGG Chapter 6) Instructor: Dr. Tongping Liu 1 Memory Model of Multithreaded Programs Synchronization for coordinated
More informationCS4411 Intro. to Operating Systems Exam 1 Fall points 10 pages
CS4411 Intro. to Operating Systems Exam 1 Fall 2005 (October 6, 2005) 1 CS4411 Intro. to Operating Systems Exam 1 Fall 2005 150 points 10 pages Name: Most of the following questions only require very short
More informationLecture 5: Synchronization w/locks
Lecture 5: Synchronization w/locks CSE 120: Principles of Operating Systems Alex C. Snoeren Lab 1 Due 10/19 Threads Are Made to Share Global variables and static objects are shared Stored in the static
More informationSPIN, PETERSON AND BAKERY LOCKS
Concurrent Programs reasoning about their execution proving correctness start by considering execution sequences CS4021/4521 2018 jones@scss.tcd.ie School of Computer Science and Statistics, Trinity College
More informationDept. of CSE, York Univ. 1
EECS 3221.3 Operating System Fundamentals No.5 Process Synchronization(1) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Background: cooperating processes with shared
More informationOperating Systems. Synchronisation Part I
Operating Systems Synchronisation Part I Process Synchronisation How do processes synchronise their operation to perform a task? Key concepts: Critical sections Mutual exclusion Atomic operations Race
More informationR13 SET - 1 2. Answering the question in Part-A is compulsory 1 a) Define Operating System. List out the objectives of an operating system. [3M] b) Describe different attributes of the process. [4M] c)
More informationLecture 2: Intro to Concurrent Processing
Lecture 2: Intro to Concurrent Processing The SR Language. Correctness and Concurrency. Mutual Exclusion & Critical Sections. Software Solutions to Mutual Exclusion. Dekker s Algorithm. The Bakery Algorithm.
More informationConcurrency. On multiprocessors, several threads can execute simultaneously, one on each processor.
Synchronization 1 Concurrency On multiprocessors, several threads can execute simultaneously, one on each processor. On uniprocessors, only one thread executes at a time. However, because of preemption
More informationProcess Synchronization. Mehdi Kargahi School of ECE University of Tehran Spring 2008
Process Synchronization Mehdi Kargahi School of ECE University of Tehran Spring 2008 Producer-Consumer (Bounded Buffer) Producer Consumer Race Condition Producer Consumer Critical Sections Structure of
More information* What are the different states for a task in an OS?
* Kernel, Services, Libraries, Application: define the 4 terms, and their roles. The kernel is a computer program that manages input/output requests from software, and translates them into data processing
More informationSpring CS 170 Exercise Set 1 (Updated with Part III)
Spring 2015. CS 170 Exercise Set 1 (Updated with Part III) Due on May 5 Tuesday 12:30pm. Submit to the CS170 homework box or bring to the classroom. Additional problems will be added as we cover more topics
More informationFinal Exam Preparation Questions
EECS 678 Spring 2013 Final Exam Preparation Questions 1 Chapter 6 1. What is a critical section? What are the three conditions to be ensured by any solution to the critical section problem? 2. The following
More informationEECE.4810/EECE.5730: Operating Systems Spring 2017 Homework 2 Solution
1. (15 points) A system with two dual-core processors has four processors available for scheduling. A CPU-intensive application (e.g., a program that spends most of its time on computation, not I/O or
More informationMULTITHREADING AND SYNCHRONIZATION. CS124 Operating Systems Fall , Lecture 10
MULTITHREADING AND SYNCHRONIZATION CS124 Operating Systems Fall 2017-2018, Lecture 10 2 Critical Sections Race conditions can be avoided by preventing multiple control paths from accessing shared state
More informationCOMP 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 informationSTUDENT 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 information1995 Paper 10 Question 7
995 Paper 0 Question 7 Why are multiple buffers often used between producing and consuming processes? Describe the operation of a semaphore. What is the difference between a counting semaphore and a binary
More informationCS533 Concepts of Operating Systems. Jonathan Walpole
CS533 Concepts of Operating Systems Jonathan Walpole Introduction to Threads and Concurrency Why is Concurrency Important? Why study threads and concurrent programming in an OS class? What is a thread?
More informationProcess Synchronization
CSC 4103 - Operating Systems Spring 2007 Lecture - VI Process Synchronization Tevfik Koşar Louisiana State University February 6 th, 2007 1 Roadmap Process Synchronization The Critical-Section Problem
More informationHigh Performance Computing Course Notes Shared Memory Parallel Programming
High Performance Computing Course Notes 2009-2010 2010 Shared Memory Parallel Programming Techniques Multiprocessing User space multithreading Operating system-supported (or kernel) multithreading Distributed
More informationGATE SOLVED PAPER - CS
YEAR 2001 Q. 1 Which of the following statements is false? (A) Virtual memory implements the translation of a program s address space into physical memory address space. (B) Virtual memory allows each
More informationSNS COLLEGE OF ENGINEERING
SNS COLLEGE OF ENGINEERING Coimbatore. Department of Computer Science and Engineering Question Bank- Even Semester 2015-2016 CS6401 OPERATING SYSTEMS Unit-I OPERATING SYSTEMS OVERVIEW 1. Differentiate
More informationConcurrency: a crash course
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Concurrency: a crash course Concurrent computing Applications designed as a collection of computational units that may execute
More informationConcurrency, 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 informationBackground. The Critical-Section Problem Synchronisation Hardware Inefficient Spinning Semaphores Semaphore Examples Scheduling.
Background The Critical-Section Problem Background Race Conditions Solution Criteria to Critical-Section Problem Peterson s (Software) Solution Concurrent access to shared data may result in data inconsistency
More information