Cooperating Processes in Operating System
Cooperating Processes in Operating System
There may be several processes running in the system at the same time which
can be either cooperating processes or independent processes.
There are two types of software first is the application software and the other
is the system software.
1. Serial mode
2. Parallel mode
In serial mode, the process will be executed one after the other means the next
process cannot be executed until the previous process gets terminated.
Cooperation by Sharing
Cooperation by Message Passing
Cooperation by Sharing
The cooperation processes in OS can communicate with each other using the
shared resource which includes data, memory, variables, files, etc.
Processes can then exchange the information by reading or writing data to the
shared region. We can use a critical section that provides data integrity and
avoids data inconsistency.
The cooperating processes in OS can communicate with each other with the
help of message passing. The production process will send the message and the
consumer process will receive the same message.
There is no concept of shared memory instead the producer process will first
send the message to the kernel and then the kernel sends that message to the
consumer process.
A kernel is known as the heart and core of an operating system. The kernel
interacts with the hardware to execute the processes given by the user space. It
works as a bridge between the user space and hardware. Functions of the kernel
include process management, file management, memory management,
and I/O management.
In the above diagram, the processes A and B are communicating with each
other. Process A first sends the message to the kernel and then the kernel will
interpret that this message is meant for Process B.
The kernel then sends the message to the process P2 and that's how the process
of communication takes place between the cooperation processes by
communication.
Need of Cooperating Processes in OS
One process will write to the file and the other process reads the file. Therefore,
every process in the system could be affected by the other process.
The need for cooperating processes in OS can be divided into four types:
1. Information Sharing
2. Computation Speed
3. Convenience
4. Modularity
Information Sharing
Computation Speed
When a task is divided into several subtasks and starts executing them
parallelly, this improves the computation speed of the execution and makes
it faster. Computation speed can be achieved if a system has multiple
CPUs and input/output devices.
When the tasks are assigned into several subtasks they become several different
processes that need to communicate with each other. That's why we need
cooperating processes in the operating system.
Convenience
A user may be performing several tasks at the same time which leads to the
running of different processes concurrently. These processes need to cooperate
so that every process can run smoothly without interrupting each other.
Modularity
We want to divide a system of complex tasks into several different modules and
later they will be established together to achieve a goal. This will help in
completing tasks with more efficiency as well as speed.
Advantages of Cooperating Process in Operating System
Let's discuss several advantages of cooperating processes in the operating
system:
With help of data and information sharing, the processes can be executed
with much faster speed and efficiency as processes can access the same
files concurrently.
Modularity gives the advantage of breaking a complex task into several
modules which are later put together to achieve the goal of faster
execution of processes.
Cooperating processes provide convenience as different processes
running at the same time can cooperate without any interruption among
them.
The computation speed of the processes increases by dividing processes
into different subprocesses and executing them parallelly at the same
time.