Page 1 :
Process Synchronization, A situation where several processes access and manipulate the same data, concurrently and the outcome of the execution depends on the particular order in, which the access takes place, is called a race condition., Producer-Consumer Problem, Paradigm for cooperating processes, producer process produces, information that is consumed by a, consumer process., To allow producer and consumer processes to run concurrently, we must, have available a buffer of items that can be filled by the producer and emptied by, the consumer. A producer can produce one item while the consumer is consuming, another item. The producer and consumer must be synchronized, so that the, consumer does not try to consume an item that has not yet been produced. In this, situation, the consumer must wait until an item is produced., ✦ unbounded-buffer places no practical limit on the size of the buffer., ✦ bounded-buffer assumes that there is a fixed buffer size., , On the basis of synchronization, processes are categorized as one of the, following two types:, , , Independent Process : Execution of one process does not affects the, execution of other processes., Cooperative Process : Execution of one process affects the execution of, other processes., Process synchronization problem arises in the case of Cooperative process, also because resources are shared in Cooperative processes.
Page 2 :
Race Condition, When more than one processes are executing the same code or accessing the, same memory or any shared variable in that condition there is a possibility that, the output or the value of the shared variable is wrong so for that all the, processes doing the race to say that my output is correct this condition known, as a race condition. Several processes access and process the manipulations, over the same data concurrently, then the outcome depends on the particular, order in which the access takes place., A race condition is a situation that may occur inside a critical section. This, happens when the result of multiple thread execution in the critical section, differs according to the order in which the threads execute., Race conditions in critical sections can be avoided if the critical section is, treated as an atomic instruction. Also, proper thread synchronization using, locks or atomic variables can prevent race conditions., Sections of a Program, Here, are four essential elements of the critical section:, Entry Section: It is part of the process which decides the entry of a particular, process., Critical Section: This part allows one process to enter and modify the shared, variable., Exit Section: Exit section allows the other process that are waiting in the Entry, Section, to enter into the Critical Sections. It also checks that a process that, finished its execution should be removed through this Section., Remainder Section: All other parts of the Code, which is not in Critical, Entry,, and Exit Section, are known as the Remainder Section, Rules for Critical Section, , The critical section need to must enforce all three rules:, , , , , , , Mutual Exclusion: Mutual Exclusion is a special type of binary, semaphore which is used for controlling access to the shared resource. It, includes a priority inheritance mechanism to avoid extended priority, inversion problems. Not more than one process can execute in its critical, section at one time., Progress: This solution is used when no one is in the critical section, and, someone wants in. Then those processes not in their reminder section, should decide who should go in, in a finite time., Bound Waiting: When a process makes a request for getting into critical, section, there is a specific limit about number of processes can get into
Page 3 :
their critical section. So, when the limit is reached, the system must allow, request to the process to get into its critical section.