Exercise (6).

Slides:



Advertisements
Similar presentations
The Important Thing About By. The Important Thing About ******** The important thing about ***** is *****. It is true s/he can *****, *****, and *****.
Advertisements

Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Sorting algorithms Sieve of Eratosthenes
For(int i = 1; i
Operating Systems Part III: Process Management (Process Synchronization)
Background Concurrent access to shared data can lead to inconsistencies Maintaining data consistency among cooperating processes is critical What is wrong.
Process Synchronization. Module 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores.
CIS 720 Mutual Exclusion. Critical Section problem Process i do (true) entry protocol; critical section; exit protocol; non-critical section od.
© 2004, D. J. Foreman 1 The Dining Philosophers Problem.
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
1 Powers of Two: Trace Ex. Print powers of 2 that are  2 N. Increment i from 0 to N. Double v each time. int i = 0; int v = 1; while (i
The Critical-Section Problem
1 Tuesday, June 20, 2006 "The box said that I needed to have Windows 98 or better... so I installed Linux." - LinuxNewbie.org.
Section 4.2: Functions that Test Conditions (continued)
Exercise Exercise3.1 8 Exercise3.1 9 Exercise
Exercise Exercise Exercise Exercise
Exercise Exercise Exercise Exercise
Exercise Exercise6.1 7 Exercise6.1 8 Exercise6.1 9.
02/17/2010CSCI 315 Operating Systems Design1 Process Synchronization Notice: The slides for this lecture have been largely based on those accompanying.
Chapter 6: Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Module 6: Synchronization 6.1 Background 6.2 The Critical-Section.
The If/Else Statement, Boolean Flags, and Menus Page 180
Process Synchronization Topics: 1.Background 2.The critical-section problem 3.Semaphores 4.Critical Regions 5.Monitors Topics: 1.Background 2.The critical-section.
02/14/2007CSCI 315 Operating Systems Design1 Process Synchronization Notice: The slides for this lecture have been largely based on those accompanying.
1 Lecture : Concurrency: Mutual Exclusion and Synchronization Operating System Spring 2008.
Apply Properties of Rational Exponents
computer
6.3 Peterson’s Solution The two processes share two variables: Int turn; Boolean flag[2] The variable turn indicates whose turn it is to enter the critical.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization.
1 Concurrent Processes. 2 Cooperating Processes  Operating systems allow for the creation and concurrent execution of multiple processes  concurrency.
Operating Systems CMPSC 473 Mutual Exclusion Lecture 11: October 5, 2010 Instructor: Bhuvan Urgaonkar.
CSCI-375 Operating Systems Lecture Note: Many slides and/or pictures in the following are adapted from: slides ©2005 Silberschatz, Galvin, and Gagne Some.
1 Lecture 8: Concurrency: Mutual Exclusion and Synchronization Advanced Operating System Fall 2012.
Synchronicity Introduction to Operating Systems: Module 5.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
int num = 22; if (num > 0) if (num % 5 == 0) System.out.println(num); else System.out.println(num + “ is negative”);
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
A: A: double “4” A: “34” 4.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
Hypothesis Testing Steps for the Rejection Region Method State H 1 and State H 0 State the Test Statistic and its sampling distribution (normal or t) Determine.
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally INTERPROCESS COMMUNICATION AND SYNCHRONIZATION SYNCHRONIZATION.
Operators A binary operator combines two values to get one result: x OP y where OP is any binary operators such as +, -, *, /, ==, !=, >, &&, or even =.
6.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Q: 請以實際例子說明 critical section 之意 ? 何謂 race condition? while (true) { /*
Homework-6 Questions : 2,10,15,22.
Chapter 6 Synchronization Dr. Yingwu Zhu. The Problem with Concurrent Execution Concurrent processes (& threads) often access shared data and resources.
4-1 LOGIC OPERATIONS In Chapter 3 we discussed the fact that data inside a computer is stored as patterns of bits. Logic operations refer to those operations.
Factors, multiple, primes: Factors from prime factors
Review Operation Bingo
The Critical-Section Problem (Two-Process Solution)
Lecture Notes – Week 3 Lecture-2
Propositional Equivalences Rosen 5th and 6th Editions section 1.2
COP 4600 Operating Systems Spring 2011
The Critical-Section Problem
Lecture 19 Syed Mansoor Sarwar
Module 7a: Classic Synchronization
Lecture 20 Syed Mansoor Sarwar
Factors, multiple, primes: Prime factors
Questions Parallel Programming Shared memory performance issues
Chapter 6: Process Synchronization
Decimals: Multiplying by 2.5
Revision I This presentation gives you some hints for solution of selected problems.
Straight line graphs: Horizontal and vertical lines
Millennium High School Agenda Calendar
Millennium High School Agenda Calendar
Factors, multiple, primes: Multiples
Fractions: Simplifies to a unit fraction?
Straight line graphs: Horizontal and vertical lines
Standard Form: Multiplying powers of 10
Standard form: In standard form?
Coordinates: Naming 2D coordinates – quadrant 1
Operating Systems {week 10}
Presentation transcript:

Exercise (6)

Exercise Provide your explanation why the following critical section problem failed: Proc(int i){ while (TRUE){ Compute; while (turn!=i) ; Critical_section; turn = (i+1) mod 2; } Shared int turn = 1; fork(Proc, 1, 0); fork(Proc, 1, 1);

Exercise (cont'd) Provide your explanation why the following critical section problem failed: Proc(int i){ while (TRUE){ Compute; while (flag[(i+1) mod 2]) ; flag[i] = TRUE; Critical_section; flag[i] = FALSE; } Shared boolean flag[2]; flag[0] = flag[1] = FALSE; fork(Proc, 1, 0); fork(Proc, 1, 1);