PDF4PRO ⚡AMP

Modern search engine that looking for books and documents around the web

Example: stock market

Chapter 6: Process Synchronization

Back to document page

1Chapter 6: Process SynchronizationChapter 6: Process , Galvin and Gagne 2005Operating System ConceptsModule 6: Process SynchronizationModule 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization Monitors Synchronization Examples Atomic , Galvin and Gagne 2005Operating System ConceptsBackgroundBackground Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure the orderly execution of cooperating processes Suppose that we wanted to provide a solution to the consumer-producer problem that fills all the buffers. We can do so by having an integer countthat keeps track of the number of full buffers. Initially, count is set to 0. It isincremented by the producer after it produces a new buffer and is decremented by the consumer after it consumes a , Galvin and Gagne 2005Operating System ConceptsBoundedBounded--Buffer Buffer Producer &Consumer Producer &Consumer ProcessesProcessesProduceritem nextProduced;while (1) {while (((in + 1) % BUFFER_SIZE) == out); /* do nothing */buffer[in] = nextProduced;in = (in + 1) % BUFFER_SIZE;}Consumeritem nextConsumed;while (1) {while (in == out); /* do nothing */nextConsumed = buffer[out];out = (out + 1) % BUFFER_SIZE;}.

4 Operating System Concepts 6.9 Silberschatz, Galvin and Gagne ©2005 Peterson’s Solution Two process solution Assume that the LOAD and STORE instructions are atomic; that is, cannot be interrupted. The two processes share two variables: zint turn; zBoolean flag[2] The variable turn indicates whose turn it is to enter the critical section. The flag array is used to indicate if a process is ...

  Process, Synchronization, Process synchronization

Download Chapter 6: Process Synchronization


Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Spam in document Broken preview Other abuse

Related search queries