Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


  1. 1. Presentation Summary of “Experiences with Processes and Monitors in Mesa” By Burke Ellett
  2. 2. What I will cover today … <ul><li>Mesa programming language and design decisions when adding concurrency. </li></ul><ul><li>Difference between Hoare’s monitors and Mesa monitors. </li></ul><ul><li>Issues that caused problems during the development of Pilot and other large processes </li></ul><ul><li>Benefits and drawbacks to having concurrency implemented inside of a language construct </li></ul>
  3. 3. What is Mesa? <ul><li>Mesa is a strongly-typed high-level programming language, a component of the Xerox Development Environment . [1] </li></ul><ul><li>It was developed at Xerox PARC in the 1970's [1] </li></ul><ul><li>It was used to develop systems software for the first personal computers and spurred the development of the Lisa and Macintosh computers, whose user interfaces in turn prompted the development of Microsoft Windows. [1] </li></ul><ul><li>Oldest relative of Java </li></ul>
  4. 4. Motivation for adding concurrency to Mesa <ul><li>The creation of Pilot which was the first operating system developed for personal computers that would allow for multiple processes to run concurrently where each shared a time slice of CPU. Created using concurrent programming as opposed to event based programming. </li></ul><ul><li>Add concurrent programming to Mesa so that side by side development of Pilot could take place. </li></ul>
  5. 5. Choices for handling concurrency in a language <ul><li>Voluntary yields was an option that was rejected </li></ul><ul><ul><li>Only good for single processor </li></ul></ul><ul><ul><li>Must respond to time critical events so preemption needed anyways </li></ul></ul><ul><ul><li>Restricts programming generality, you need to know if a procedure you call will yield the processor </li></ul></ul><ul><ul><li>Page faults would cause involuntary yields at arbitrary points in a program </li></ul></ul><ul><li>Message passing was an option that was rejected because it was proven to be equivalent to monitors when some mild restrictions are applied </li></ul><ul><li>Monitors was the final choice because it was equivalent to message passing and worked better with the procedural scheme of Mesa, they choose Hoare’s paper as a starting place for thinking about concurrency in their language. </li></ul>
  6. 6. Issues about adding concurrency to Mesa so that Pilot could be developed <ul><li>Program structure </li></ul><ul><li>Creating processes </li></ul><ul><li>Creating monitors </li></ul><ul><li>Wait in a nested monitor call </li></ul><ul><li>Handling exceptions </li></ul><ul><li>Priority scheduling </li></ul><ul><li>Communication with devices (like I/O) </li></ul>
  7. 7. Creation of a process in Mesa <ul><li>Any non-internal monitor procedure can create a new process by the use of a new key word called FORK that is placed in front of the procedure call </li></ul><ul><li>This FORK procedure call will allow the current process to work concurrently with the new process created. It also returns a reference to the process just created so that the parent process can later joined an a result is returned or to detach from it. Different then Hoare thread that must suspend working until to the thread just created exits or yields. </li></ul><ul><ul><ul><ul><li>P ←FORK ReadLine[Terminal]; </li></ul></ul></ul></ul><ul><ul><ul><ul><li>… <concurrent computation> </li></ul></ul></ul></ul><ul><ul><ul><ul><li>buffer ← JOIN p; </li></ul></ul></ul></ul><ul><li>Every thread can be joined at a later time unlike PThreads where you need to specify at time of creation. Extra overhead in Mesa thread even though in practice most Mesa programmers will immediately detach the thread. </li></ul>
  8. 8. Reasons for this syntax for creating processes <ul><li>Made a process a first class value </li></ul><ul><li>Method of passing and retrieving values to a new process the same as a normal procedure </li></ul><ul><li>No special declaration needed for procedures that can be invoked as separate processes, similar to PThreads </li></ul><ul><li>Low cost of creating and destroying processes allowed for number of processes to vary widely at any time </li></ul><ul><li>Start the new process working at the beginning of any procedure </li></ul>
  9. 9. Creating monitors <ul><li>A Mesa module (Similar to a class) contains shared data and procedures to act on the data as well external procedures that do not modify the data (Diff. than Hoare that has no external procedures) </li></ul><ul><li>A module can be declared a monitor module which contains three type of procedures </li></ul><ul><ul><li>Entry (Monitor required procedures called externally) </li></ul></ul><ul><ul><li>Internal (Private procedures may be called by entry procedure) </li></ul></ul><ul><ul><li>External (Non-monitor procedures) </li></ul></ul><ul><li>A lock must be obtained by a process that calls an entry procedure and is released when the entry procedure exits. The lock is implicit and the runtime environment handles management of this. Therefore a Mesa monitor is an instance of a module. </li></ul><ul><li>No explicit creation of a locks unlike in PThreads. </li></ul>
  10. 10. Problems with this implementation <ul><li>Upon entering a Entry procedure you might find you need to wait (Like consumer/producer problem) </li></ul><ul><li>Exception thrown by this procedure or a sub-procedure who releases the lock </li></ul><ul><li>Recursive entry procedures </li></ul><ul><li>Calling an Entry procedure of another monitor-module from inside a monitored procedure </li></ul>
  11. 11. Adding the WAIT key word <ul><li>WHILE NOT <OK to proceed> DO WAIT c ENDLOOP. (Mesa and PThreads) </li></ul><ul><li>-versus- </li></ul><ul><li>IF NOT <OK to proceed> THEN WAIT c. (Hoare) </li></ul>
  12. 12. NOTIFY key word <ul><li>When one process establishes a condition for which some other process may be waiting it notifies the corresponding condition variable </li></ul><ul><li>It is like a hint to a single waiting process to resume at some convenient time, not a guarantee that the condition waiting on will be true (Different the Hoare) </li></ul><ul><li>Alternatives to NOTIFY are TIMEOUT, ABORT, BROADCAST </li></ul>
  13. 13. Hoare Semantics for condition variable wakeup [4]
  14. 14. Mesa Semantics for conditional variable wakeup [4]
  15. 15. Implementation of processes and monitors <ul><li>Split between compiler, runtime package, underlying machine </li></ul><ul><li>A process is represented by stack of procedure activation records (frames) plus a small description called a process state </li></ul><ul><ul><li>Frames are stored on the heap and a frame handler is invoked if a fault occurs </li></ul></ul><ul><ul><li>Process state is stored in fixed table which consists of four types of queues </li></ul></ul><ul><ul><ul><li>Ready queue </li></ul></ul></ul><ul><ul><ul><li>Monitor lock queue </li></ul></ul></ul><ul><ul><ul><li>Condition variable queue </li></ul></ul></ul><ul><ul><ul><li>Fault queue </li></ul></ul></ul>
  16. 16. The queues <ul><li>Queue cells point to the tail process state in a circular link list of process states </li></ul><ul><li>The queue is priority sorted and within each priority group a FIFO algorithm is used to decide the next running process </li></ul><ul><li>A process not held in the ready queue could be passed to the processor through software instructions or a trap vector center in the case of a page fault </li></ul><ul><li>The Process module of the Mesa runtime package handles all of this including notification of processes waiting on a time interval </li></ul>
  17. 17. Priority Scheduling can Cause Blocking <ul><li>The paper example of possible blocking caused by priority scheduling (same as last week) </li></ul><ul><li>P1, P2, and P3 are processes with priority same as subscript, with monitor M. </li></ul><ul><li>1. P1 enters M </li></ul><ul><li>2. P1 is preempted by P2 </li></ul><ul><li>3. P2 is preempted by P3 </li></ul><ul><li>4. P3 tries to enter monitor and waits for lock </li></ul><ul><li>5. P2 runs again and effectively prevents P3 from running contrary to priorities </li></ul><ul><li>Mesa uses priority scheduling but assigns each monitor the priority of the highest priority process which ever enters that monitor to ensure the CPU priority scheduling discipline imposed by some application, thus preventing blocking in example above. </li></ul>
  18. 18. Handle I/O interrupts for condition variables <ul><li>Since I/O device does not wait on a monitor it notifies the condition handler when it needs attention. This is called a “Naked Notify” and can lead to a race conditions </li></ul><ul><ul><li>If a process inside the “while not <condition> do wait” loop and has checked the condition and is preparing to wait at the same time the interrupt occurs then the notify could become lost and the process may not wake again. </li></ul></ul><ul><ul><li>Fixed with wakeup-waiting switch in condition variable (binary semaphore) </li></ul></ul>
  19. 19. Compiler changes <ul><li>New key words </li></ul><ul><li>More static checking to find frequent errors like the use of wait in an external procedure (external procedures have no knowledge of locks that are held) </li></ul>
  20. 20. Performance issues <ul><li>The only major performance issue was the FORK-JOIN construct which resulted in over 10 times the amount of time ticks as any other construct or the same time as 1100 simple instructions </li></ul><ul><li>The cause was the implementation of this in software, but since it is not in popular use they left it there </li></ul>
  21. 21. Problems encountered with Mesa implementation of concurrency <ul><li>The lack of mutual exclusion in handling of interrupts (Bugs caused in timing races between I/O and handlers </li></ul><ul><li>The interaction of concurrency and exception handling makes programming hard </li></ul>
  22. 22. Implement concurrency in language or not <ul><li>Main advantages is the programmer has direct guidelines for the syntax and behavior of the threads, the program should work the same from computer platform to computer platform so more portable, far easier to use a standard package </li></ul><ul><li>Main disadvantages are that the programmer loses the ability to take advantage of hardware, by having built in concurrency you lose flexibility of interleaving different libraries that handle concurrency favorable to your particular problem </li></ul>
  23. 23. Contributions to community <ul><li>Though neither Mesa or Pilot ever took off it was the launching point of both the modern personal computer and the ideas behind the use of virtual machines like Java </li></ul><ul><li>Tied up many loose ends in concurrent programming and got them implemented into one package </li></ul><ul><li>Helped define basic implementations of a modern OS </li></ul>
  24. 24. References <ul><li>http://www.apearson.f2s.com/mesacourse10.html A website about the Mesa programming language, and its history. </li></ul><ul><li>“ Monitors: An Operating System Structuring Concept” by C.A.R Hoare,The Queen's University of Belfast </li></ul><ul><li>“ Pilot: An Operating System for a Personal Computer” by David D. Redell, Yogen K. Dalal, Thomas R. Horsley, Hugh C. Lauer, William C. Lynch,Paul R. McJones, Hal G. Murray, and Stephen C. Purcell, Xerox Business Systems </li></ul><ul><li>Duke University Systems and Architecture class slides </li></ul>