1 / 10

CS 423 – Operating Systems Design Lecture 12 – Monitors and Barriers

CS 423 – Operating Systems Design Lecture 12 – Monitors and Barriers. Roy Campbell Spring 2008. Administration. Tanenbaum Chapter 2, 3 MP2 Understanding the LINUX Kernel, Ch 11, 8, 9, 16 Look at http://lxr.linux.no/. Monitors (1). Figure 2-33. A monitor. Monitors (2).

paley
Download Presentation

CS 423 – Operating Systems Design Lecture 12 – Monitors and Barriers

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. CS 423 – Operating Systems DesignLecture 12 – Monitors and Barriers Roy Campbell Spring 2008 CS 423 – Spring 2008

  2. Administration Tanenbaum Chapter 2, 3 MP2 Understanding the LINUX Kernel, Ch 11, 8, 9, 16 Look at http://lxr.linux.no/

  3. Monitors (1) Figure 2-33. A monitor. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

  4. Monitors (2) Figure 2-34. An outline of the producer-consumer problem with monitors. Only one monitor procedure at a time is active. The buffer has N slots. Note similarity to Pthreads conditional wait.

  5. Monitors (3) Figure 2-34. An outline of the producer-consumer problem with monitors. Only one monitor procedure at a time is active. The buffer has N slots. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

  6. Barriers Two uses of term barriers: Linux – compiler barrier Multiprocessing – synchronization primitive. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

  7. Compiler Barriers rmb() no loads are reordered across call wmb() no stores are reordered across call mb() no loads or stores are reordered across call barrier() prevents the compiler from optimizing stores or loads across the barrier Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

  8. Compiler Barriers Thread 1 Thread 2 - - c = b; rmb(); d = a; a = 3; mb(); b = 4; - - Without using the memory barrier, c could get the new value of b while d gets the old value of a Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

  9. Synchronization Barriers Figure 2-37. Use of a barrier. (a) Processes approaching a barrier. (b) All processes but one blocked at the barrier. (c) When the last process arrives at the barrier, all of them are let through. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

  10. Possible Synchronization Barrier Implementation spin_lock(barriercount); increment(count); spin_unlock(barriercount); if (count == all_processes) then {count = 0; for (k=0; k<=all_processes; K++) spin_unlock(barrierlock[k]; }; else spin_lock(barrierlock[mine]); Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

More Related