Il Barbiere Addormentato (versione con Monitor) type salone = monitor var poltronaoccupata, barbieredorme : boolean slibere :integer sedia, taglia, sveglia:

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.
Module 6: Process Synchronization
Stacks, Queues, and Linked Lists
Operating Systems: Monitors 1 Monitors (C.A.R. Hoare) higher level construct than semaphores a package of grouped procedures, variables and data i.e. object.
Modules Program is built out of components. Each component defines a set of logically related entities (strong internal coupling) A component has a public.
Solving IPs – Cutting Plane Algorithm General Idea: Begin by solving the LP relaxation of the IP problem. If the LP relaxation results in an integer solution,
Naredba If..Then..Else... Procedure TForm1.Button1Click ( SEnder: Tobject ); Var x, y, Max : Integer; Begin x := StrToInt ( Edit1.Text ); y := StrToInt.
Software Transactional Memory and Conditional Critical Regions Word-Based Systems.
Queues1 Part-B2 Queues. Queues2 The Queue ADT (§4.3) The Queue ADT stores arbitrary objects Insertions and deletions follow the first-in first-out scheme.
Chapter 2.5 Modula 2 Control Instructions. Modula 2 Control Statements Selection statements –BOOLEAN Selector : IF statement –Ordinal Selector : CASE.
Parallel and Distributed Simulation
Lecture # 21 Chapter 6 Uptill 6.4. Type System A type system is a collection of rules for assigning type expressions to the various parts of the program.
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
An Introduction to Hashing. By: Sara Kennedy Presented: November 1, 2002.
Process Synchronization Continued 7.2 The Critical-Section Problem.
Lab2: Semaphores and Monitors. Credits Material in this slide set is from G. Andrews, “Foundation of Multithreaded, Parallel, and Distributed Programming”,
Informationsteknologi Wednesday, September 26, 2007 Computer Systems/Operating Systems - Class 91 Today’s class Mutual exclusion and synchronization 
James TamThe Bubble Sort in Pascal Sorting (Bubble) In this section of notes you will learn one technique for ordering a list.
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
Section 4.2: Functions that Test Conditions (continued)
Process Synchronization
J. Michael Moore Searching & Sorting CSCE 110. J. Michael Moore Searching with Linear Search Many times, it is necessary to search an array to find a.
Synchronization April 14, 2000 Instructor Gary Kimura Slides courtesy of Hank Levy.
Synchronization Solutions
6: Process Synchonization II 1 PROCESS SYNCHRONIZATION II THE BOUNDED BUFFER ( PRODUCER / CONSUMER ) PROBLEM: This is the same producer / consumer problem.
University of Pennsylvania 9/28/00CSE 3801 Concurrent Programming (Critical Regions, Monitors, and Threads) CSE 380 Lecture Note 6 Insup Lee.
1 Chapter 9 Spaces with LINDA. 2 Linda Linda is an experimental programming concept unlike ADA or Occam which are fully developed production-quality languages.
Monitor  Giving credit where it is due:  The lecture notes are borrowed from Dr. I-Ling Yen at University of Texas at Dallas  I have modified them and.
The Critical Section Problem
Silberschatz and Galvin  Operating System Concepts Module 6: Process Synchronization Background The Critical-Section Problem Synchronization.
Principles of Operating Systems Lecture 6 and 7 - Process Synchronization.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 7 Process Synchronization Slide 1 Chapter 7 Process Synchronization.
Pascal Programming Written by Leung King Yung. Simple Program 1 begin end.
Process Synchronization Tanenbaum Ch 2.3, 2.5 Silberschatz Ch 6.
ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 24 Critical Regions.
Fall 2000M.B. Ibáñez Lecture 08 High Level mechanisms for process synchronization Critical Regions Monitors.
Queue. Avoid confusion Britain Italy 6 Applications of Queues Direct applications –Waiting lists, bureaucracy –Access to shared resources (e.g.,
Elementary Sorting 30 January Simple Sort // List is an array of size == n for (i = 1; i < n; i++) for (j = i+1; j List[j])
A: A: double “4” A: “34” 4.
The If Statement There are no switch statements in Python. You need to use just if statements. There are no switch statements in Python. You need to use.
DATA TYPES, VARIABLES AND CONSTANTS. LEARNING OBJECTIVES  Be able to identify and explain the difference between data and information  Be able to identify,
June 11, 2002Serguei A. Mokhov, 1 The Monitor COMP346 - Operating Systems Tutorial 7 Edition 1.2, June 15, 2002.
Sensor Information: while loops and Boolean Logic.
Written by Al.So. Software solutions
“Language Mechanism for Synchronization”
Day 13 Concurrency.
Day 15 Concurrency.
Chapter 6-7: Process Synchronization
CPSC Pascal Brent M. Dingle Texas A&M University 2001, 2002
Review Operation Bingo
The Critical-Section Problem (Two-Process Solution)
The C++ IF Statement Part 2 Copyright © Curt Hill
البرمجة بلغة الفيجول بيسك ستوديو
البرمجة بلغة فيجول بيسك ستوديو
kbkjlj/m/lkiubljj'pl;
Semaphore Originally called P() and V() wait (S) { while S <= 0
Queues: Implemented using Arrays
Synchronization Hank Levy 1.
Selection Statements.
CSE 451: Operating Systems Autumn Lecture 8 Semaphores and Monitors
The structure of programming
Synchronization Hank Levy 1.
COMP108 Algorithmic Foundations Searching
COMP108 Algorithmic Foundations Searching
Inequalities TRUE FALSE.
Сабақтың тақырыбы: Мәлімет типтері. Шамалардың сипатталуы
Flow of Control Flow of control is the order in which a program performs actions. Up to this point, the order has been sequential. A branching statement.

Presentation transcript:

Il Barbiere Addormentato (versione con Monitor) type salone = monitor var poltronaoccupata, barbieredorme : boolean slibere :integer sedia, taglia, sveglia: condition procedure entry Avanti-il-prossimo begin if poltronaoccupata then begin if slibere < max then begin slibere := slibere + 1 sedia.signal end else begin barbieredorme := true sveglia.wait barbieredorme := false end

Procedure entry Si-Accomodi begin poltronaoccupata := false taglia.signal end Procedure entry Vado-dal-Barbiere (var done: boolean) begin done := true if (poltronaoccupata.OR. slibere < max ) then if slibere = 0 then done := false else begin slibere := slibere - 1 sedia.wait end if done then begin poltronaoccupata := true if barbieredorme then sveglia.signal taglio.wait end begin pltronaoccupata:= false barbieredorme := false slibere := max end

Process Barbiere repeat begin Avanti-il-prossimo Si-Accomodi end forever Process Cliente var done: boolean begin : Vado-dal-Barbiere (done) if done then : end

Il Barbiere Addormentato (versione con RCC) var salone: shared record clienti : 0..max (0) tagliofinito : boolean (false) Process Barbiere repeat region salone when ( clienti > 0) do begin clienti := clienti - 1 end region salone begin tagliofinito := true end forever

Process Cliente var done: boolean begin : region salone do begin if clienti < max then begin clienti := clienti + 1 done := true end else done := false end if done then region salone when tagliofinito do begin tagliofinito := false end : end

Il Barbiere Addormentato (versione con RPC) Process salone var poltronalibera : boolean slibere :integer attesa:queue of process begin slibere : = N poltronalibera:=true do (poltronalibera.and. slibere < N); accept Avanti-il-prossimo (out client : process) do …..od accept Vado-dal-barbiere (in client: process, out done: boolean) do …..od accept Ho-finito (in client) do …..od od end

accept Vado-dal-barbiere (in: client: process, out: done: boolean) do if slibere = 0 thendone := false else begin slibere := slibere - 1 insert (client, attesa) done := true end od accept Avanti-il-prossimo (out client : process) do begin slibere := slibere+ 1 client:= first (attesa) poltronalibera:= false end od accept Ho-finito (in client) do begin client.Si-accomodi poltronalibera:= true end

Process Barbiere var cliente: process begin : repeat begin salone. Avanti-il-prossimo (var cliente) salone. Ho-finito (cliente) end forever Process Cliente var done: boolean begin : salone. Vado-dal-barbiere (myname, done) if done then else accept Si-Accomodi do od end