Computer Science, asked by Reetinder4876, 10 months ago

A ipc mechanism that which executes on different systems and can communicate

Answers

Answered by Anonymous
0

Inter Process Communication

A process can be of two type:

Independent process.

Co-operating process.

An independent process is not affected by the execution of other processes while a co-operating process can be affected by other executing processes. Though one can think that those processes, which are running independently, will execute very efficiently but in practical, there are many situations when co-operative nature can be utilised for increasing computational speed, convenience and modularity. Inter process communication (IPC) is a mechanism which allows processes to communicate each other and synchronize their actions. The communication between these processes can be seen as a method of co-operation between them. Processes can communicate with each other using these two ways:

Shared Memory

Message passing

The Figure 1 below shows a basic structure of communication between processes via shared memory method and via message passing.

 

An operating system can implement both method of communication. First, we will discuss the shared memory method of communication and then message passing. Communication between processes using shared memory requires processes to share some variable and it completely depends on how programmer will implement it. One way of communication using shared memory can be imagined like this: Suppose process1 and process2 are executing simultaneously and they share some resources or use some information from other process, process1 generate information about certain computations or resources being used and keeps it as a record in shared memory. When process2 need to use the shared information, it will check in the record stored in shared memory and take note of the information generated by process1 and act accordingly. Processes can use shared memory for extracting information as a record from other process as well as for delivering any specific information to other process.  

Let’s discuss an example of communication between processes using shared memory method.

 struct item{  

 

       // diffrent member of the produced data  

       // or consumed data      

       ---------  

   }  

     

   // An array is needed for holding the items.  

   // This is the shared place which will be    

   // access by both process    

   // item shared_buff [ buff_max ];  

       

   // Two variables which will keep track of  

   // the indexes of the items produced by producer  

   // and consumer The free index points to  

   // the next free index. The full index points to  

   // the first full index.  

   int free_index = 0;  

   int full_index = 0;

Similar questions