Experience with Processes and Monitors in Mesa p. 1/1

Similar documents
Monitors in Mesa. Josh Triplett. January 17, Message passing harder to integrate into Mesa type system

Experience with Processes and Monitors in Mesa. Arvind Krishnamurthy

CSE 153 Design of Operating Systems

CS533 Concepts of Operating Systems. Jonathan Walpole

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University

Lecture 9: Midterm Review

CS 318 Principles of Operating Systems

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 is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem?

Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5

UNIT:2. Process Management

Need for synchronization: If threads comprise parts of our software systems, then they must communicate.

Threads Questions Important Questions

Operating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski

CSE 153 Design of Operating Systems

Operating Systems (1DT020 & 1TT802)

Deadlock and Monitors. CS439: Principles of Computer Systems September 24, 2018

Concurrency Control. Synchronization. Brief Preview of Scheduling. Motivating Example. Motivating Example (Cont d) Interleaved Schedules

CMPS 111 Spring 2013 Prof. Scott A. Brandt Midterm Examination May 6, Name: ID:

What's wrong with Semaphores?

G Programming Languages Spring 2010 Lecture 13. Robert Grimm, New York University

SYNCHRONIZATION M O D E R N O P E R A T I N G S Y S T E M S R E A D 2. 3 E X C E P T A N D S P R I N G 2018

Dealing with Issues for Interprocess Communication

Lecture 8: September 30

Concurrency, Thread. Dongkun Shin, SKKU

IT 540 Operating Systems ECE519 Advanced Operating Systems

Monitors (Deprecated)

Lecture 7: CVs & Scheduling

Midterm Exam Amy Murphy 19 March 2003

CSE 120 Principles of Operating Systems Spring 2016

CSE 410: Systems Programming

Goals. Processes and Threads. Concurrency Issues. Concurrency. Interlacing Processes. Abstracting a Process

Resource management. Real-Time Systems. Resource management. Resource management

Module 1. Introduction:

CPS 310 second midterm exam, 11/14/2014

Page 1. Goals for Today" Atomic Read-Modify-Write instructions" Examples of Read-Modify-Write "

1 Process Coordination

Page 1. Goals for Today. Atomic Read-Modify-Write instructions. Examples of Read-Modify-Write

Concurrent Programming Synchronisation. CISTER Summer Internship 2017

Lecture #7: Implementing Mutual Exclusion

Last Class: CPU Scheduling! Adjusting Priorities in MLFQ!

Operating Systems. Operating Systems Summer 2017 Sina Meraji U of T

Synchronization. Dr. Yingwu Zhu

JAVA CONCURRENCY FRAMEWORK. Kaushik Kanetkar

CS 167 Final Exam Solutions

EECS 482 Introduction to Operating Systems

Student Name:.. Student ID... Course Code: CSC 227 Course Title: Semester: Fall Exercises Cover Sheet:

Operating Systems: Quiz2 December 15, Class: No. Name:

Operating Systems ECE344

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Main Points of the Computer Organization and System Software Module

Concurrent Programming using Threads

Page 1. Goals for Today" Atomic Read-Modify-Write instructions" Examples of Read-Modify-Write "

Implementing Scheduling Algorithms. Real-Time and Embedded Systems (M) Lecture 9

The University of Texas at Arlington

The University of Texas at Arlington

CS-537: Midterm Exam (Spring 2001)

CPSC/ECE 3220 Summer 2017 Exam 2

Multi-core Architecture and Programming

1 PROCESSES PROCESS CONCEPT The Process Process State Process Control Block 5

Operating systems and concurrency (B08)

Synchronization. CSCI 5103 Operating Systems. Semaphore Usage. Bounded-Buffer Problem With Semaphores. Monitors Other Approaches

Threads and concurrency

Threads and concurrency

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 8: Semaphores, Monitors, & Condition Variables

Interprocess Communication By: Kaushik Vaghani

Concurrency: a crash course

Roadmap for This Lecture

CS140 Operating Systems and Systems Programming Midterm Exam

Performance Throughput Utilization of system resources

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

General Objectives: To understand the process management in operating system. Specific Objectives: At the end of the unit you should be able to:

COMP 3361: Operating Systems 1 Final Exam Winter 2009

Operating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017

Real-Time Systems. Lecture #4. Professor Jan Jonsson. Department of Computer Science and Engineering Chalmers University of Technology

The Synchronization Toolbox

CS/ECE 6780/5780. Al Davis

Page 1. Lab 5 Logistics. Implicit Threads. Explicit Thread Semantics. Problem not enough interrupt pins CS/ECE 6780/5780. Al Davis

CHAPTER 6: PROCESS SYNCHRONIZATION

Concurrency. Chapter 5

Review. Preview. Three Level Scheduler. Scheduler. Process behavior. Effective CPU Scheduler is essential. Process Scheduling

Real-Time Programming

Threads. Concurrency. What it is. Lecture Notes Week 2. Figure 1: Multi-Threading. Figure 2: Multi-Threading

Interrupts and Time. Real-Time Systems, Lecture 5. Martina Maggio 28 January Lund University, Department of Automatic Control

February 23 rd, 2015 Prof. John Kubiatowicz

Lecture 13 Concurrent Programming

Multiprocessor and Real- Time Scheduling. Chapter 10

Lesson 6: Process Synchronization

Opera&ng Systems ECE344

Chapter 5 Concurrency: Mutual Exclusion and Synchronization

Operating System Support

Remaining Contemplation Questions

Deadlock and Monitors. CS439: Principles of Computer Systems February 7, 2018

Real-Time and Concurrent Programming Lecture 4 (F4): Monitors: synchronized, wait and notify

Chapter 6 Process Synchronization

Last Class: Monitors. Real-world Examples

Operating Systems Antonio Vivace revision 4 Licensed under GPLv3

Introduction to Real-Time Operating Systems

Synchronization 1. Synchronization

Last Class: Synchronization. Review. Semaphores. Today: Semaphores. MLFQ CPU scheduler. What is test & set?

Transcription:

Experience with Processes and Monitors in Mesa Authors: Butler W. Lampson, David D. Redell Presented by: John McCall rjmccall@cs.pdx.edu Experience with Processes and Monitors in Mesa p. 1/1

Star and Pilot The Xerox Star (1981) was a personal workstation designed for office use; it was a fairly visionary device, with many of the features (a graphical display, a mouse, icons, overlapping windows, ethernet) of a modern PC. The Star s operating system was Pilot: pre-emptive multitasking (but not timeslicing) virtual memory (but all memory was shared unprotected, including Pilot s) Experience with Processes and Monitors in Mesa p. 2/1

Mesa Pilot and the entire Star application suite were written in Mesa, a high-level (hence the name) programming language written specifically for this purpose. Mesa was a successor of Modula and ALGOL and a predecessor of Modula-2 and -3; DoD originally considered Mesa for its institutional PL, but Xerox refused, and so DoD created Ada. Mesa is a procedural language with rich support for exceptions, modularity, and concurrency; balancing these is a key point of Mesa s design. Experience with Processes and Monitors in Mesa p. 3/1

Concurrency in Mesa Processes in Mesa are lightweight. All processes share the same memory space, and a process has no explicit stack; instead, a process simply allocates stack frames on the heap. Processes can safely share data and wait for events using monitors and condition variables. These are slightly different from how they were presented in Hoare. Experience with Processes and Monitors in Mesa p. 4/1

Alternatives to Monitors The Mesa designers considered some alternatives to monitors: They could use message-passing, but it s harder to support in the language, and they were already committed to using procedures. They could rely on non-preemption, but: they didn t want to rely on having a uniprocessor architecture programmers wouldn t be able to call functions which just coincidentally yield virtual memory and I/O can cause preemptions anyway Experience with Processes and Monitors in Mesa p. 5/1

Monitors and Modularity A module in Mesa is a collection of private variables and private procedures (which can t be seen outside the module) and public procedures (which can be called by anyone). A monitor module is a special kind of module which can also have public entry procedures which acquire the monitor s lock on entry and release it on exit. Mesa also allows monitors to be dynamically created, which isn t possible in Hoare. Experience with Processes and Monitors in Mesa p. 6/1

Condition Variables, Part 1 Hoare s semantics: if P 1 is waiting on V, then if P 2 signals V, the system must immediately resume P 1. Mesa s semantics: P 1 resumes whenever it s convenient for the system, potentially even if V hasn t been signalled. These semantics are much weaker! Hoare s semantics allow for some precise control over scheduling which can t be achieved anymore. Furthermore, Mesa s semantics require the actual condition to be checked after a wakeup; Hoare s semantics provide a guarantee of correctness. Worse, Mesa s semantics allow for starvation: by the time P 1 resumes, some other process might have already reacquired the lock! Experience with Processes and Monitors in Mesa p. 7/1

Condition Variables, Part 2 It turns out that Mesa s semantics are usually better: Hoare s semantics mandate a context-switch which usually isn t required. Hoare s semantics make some very stringent demands of schedulers. Therefore Mesa s semantics are usually cheaper and easier to implement. Anyway, the low level scheduling mechanism provided by monitor locks should not be used to implement high level scheduling decisions. Hoare s semantics encourage programmers to only signal a variable if they re absolutely sure the waiter will be ready to run afterwards; Mesa s semantics make spurious signals much cheaper. Experience with Processes and Monitors in Mesa p. 8/1

Condition Variables, Part 3 Mesa s semantics also encourage some easy extensions to the condition-variable API. signal() is now called notify(). broadcast() wakes up every thread that s waiting on the condition. A call to wait() can time-out, which is frequently useful in practical programs. notify() can be safely called without holding the lock if the condition variable is turned into a binary semaphore (this eliminates a potential race condition). Experience with Processes and Monitors in Mesa p. 9/1

Queues Scheduling in Mesa/Pilot/Star is implemented using a simple, hardware-supported round-robin scheduler. A process is always in one of four types of queues: The processor s job is to always run the first job in the system-wide ready queue. Monitor locks have associated monitor lock queues. Condition variables have associated condition variable queues. Faults cause processes to move into a fault queue. When a process is notified, it is moved to the tail of the ready queue. The processor occaisionally scans the full process table and notifies any process whose timeout has expired. Experience with Processes and Monitors in Mesa p. 10/1

Priorities, Part 1 It can be useful in many applications to suggest to the scheduler that some work is more important than others. In Mesa/Pilot, every process is assigned a priority, and a process is only scheduled if no higher-priority process is available; this is implemented by sorting the ready queue in reverse order of priority. Experience with Processes and Monitors in Mesa p. 11/1

Priorities, Part 2 This approach suffers from a problem (now) called priority inversion. Let P 1, P 2, and P 3 be processes, where higher-numbered processes have higher priorities. Suppose that P 2 and P 3 are waiting on something, and P 1 enters a monitor M. P 3 wakes up and tries to enter M, but is blocked. P 2 wakes up and runs for awhile, preventing P 1 from running and exiting its critical section, which would allow P 3 to resume; in effect, P 3 is blocked by P 2. This problem does not arise in all applications, and it can be addressed by temporarily raising the priority of any process entering a monitor to the maximum priority of any process which ever enters the monitor. Experience with Processes and Monitors in Mesa p. 12/1

Deadlock Mesa monitors are non-recursive, so a monitor entry procedure can t call itself or any other entry procedure of that monitor. The compiler can check for this. If monitor M 1 calls monitor M 2, and M 2 calls M 1, there s a possibility for deadlock. This can be solved by always entering monitors in a particular order i.e. there should never be any mutally-recursive monitors. If P 1 is inside monitors M 1 and M 2, and P 1 waits on a condition variable V inside M 2, only M 2 is released; P 2 might want to signal V, but might instead be blocked because it needs to enter M 1 first. Every process can be waiting on a condition variable, each expecting one of the others to wake it up. Experience with Processes and Monitors in Mesa p. 13/1