1 / 20

COP 4600 Operating Systems Fall 2010

COP 4600 Operating Systems Fall 2010. Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:30-4:30 PM. Last time: Discussion of the solutions for the midterm Today: Presentation of the paper “Distributed object model of Java” Thread coordination with a bounded buffer. Semaphores

rance
Download Presentation

COP 4600 Operating Systems Fall 2010

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COP 4600 Operating Systems Fall 2010 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:30-4:30 PM

  2. Last time: Discussion of the solutions for the midterm Today: Presentation of the paper “Distributed object model of Java” Thread coordination with a bounded buffer. Semaphores Virtual memory Next time Presentation of the paper “Cooperating sequential processes” Virtual memory Lecture 21 – Tuesday November 2, 2010 Lecture 21

  3. Lecture 21

  4. Implicit assumptions for the correctness of the implementation • One sending and one receiving thread. Only one thread updates each shared variable. • Sender and receiver threads run on different processors to allow spin locks • in and out are implemented as integers large enough so that they do not overflow (e.g., 64 bit integers) • The shared memory used for the buffer provides read/write coherence • The memory provides before-or-after atomicity for the shared variables in and out • The result of executing a statement becomes visible to all threads in program order. No compiler optimization supported Lecture 21

  5. Lecture 21

  6. Lecture 21

  7. Lecture 6 Lecture 21 7

  8. Lecture 21

  9. Lecture 21

  10. This solution does not work Lecture 21 The NOTIFY should always be sent after the WAIT. If the sender and the receiver run on two different processor there could be a race condition for the notempty event. The NOTIFY could be sent before the WAIT. Tension between modularity and locks Several possible solutions: AWAIT/ADVANCE, semaphores, etc

  11. AWAIT - ADVANCE solution • A new state, WAITING and two before-or-after actions that take a RUNNING thread into the WAITING state and back to RUNNABLE state. • eventcount variables with an integer value shared between threads and the thread manager; they are like events but have a value. • A thread in the WAITING state waits for a particular value of the eventcount • AWAIT(eventcount,value) • If eventcount >value  the control is returned to the thread calling AWAIT and this thread will continue execution • If eventcount ≤value  the state of the thread calling AWAIT is changed to WAITING and the thread is suspended. • ADVANCE(eventcount) • increments the eventcount by one then • searches the thread_tablefor threads waiting for this eventcount • if it finds a thread and the eventcount exceeds the value the thread is waiting for then the state of the thread is changed to RUNNABLE Lecture 21

  12. Solution for a single sender and multiple receivers Lecture 21

  13. Supporting multiple senders: the sequencer Sequencer shared variable supporting thread sequence coordination -it allows threads to be ordered and is manipulated using two before-or-after actions. TICKET(sequencer)  returns a negative value which increases by one at each call. Two concurrent threads calling TICKET on the same sequencer will receive different values based upon the timing of the call, the one calling first will receive a smaller value. READ(sequencer)  returns the current value of the sequencer Lecture 21

  14. Multiple sender solution; only the SEND must be modified Lecture 21

  15. Implementation of AWAIT and ADVANCE Lecture 21

  16. Semaphores • Introduced by Dijkstra in 1965 • Does not require busy waiting • Semaphore S – integer variable • Two standard operations modify S: wait() and signal() • Originally called P() andV() • Less complicated • Can only be accessed via two indivisible (atomic) operations • wait (S) { while S <= 0 ; // no-op S--; } • signal (S) { S++; } Lecture 21

  17. Lecture 21

  18. Lecture 21

  19. Lecture 21

  20. Wait for graph Lecture 21

More Related