CS533 – Spring 2006 - Jeanie M. Schwenk Experiences and Processes and Monitors with Mesa What is Mesa? “Mesa is a strongly typed, block structured programming.

Slides:



Advertisements
Similar presentations
Operating Systems Semaphores II
Advertisements

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.
1 Chapter 5 Concurrency: Mutual Exclusion and Synchronization Principals of Concurrency Mutual Exclusion: Hardware Support Semaphores Readers/Writers Problem.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Ch 7 B.
Chapter 6: Process Synchronization
5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 5: CPU Scheduling.
CS533 - Concepts of Operating Systems 1 Presentation Summary of “Experiences with Processes and Monitors in Mesa” By Burke Ellett.
1 Semaphores and Monitors: High-level Synchronization Constructs.
CS533 Concepts of Operating Systems Class 3 Monitors.
CS533 Concepts of Operating Systems Class 3 Monitors.
Concurrent Processes Lecture 5. Introduction Modern operating systems can handle more than one process at a time System scheduler manages processes and.
Concurrency: Mutual Exclusion, Synchronization, Deadlock, and Starvation in Representative Operating Systems.
Monitors CSCI 444/544 Operating Systems Fall 2008.
CS533 - Concepts of Operating Systems 1 Class Discussion.
CPS110: Implementing threads/locks on a uni-processor Landon Cox.
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
Monitors: An Operating System Structuring Concept
CS510 Concurrent Systems Introduction to Concurrency.
Experience with Processes and Monitors in Mesa
Nachos Phase 1 Code -Hints and Comments
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
© 2004, D. J. Foreman 1 High Level Synchronization and Inter-Process Communication.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
1 Announcements The fixing the bug part of Lab 4’s assignment 2 is now considered extra credit. Comments for the code should be on the parts you wrote.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Mutual Exclusion.
Internet Software Development Controlling Threads Paul J Krause.
CSC321 Concurrent Programming: §5 Monitors 1 Section 5 Monitors.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
11/18/20151 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam.
11/21/20151 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam.
ICS 313: Programming Language Theory Chapter 13: Concurrency.
Chapter 7 -1 CHAPTER 7 PROCESS SYNCHRONIZATION CGS Operating System Concepts UCF, Spring 2004.
Chapter 6 – Process Synchronisation (Pgs 225 – 267)
1 Interprocess Communication (IPC) - Outline Problem: Race condition Solution: Mutual exclusion –Disabling interrupts; –Lock variables; –Strict alternation.
Java Thread and Memory Model
SPL/2010 Guarded Methods and Waiting 1. SPL/2010 Reminder! ● Concurrency problem: asynchronous modifications to object states lead to failure of thread.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
1 Condition Variables CS 241 Prof. Brighten Godfrey March 16, 2012 University of Illinois.
COSC 3407: Operating Systems Lecture 9: Readers-Writers and Language Support for Synchronization.
CSE 153 Design of Operating Systems Winter 2015 Midterm Review.
CS533 Concepts of Operating Systems Class 2a Monitors.
CS510 Concurrent Systems Jonathan Walpole. Introduction to Concurrency.
© 2004, D. J. Foreman 1 Monitors and Inter-Process Communication.
© 2004, D. J. Foreman 1 Monitors and Inter-Process Communication.
CS3771 Today: Distributed Coordination  Previous class: Distributed File Systems Issues: Naming Strategies: Absolute Names, Mount Points (logical connection.
Where Testing Fails …. Problem Areas Stack Overflow Race Conditions Deadlock Timing Reentrancy.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
CS162 Section 2. True/False A thread needs to own a semaphore, meaning the thread has called semaphore.P(), before it can call semaphore.V() False: Any.
Tutorial 2: Homework 1 and Project 1
CS703 - Advanced Operating Systems
Multithreading / Concurrency
Chapter 5: Process Synchronization – Part 3
Background on the need for Synchronization
CS510 Operating System Foundations
Day 13 Concurrency.
Day 15 Concurrency.
CS510 Operating System Foundations
Multithreading.
Multithreading.
Concurrency: Mutual Exclusion and Process Synchronization
CSE 451: Operating Systems Autumn 2003 Lecture 7 Synchronization
CSE 451: Operating Systems Autumn 2005 Lecture 7 Synchronization
CSE 451: Operating Systems Winter 2003 Lecture 7 Synchronization
CSE 153 Design of Operating Systems Winter 19
CS333 Intro to Operating Systems
Monitors and Inter-Process Communication
CSE 542: Operating Systems
CSE 542: Operating Systems
Presentation transcript:

CS533 – Spring Jeanie M. Schwenk Experiences and Processes and Monitors with Mesa What is Mesa? “Mesa is a strongly typed, block structured programming language whose syntax is similar to that of Pascal. “ [1] Besides being a language, it is essentially a scheduler for resources with one monitor per resource. Design Goals of Mesa Develop a model for controlling concurrency using monitors for: 1) local concurrent programming 2) global resource sharing 3) replace use of interrupts

CS533 – Spring Jeanie M. Schwenk Other options for concurrency ● Considered but rejected: – Message passing ● deemed to be equal to monitors but the message passing would require more work to develop a message-passing scheme – Shared memory ● It would not work on multiple processors ● Needed an additional preemptive mechanism (ie interrupts ● Would need mutex ● If didn't use mutex, needed sempahore

CS533 – Spring Jeanie M. Schwenk Mesa Monitor Review ● Has procedures and global data – Entry procedure(s) for asynchronous access ● To gain access to the critical section ● Must hold the lock ● Called from outside the monitor – Internal procedure(s) ● Must hold the lock ● Is private ● Called from inside the monitor – External procedure(s) (Hoare does not have) ● Non-monitor activity (not in critical section) ● Global data – not seen outside the monitor ● global to the critical section but still private data

CS533 – Spring Jeanie M. Schwenk Problems Addressed by Mesa ● Not handled by other monitor papers 1. Dynamic process creation and destruction 2. Semantics of nested monitor calls 3. Defining the meaning of WAIT 4. Priority scheduling 5. Exception handling (e.g. aborts, timeouts) 6. Monitoring large numbers of small objects 7. I/O

CS533 – Spring Jeanie M. Schwenk 1. Dynamic Creation of processes in Mesa ● New process is invoked concurrently with its caller (can be detached) ● Communicate with a process the same way you communicate with a procedure ● Can call with parameters ● Can return a value ● Subject to strict type checking ● No special declaration for a procedure that is invoked by a process ● Cost of creating/destroying is moderate (why?) ● Allows interprocess communication without much overhead.

CS533 – Spring Jeanie M. Schwenk 2. Patterns of Deadlocks ● Single process deadlocks with self (recursive) – Avoid recursive entry procedures ● 2 processes end up in WAIT, each waiting for the other to wake it up – Typically a bug that needs to be corrected ● Cyclic dependency among monitors – Impose partial ordering ● Order dependent – Break monitors into smaller parts

CS533 – Spring Jeanie M. Schwenk 3. WAIT defined ● If a caller has to wait in an entry procedure, – It signals with a Notify – It releases the lock (waiting process will need to reacquire it when it enters the monitor) ● If wait is in one of the internal procedures, the lock is released ● If a monitor calls an external procedure, the lock is NOT acquired or released because the lock is already held

CS533 – Spring Jeanie M. Schwenk 3. WAIT continued ● Mesa WHILE NOT DO WAIT c ENDLOOP Results in an extra evaluation of the condition but there are no extra process switches and no constraints on when the waiting process can run after a notify ● Hoare IF NOT THEN WAIT c

CS533 – Spring Jeanie M. Schwenk 3. WAIT summary ● Mesa: a monitor that is in a WAIT releases the lock. ● When control leaves the monitor, the invariant must be established: – before returning – before doing a WAIT ● Whenever control enters the monitor, the invariant can be assumed. – At the start of an entry procedure – after a WAIT

CS533 – Spring Jeanie M. Schwenk Conditions ● Condition.wait – Release monitor lock – Put process to sleep. – When process wakes up again, re-acquire monitor lock immediately. ● Condition.notify – Wake up (at some time in the future) some process waiting on the condition variable (queue). ● Hoare's definition a process must run immediately – If nobody waiting, do nothing. Signal is lost. ● Condition.broadcast – Wake all processes waiting on the condition variable (queue) – If nobody waiting, do nothing. Signal is lost.

CS533 – Spring Jeanie M. Schwenk Notify ● For resuming waiting processes ● Really only a hint – Signaler continues vs signal yields (Hoare) ● Alternatives to attract the attention of a waiting process – Timeout – Abort – Broadcast

CS533 – Spring Jeanie M. Schwenk 4. Priority Scheduling ● Hoare's method allows more “senior” threads to obtain the lock ● Mesa does not so it has to have a way to ensure starvation does not occur ● Associate with each monitor the priority of the highest priority process which never enters a monitor. Then when a process enters a monitor, its priority is temporarily increased.

CS533 – Spring Jeanie M. Schwenk 5. Exception Handling ● UNWIND ● Uses the procedure call process to control the processing of exceptions – they either run concurrently or are separate processes (becomes the root process that must deal with an exception if it occurs)

CS533 – Spring Jeanie M. Schwenk 6. Monitored Shared Data Objects ● Examples: file, database, external storage ● Want to be able to add and remove shared data objects as needed ● Access needs to be serializable – To accomplish ● Single monitor per object ● Multiple monitor instances per object ● ● Monitored record – Programmer specifies how to access the monitored record but Mesa's type system does not support this well

CS533 – Spring Jeanie M. Schwenk 7. I/O Handling ● Problem: Devices cannot wait on a monitor lock ● Solution: a notify that does not acquire a lock ● A naked notify is a notify that causes an interrupt handler to take over so the actions can be atomic.

CS533 – Spring Jeanie M. Schwenk Summary/Conclusion ● Hoare monitor construct: entry and internal procedures ● Mesa: entry, internal and external procedures ● Hoare monitor – Fixed number of monitors – Does not handle excpetions ● Mesa – Dynamic number of monitors - can grow and shrink as necessary – A monitor can have an exception handler associated with it – Can create dangling processes (can be a monitor)

CS533 – Spring Jeanie M. Schwenk Summary/Conclusion ● Hoare monitor – a waiting process can run when another monitor signals that variable – signalling process runs as soon as the waiter leaves the monitors (the signaling thread yields.) – the wait checks the invariant once (in an if statement) because it assumes the lock still holds ● Mesa monitor – waiting process has to check condition to resume because notify makes no guarantee of condition – the released thread yields the monitor – notify thread retains the lock and continues – The wait has to be checked in a loop

CS533 – Spring Jeanie M. Schwenk References ● [1] ● [2] ● ● Modern Operating Systems 2 nd edition, Andrew S. Tanenbaum ● ● microsoft.com/en-US/library/ms228964%28VS.80%29.aspx microsoft.com/en-US/library/ms228964%28VS.80%29.aspx ● types.html types.html

CS533 – Spring Jeanie M. Schwenk Invariant process: Conditions & Locks “An invariant is a condition or relation that is true when the associated lock is being set. Once the lock is set, the invariant can be false. However, the code that holds the lock must reestablish the invariant before releasing the lock.” [2]