- Back to Home »
- Cooperating Processes in Operating System: Definition and Explanation
Cooperating Processes in Operating System:
Definition and Explanation:
There are two kinds of processes: cooperating and independent processes. A process is independent if it cannot affect or be affected by other processes. A process is said to be a cooperating process if it can affect or be affected by other processes in the system. A process that shares data with other processes is cooperating and a process that does not share data is independent.
Advantages of Cooperating Processes:
There are some advantages of cooperating processes:
information Sharing: Several users may which to share the same information e.g. a shared file. The O/S needs to provide a way of allowing concurrent access.
Computation Speedup: Some problems can be solved quicker by sub-dividing it into smaller tasks that can be executed in parallel on several processors.
Modularity: The solution of a problem is structured into parts with well-defined interfaces, and where the parts run in parallel.
Convenience: A user may be running multiple processes to achieve a single goal, or where a utility may invoke multiple components, which interconnect via a pipe structure that attaches the stdout of one stage to stdin of the next etc.
If we allow processes to execute concurrently and share data, then we must either provide some mechanisms to handle conflicts e.g. writing and reading the same piece of data. We must also be prepared to handle inconsistent or corrupted data.
Example:
Below is a very simple example of two cooperating processes. The problem is called the Producer Consumer problem and it uses two processes, the producer and the consumer.
Producer Process: It produces information that will be consumed by the consumer.
Consumer Process: It consumes information produced by the producer.
Both processes run concurrently. If the consumer has nothing to consume, it waits.
There are two versions of the producer. In version one, the producer can produce an infinite amount of items. This is called the Unbounded Buffer Producer Consumer Problem. In the other version, there is a fixed limit to the buffer size. When the buffer is full, the producer must wait until there is some space in the buffer before it can produce a new item.
Bounded Buffer - Shared Memory Solution:
Here is a shared memory solution for Bounded Buffer Producer Consumer problem. Both processes have some shared data that can be accessed and updated. The shared data is as follows:
// Shared data:
int n = 5, item, in, out;
// number of items in buffer is at most 5
int buffer[n];
// both the consumer and producer are currently looking at buffer element 0.
in = 0;
out = 0;
// Producer Process .
while (true)
{
while (in+1 % n == out)
{
// Do nothing
}
// produce a random item buffer[in] = nextProduction; in = in + 1 % n;
}
/ / Consumer process
while (true)
{
while (in = = out)
{
//Do nothing
. }
nextConsumed = buffer [out];
out = out + 1 % n;
}
The producer basically just checks to see if there is any space in which to put a newly produced item (outer while loop). If there is no space, then it waits, until there is some space. The consumer waits while the buffer is empty. If there is something/ it grabs the next item and consumes it. One drawback with this solution is that there is one element of the buffer that is wasted.
nice explaination...
ReplyDeleteEasy to understand and well explained ..............................
ReplyDeleteEasy to understand and well explained ..............................
ReplyDelete1) Restricting the child process to a subset of the parent’s resources prevents any process from :
ReplyDeletea) overloading the system by using a lot of secondary storage
b) under-loading the system by very less CPU utilization
c) overloading the system by creating a lot of sub-processes
d) crashing the system by utilizing multiple resources
View Answer
Answer: c
Explanation: None.
can any body explain?????
thank you sir
ReplyDeletethank you sir
ReplyDeletehummmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm great
ReplyDeleteThnak you so much sir
ReplyDeleteThnak you so much sir
ReplyDeletewow. simply awesome. easy to understand.
ReplyDeleteHelpful
ReplyDeleteCooperating Processes In Operating System: Definition And Explanation >>>>> Download Now
ReplyDelete>>>>> Download Full
Cooperating Processes In Operating System: Definition And Explanation >>>>> Download LINK
>>>>> Download Now
Cooperating Processes In Operating System: Definition And Explanation >>>>> Download Full
>>>>> Download LINK Ml