Experience with Processes and Monitors in Mesa

Slides:



Advertisements
Similar presentations
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.
Advertisements

More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
1 Chapter 5 Concurrency: Mutual Exclusion and Synchronization Principals of Concurrency Mutual Exclusion: Hardware Support Semaphores Readers/Writers Problem.
Ch 7 B.
Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
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.
1 Concurrency: Mutual Exclusion and Synchronization Chapter 5.
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.
Synchronization and IPC 1 CS502 Spring 2006 More on Synchronization Interprocess Communication (IPC) CS-502 Spring 2006.
CS 3013 & CS 502 Summer 2006 IPC, Synchronization, and Monitors 1 More on Synchronization Interprocess Communication (IPC) CS-3013 & CS-502 Summer 2006.
Concurrency CS 510: Programming Languages David Walker.
Language Support for Concurrency. 2 Common programming errors Process i P(S) CS P(S) Process j V(S) CS V(S) Process k P(S) CS.
Synchronization: Monitors Hank Levy. 6/21/20152 Synchronization with Semaphores Semaphores can be used to solve any of the traditional synchronization.
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.
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
CS444/CS544 Operating Systems Classic Synchronization Problems 2/26/2007 Prof. Searleman
Process Description and Control A process is sometimes called a task, it is a program in execution.
Concurrency - 1 Tasking Concurrent Programming Declaration, creation, activation, termination Synchronization and communication Time and delays conditional.
Fundamentals of Python: From First Programs Through Data Structures
Process Description and Control. Process concepts n Definitions – replaces task, job – program in execution – entity that can be assigned to and executed.
FINAL MPX DELIVERABLE Due when you schedule your interview and presentation.
1 CS 333 Introduction to Operating Systems Class 6 – Monitors and Message Passing Jonathan Walpole Computer Science Portland State University.
© 2004, D. J. Foreman 1 High Level Synchronization and Inter-Process Communication.
Chapter 41 Processes Chapter 4. 2 Processes  Multiprogramming operating systems are built around the concept of process (also called task).  A process.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
SWE202 Review. Processes Process State As a process executes, it changes state – new: The process is being created – running: Instructions are being.
REVIEW OF COMMONLY USED DATA STRUCTURES IN OS. NEEDS FOR EFFICIENT DATA STRUCTURE Storage complexity & Computation complexity matter Consider the problem.
CSC321 Concurrent Programming: §5 Monitors 1 Section 5 Monitors.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
1 Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
1 Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Threaded Programming in Python Adapted from Fundamentals of Python: From First Programs Through Data Structures CPE 401 / 601 Computer Network Systems.
CSE 451: Operating Systems Section 5 Midterm review.
ICS 313: Programming Language Theory Chapter 13: Concurrency.
CSE 451: Operating Systems Winter 2012 Semaphores and Monitors Mark Zbikowski Gary Kimura.
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
SPL/2010 Guarded Methods and Waiting 1. SPL/2010 Reminder! ● Concurrency problem: asynchronous modifications to object states lead to failure of thread.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
Monitors and Blocking Synchronization Dalia Cohn Alperovich Based on “The Art of Multiprocessor Programming” by Herlihy & Shavit, chapter 8.
13-1 Chapter 13 Concurrency Topics Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads C# Threads.
CS533 – Spring Jeanie M. Schwenk Experiences and Processes and Monitors with Mesa What is Mesa? “Mesa is a strongly typed, block structured programming.
CSE 153 Design of Operating Systems Winter 2015 Midterm Review.
1 Process Description and Control Chapter 3. 2 Process A program in execution An instance of a program running on a computer The entity that can be assigned.
Operating System Chapter 5. Concurrency: Mutual Exclusion and Synchronization Lynn Choi School of Electrical Engineering.
CS533 Concepts of Operating Systems Class 2a Monitors.
© 2004, D. J. Foreman 1 Monitors and Inter-Process Communication.
© 2004, D. J. Foreman 1 Monitors and Inter-Process Communication.
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.
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
Module 12: I/O Systems I/O hardware Application I/O Interface
Threaded Programming in Python
Process concept.
Topics Covered What is Real Time Operating System (RTOS)
CS510 Operating System Foundations
Concurrency: Mutual Exclusion and Synchronization
Multithreading.
CSE 451: Operating Systems Winter 2004 Module 7+ Monitor Supplement
CSE 451: Operating Systems Autumn Lecture 8 Semaphores and Monitors
CSE 451: Operating Systems Winter Module 7 Semaphores and Monitors
Synchronization: Monitors
Monitors and Inter-Process Communication
Presentation transcript:

Experience with Processes and Monitors in Mesa Lampson & Redell, Processes & Monitors in Mesa Experience with Processes and Monitors in Mesa B. W. Lampson Xerox Palo Alto Research Center D. D. Redell Xerox Business Systems Communications of the ACM v.23, n.2, Feb.1980, pp. 105-117 sbwood 2005

Design Goals Local concurrent programming Global resource sharing Replacing interrupts sbwood 2005

Concurrent Programming using Monitors in Mesa Interactions with process creation and destruction How to define WAIT Priority scheduling Semantics of nested monitor calls Handling timeouts, aborts, and other exceptions Monitoring large numbers of small objects sbwood 2005

Signaling in Monitors J. H. Howard 2nd Intl. Conf Signaling in Monitors J. H. Howard 2nd Intl. Conf. of Software Engr, Oct.1976 SU signal & urgent wait Hoare’74 signaler to “urgent” queue & resumes after signaled process runs SR signal & return Brinch Hansen’75 return from monitor immediately after signaling Concurrent PASCAL SW signal & wait Howard’76 signaled immediate access signaler to monitor’s entry queue SC signal & continue signaler’s view of monitor state not corrupted requires explicit recording of signals pending Problems SU & SW: signalers might wait & restart unnecessarily SR simplest but may be inadequate & SC complex sbwood 2005

Excerpt of Tanenbaum’s Example of Hoare Semantic Monitor ProducerConsumer condition full, empty; integer count; procedure insert (item; integer); begin Modification for Mesa Semantic if count = N then wait (full); while not count = N do wait (full) insert_item (item); count := count + 1; if count = 1 then signal (empty); end; Hoare semantic Mesa semantic Signaling thread suspends on urgent Signaled thread wakes & runs immediately First thread regains possession of monitor when second completes Signaling thread continues Signaled thread rechecks condition because order not guaranteed Avoid context switch sbwood 2005

Allocate: ENTRY PROCEDURE [size: INTEGER StorageAllocator: MONITOR = BEGIN availableStorage: INTEGER: moreAvailable: CONDITION: Allocate: ENTRY PROCEDURE [size: INTEGER RETURNS [p: POINTER] = BEGIN UNTIL availableStorage >= size DO WAIT moreAvailable ENDLOOP; p <- <remove chunk of size words & update availableStorage> END; Free: ENTRY PROCEDURE [p: POINTER, Size: INTEGER] = BEGIN <put back chunk of size words & update availableStorage>; NOTIFY moreAvailable END; Expand:PUBLIC PROCEDURE [pOld: POINTER, size: INTEGER] RETURNS [pNew: POINTER] = BEGIN pNew <- Allocate[size]; <copy contents from old block to new block>; Free[pOld] END; END. sbwood 2005

Mutual exclusion Asynchronous processes must not Allocate and Free simultaneously → use entry procedures Monitor lock not needed during copy in Expand → use external procedure Structure the monitor computations only when lock is already held → use internal procedure sbwood 2005

Define WAIT If caller waits in entry procedure, it releases the lock If wait in internal procedure, the lock is released If monitor calls procedure outside the monitor, the lock is not released sbwood 2005

Invariant Always true, except when process is executing in the monitor On entry, invariant assumed to hold Invariant established before control leaves monitor Monitor procedure must establish invariant before WAIT Consider exception handler called from entry procedure sbwood 2005

Causes of Pair-wise Deadlock 2 processes WAIT in a single monitor Cyclic calling between 2 monitors → impose a partial order Two level data abstraction sbwood 2005

Two level data abstraction Example: Monitor M calls N and waits for C requires process to enter N through M to set C → DEADLOCK Divide M into monitor M’ and interface O to call N sbwood 2005

Monitored Objects Collection of shared data objects Multiple instances of monitor Duplication of program linking and code swapping Monitored record To access a file, pass as parameter to effectively create a separate monitor for each object (read-only, no aliasing) sbwood 2005

Abandon computation UNWIND exception to allow clean-up by any active procedure If procedure to be abandoned is an entry procedure, must restore invariant and release lock Programmer provides handler or experiences deadlock Compare to Java exception handling sbwood 2005

Condition variables Process establishes a condition for which another process waits NOTIFY is a hint that waiting process will resume and reacquire the monitor lock No guarantee about another process interceding Waiter must reevaluate when it resumes Mesa WHILE NOT <OK to proceed> DO WAIT c ENDLOOP Hoare IF NOT <OK to proceed> THEN WAIT c sbwood 2005

Verification rules Simpler and more localized Invariant established before return from entry procedure or a WAIT Invariant assumed at start of entry procedure and just after a WAIT Waiter explicitly tests Notify condition may be more general (low cost to wake a process) sbwood 2005

NOTIFY alternatives Timeout with interval Abort Broadcast I/O device communication device cannot wait on monitor lock notify condition variable to wake interrupt handler sbwood 2005

Priorities Ordering implied by assignment of priorities can be subverted by monitors Associate with each monitor the priority of the highest priority process that ever enters the monitor (Modula disables interrupts, but this fails with page fault.) sbwood 2005

Example of subverted priority Process P1 enters monitor M, P2 preempts, P3 preempts P3 tries to enter monitor and waits for lock P1 enter M P2 preempt P1 P3 preempt P2 P2 runs again, effectively keeps P3 from running, undermining the priorities. sbwood 2005

Lampson & Redell, Processes & Monitors in Mesa Processor Process states (pcbs) in queues sorted by priority Ready queue Monitor lock queue Condition variable queue Fault queue Queue cell process state process state process state ---- head tail sbwood 2005 sbwood 2005

Implementation Compiler – flags errors WAIT in external procedure direct call from external to internal procedure Runtime – process creation and destruction Machine – process scheduling and monitor entry/exit sbwood 2005

Performance sbwood 2005

Validation of Mesa Semantic Operating system Interrupt handling lack of mutual exclusion Interaction of concurrency and exception Database Single monitor and single condition variable Array of representative states Network communication Router monitor Network driver monitor sbwood 2005

Closing comparison sbwood 2005

Implementation sbwood 2005

Questions Should signal be the last operation of a monitor procedure? Monitor – low level mechanism Starvation addressed by high level scheduling Simpler & localized verification rules Signaled process checks specific condition More general condition for notify Questions Should signal be the last operation of a monitor procedure? How is exception handling addressed? sbwood 2005