processes and monitors in mesa experience with
TRANSCRIPT
![Page 1: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/1.jpg)
Experience with Processes and
Monitors in MesaButler W. Lampson
David D. Redell
Presented by Priyal and Tina
![Page 2: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/2.jpg)
Outline● Introduction● Monitors● Condition Variables
○ Different ways to notify
● Processes● Discussion Questions
![Page 3: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/3.jpg)
Introduction● Built at Xerox PARC in late 1970s
![Page 4: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/4.jpg)
Introduction● Built at Xerox PARC in late 1970s● Problem they are trying to solve: Concurrency between lightweight
processes (threads today) ○ Multiple processes running in a time sliced fashion in Pilot ○ Want to support a preemptive scheduler
![Page 5: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/5.jpg)
● Built at Xerox PARC in late 1970s● Problem they are trying to solve: Concurrency between lightweight
processes (threads today)○ Multiple processes running in a time sliced fashion in Pilot ○ Want to support a preemptive scheduler
● Both the OS and programs written in Mesa, natural to design language to contain concurrency support
Introduction
![Page 6: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/6.jpg)
● Built at Xerox PARC in late 1970s● Problem they are trying to solve: Concurrency between lightweight
processes (threads today)○ Multiple processes running in a time sliced fashion in Pilot ○ Want to support a preemptive scheduler
● Both the OS and programs written in Mesa, natural to design language to contain concurrency support
● Two approaches○ Shared Memory ○ Message passing
Introduction
![Page 7: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/7.jpg)
● Built at Xerox PARC in late 1970s● Problem they are trying to solve: Concurrency between lightweight
processes (threads today)○ Multiple processes running in a time sliced fashion in Pilot ○ Want to support a preemptive scheduler
● Both the OS and programs written in Mesa, natural to design language to contain concurrency support
● Two approaches○ Shared Memory - why?○ Message passing
Introduction
![Page 8: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/8.jpg)
● Structure that contains a lock, data, and code○ Similar to a class in Java
Monitors
![Page 9: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/9.jpg)
● Structure that contains a lock, data, and code○ Similar to a class in Java
● Synchronize processes
Monitors
![Page 10: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/10.jpg)
● Structure that contains a lock, data, and code○ Similar to a class in Java
● Synchronize processes● All of the data is private
Monitors
![Page 11: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/11.jpg)
● Structure that contains a lock, data, and code○ Similar to a class in Java
● Synchronize processes● All of the data is private● Three types of procedures:
○ Entry (monitor, public)○ Internal (monitor, private)
Monitors
![Page 12: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/12.jpg)
● Structure that contains a lock, data, and code○ Similar to a class in Java
● Synchronize processes● All of the data is private● Three types of procedures:
○ Entry (monitor, public)○ Internal (monitor, private)○ External (non-monitor, public)
Monitors
![Page 13: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/13.jpg)
● Queues that keep track of processes waiting for a condition to become true
Condition Variables
![Page 14: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/14.jpg)
● Queues that keep track of processes waiting for a condition to become true
● To enter the queue, processes call wait()
Condition Variables
![Page 15: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/15.jpg)
● Queues that keep track of processes waiting for a condition to become true
● To enter the queue, processes call wait()● Processes leave the queue when some other process calls notify() on the
CV
Condition Variables
![Page 16: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/16.jpg)
● Queues that keep track of processes waiting for a condition to become true
● To enter the queue, processes call wait()● Processes leave the queue when some other process calls notify() on the
CV● Each CV is associated with a timeout
Condition Variables
![Page 17: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/17.jpg)
● Queues that keep track of processes waiting for a condition to become true
● To enter the queue, processes call wait()● Processes leave the queue when some other process calls notify() on the
CV● Each CV is associated with a timeout● Note:
○ Condition variables do not have any mechanism to verify if the condition is true/false. That is the responsibility of the programmer.
Condition Variables
![Page 18: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/18.jpg)
Code Snippet
![Page 19: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/19.jpg)
Code Snippet
![Page 20: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/20.jpg)
Code Snippet
![Page 21: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/21.jpg)
Code Snippet
![Page 22: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/22.jpg)
Code Snippet
![Page 23: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/23.jpg)
Code Snippet
![Page 24: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/24.jpg)
Code Snippet
![Page 25: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/25.jpg)
Code Snippet
![Page 26: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/26.jpg)
Code Snippet - Question
![Page 27: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/27.jpg)
Code Snippet - Answer
![Page 28: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/28.jpg)
● TIMEOUT○ Do processes that hit TIMEOUT throw an exception?○
● ABORT ○ Do processes need to listen to an ABORT?○
● BROADCAST○ Can you replace a NOTIFY with a BROADCAST?
Alternatives to NOTIFY
Calls made to the Conditional Variable:● wait()● notify()
● abort()● broadcast()
![Page 29: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/29.jpg)
● TIMEOUT○ Condition variables associated with some timeout variable t○ Does not throw exception
Alternatives to NOTIFY
![Page 30: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/30.jpg)
● TIMEOUT○ Condition variables associated with some timeout variable t○ Does not throw exception
● ABORT○ When process resumes, throws Aborted exception○ Aborted process does not have to listen
Alternatives to NOTIFY
![Page 31: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/31.jpg)
● TIMEOUT○ Condition variables associated with some timeout variable t○ Does not throw exception
● ABORT○ When process resumes, throws Aborted exception○ Aborted process does not have to listen
● BROADCAST○ All processes waiting in a condition variable’s queue wakes up○ Can always use a BROADCAST where NOTIFY is used
Alternatives to NOTIFY
![Page 32: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/32.jpg)
Bug in Code Snippet
![Page 33: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/33.jpg)
Bug in Code Snippet
![Page 34: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/34.jpg)
● A Mesa process can be thought of as a modern-day thread
Processes
![Page 35: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/35.jpg)
● A Mesa process can be thought of as a modern-day thread ● Represented by a 10-byte descriptor called ProcessState and a frame
○ Frame can be thought of as a stack frame, which keeps track of the procedures that a given process calls
Processes
![Page 36: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/36.jpg)
● A Mesa process can be thought of as a modern-day thread ● Represented by a 10-byte descriptor called ProcessState and a frame
○ Frame can be thought of as a stack frame, which keeps track of the procedures that a given process calls
● Created using the Process module○ Fork○ Join○ End○ Detach○ Abort ○ Yield
Processes
![Page 37: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/37.jpg)
● At a given time, a process can be in only one of the following queues:○ Ready Queue○ Monitor lock Queue○ Condition Variable Queue○ Fault Queue
Processes
![Page 38: Processes and Monitors in Mesa Experience with](https://reader033.vdocuments.mx/reader033/viewer/2022051102/6276df6ac4d42b243562d23c/html5/thumbnails/38.jpg)
● Difference between how Hoare and Mesa monitors handle waking up after a NOTIFY?
○ What can you assume about the monitor’s state after waking up?○ How does it change the use of while vs if
● What are the different ways to deadlock in Mesa?● How can implementing monitors defeat priority queues?● What is the exception handling mechanism in Mesa?
○ How does it interact with Monitors?
● What are the correctness/performance benefits of providing concurrency models at different layers of the system?
Discussion Questions