Inter Process Communication
Inter Process Communication (IPC) allows the programmer to coordinate different processes of a program which can run concurrently in the operating system. The feature of IPC handles many user requests for the program at the same time. IPC works using the signal and wait processes. This signal helps other processes to know whether they can start their functionality or not. Semaphores are being used to signal the processes. Semaphore is considered to be a protected variable which has two signals P (wait signal) and V (wakeup signal). With the help of these two operations the program processes can be altered and the variable takes the binary value 0 and 1. The wait operation on semaphore S is defined as P(S) and operates as:-
P(S): if S > 0
Then S = S-1
ELSE (wait on S)
The signal operation on semaphore S is defined as V(S) and operates as:-
V(S): if (one or more processes are waiting on S)
THEN (let one of the process proceed)
ELSE S = S+1.
The semaphores are being used in the producer consumer problem. The producer-consumer problem requires the synchronization between the two systems where they can share the single resource. The producer and consumer processes share the fixed size buffer so that the data can be shared between them. The producer process produces the information and put in the shared buffer while the consumer processes uses the information from the shared buffer and perform the actions accordingly. Both the processes access the shared buffer concurrently and this creates the problem of deadlock situation. The situation in these processes can arise that producer is producing even if the buffer is full and the consumer is consuming the data even if the buffer is fully empty.
The message passing method can be used as the solution for the producer-consumer problem. When the system is distributed system then the method of message passing is used rather than semaphores or monitors. In the message passing system two primitives are used:- SEND and RECEIVE. The primitive SEND is used to send a message to its particular destination process while the primitive RECEIVE receives the message from the specified source process. Mutual Exclusion can be implemented using message passing technique. There is one process and the buffer to handle mutual exclusion. The resource control process is used to store a variable which records the status of the records the status of the resource that whether the resource is free or busy with another process. The buffer stores all the request messages for the other processes.