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

Info iconThis 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.
Background image of page 1

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

View Full DocumentRight 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
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/18/2008 for the course CSCI 4061 taught by Professor Tripathi during the Spring '08 term at Minnesota.

Page1 / 8

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

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online