6-on-1(3) - Lecture Notes 11 Concurrent Programming and...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 3/24/2008 CSci 4061 - Instructor: A. Tripathi 1 Lecture Notes 11 Concurrent Programming and Process Synchronization Anand Tripathi CSci 4061 Introduction to Operating Systems 3/24/2008 CSci 4061 - Instructor: A. Tripathi 2 Concurrent Programming Process/Thread Synchronization Problems Process Coordination and Synchronization Problems – Topics from Chapters 6 (up to and including Section 6.6) from the Silberschatz book (7 th Edition) 3/24/2008 CSci 4061 - Instructor: A. Tripathi 3 Topics from Chapters 6 Critical Section problem Mutual exclusion and atomic operations Mutual exclusion protocols Using Test-and-Set, or swap instructions Semaphores Abstraction and its implementation using test-and-set Classical problems in process coordination Bounded buffer problem Readers/Writers problem Dining Philosophers Problem 3/24/2008 CSci 4061 - Instructor: A. Tripathi 4 Inter-Process Communication through Shared Memory Process (thread) 1 Process (thread) 2 Process (thread) 3 Shared Memory read/write read/write read/write 3/24/2008 CSci 4061 - Instructor: A. Tripathi 5 Modification of Shared Data by Concurrent Processes PROCESS A PROCESS B I = I + 1 I = I + 1 A statement such as I = I + 1 is implemented by several machine level instructions such as; 1. Load I from memory into the CPU accumulator 2. Increment accumulator 3. Store accumulator's contents back into memory location of I. 3/24/2008 CSci 4061 - Instructor: A. Tripathi 6 Modification of Shared Data by Concurrent Processes Arbitrary interleaving of the execution of these 3 steps by A and B can happen as follows: A 1; A 2; B 1; B 2; A 3; B 3; If the initial value of I before the execution of A and B is 1; at the end of this sequence it would be 2, instead of 3.
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 3/24/2008 CSci 4061 - Instructor: A. Tripathi 7 Certain sequence of operations on shared data should be performed as an indivisible sequence. I.e. no interleaving with the execution of other processes accessing the same data E.g., I = I + 1 should be made INDIVISIBLE or ATOMIC In other words, when process A is executing I = I + 1 , no other process should be allowed to modify I concurrently. This leads to one important problem in concurrent programming => 3/24/2008 CSci 4061 - Instructor: A. Tripathi 8 Atomic Operation An atomic operation, once started executes completely as a logically indivisible action, without any interleaving with instructions of any other related operations. 3/24/2008 CSci 4061 - Instructor: A. Tripathi 9 Bounded Buffer Problem Consider the following bounded-buffer problems, where a produce process communicates with a consumer process (by sending some data items) through a bounded buffer. These processes may execute at any arbitrary speeds. The items deposited into the buffer by the producer should be received by the consumer in the same order.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern