Interprocess communication (IPC) is a group of programming interfaces which enable a software developer or programmer to coordinate different tasks and activities among different program operations which execute simultaneously in the operating system. IPC enables a program to handle many user requests at the same time. An user request results in execution of multiple processes in the operating system. The processes must communicate with one other to carry out their tasks. The interfaces of IPC aids in communication,data exchange among the different processes. There are advantages and disadvantages present in every method of IPC. A single program can use different methods of IPC. The different methods of IPC include shared memory, message queuing,sockets, pipes and semaphores among others(Rouse,2017).
The mechanism of IPC helps in organizing the multiple activities among the diverse processes. Data is easily shared between applications without any interference. The processes share information and memory using IPC. Messages are transferred effectively and efficiently accomplished between the processes. The IPC mechanism is built on Task Control Architecture (TCA). IPC transmits and receives data structures,variable length array and lists. It supports diverse operating systems and programming languages( Techopedia,2017).
IPC is the mechanism through which processes communicate among themselves. IPC is crucial for co-ordination among the processes. The different IPC mechanisms are dependent on the operating system kernel. The communication between processes p1 and p2 takes place through shared memory region. Process p1 writes the information in the memory area and process p2 reads the information form the same memory area.
The notion of shared memory is implemented using pipes,memory mapped objects(MMO) among others. Pipes are based on client-server architecture model. A pipe is created by a process,pipe server. Another process,pipe client connects to the pipe. A pipe conceptually consists of two ends and the flow of information through the pipe can be in single direction or in both directions. In a single directional pipe mechanism a process at one end writes data into the pipe. The process at the other end of pipe reads the data. Ia bi-directional pipe mechanism both the tasks of writing and reading the data can be accomplished at any end of the pipe(Shibu,2009).
MMO is a method used in some real time operating systems(RTOS) in which a block of memory is shared among different processes simultaneously. In this technique,a mapping object is generated and a physical storage space is allocated for it. This storage area is mapped by a process to a virtual address space(VAS). The process can then perform the operations of write and read on VAS. The operations are performed in the physical storage area. A MMO is used across different threads present in a process. The main or parent thread creates MMO and it is mapped to VAS. The parent thread then shares the pointer to MMO as a global pointer. The other threads of the process can use the global pointer to perform the operations of writing and reading to the MMO.
In message passing mechanism, a limited quantity of data is shared. This mechanism is not burdened with synchronization overheads and its operation is fast. It is classified into three categories,message queue,mailbox and signalling based on the mode of message passing between different processes. In message queue the message transmitted by a process is sent to first-in-first-out(FIFO) queue. It is stored for a limited time in a memory object and then delivered to the required process. The messages are transmitted using send and receive methods.
The implementation of send and receive methods,message queue depends on operating system kernel. Mail box method is used in RTOS for transfer of messages in a single direction. The thread/task which desires to transmit messages to other threads/tasks generates a mail box where the messages are posted. The threads which wish to receive the mail box messages subscribe to it. The mail box is created by a thread which is known as mailbox server(MBS). The mail box clients are those threads which have subscribed to receive the mail box messages. Messages are posted in the mail box by MBS. The clients receive notification from the MBS after the message is posted. Then the mail box messages are read by the clients. The application programming interface(API) calls of the kernel are associated with the creation of mail box,subscription,message writing and reading. Mail box can be used for message exchange between a task and interrupt service subroutine or among two tasks. The mail box comprises of a wait list and an associated pointer.
Signalling is an elementary method of transmitting information between threads/processes. Signals are utilized for the purpose of asynchronous alerts where the firing of a signal by a thread/process indicates the development of a situation to other threads/processes which are in wait state. No data is carried by the signals(Shibu,2009).
Remote process communication(RPC) is a IPC mechanism where a client process makes a request to invoke a procedure of a remote server process. The server process can run on a different processor or the same processor. Both client and server processes are interconnected on the network. Using RPC,communication is possible in a heterogeneous network where the applications associated with the server and client run on diverse operating systems. In synchronous RPC the client process which invokes the distant procedure stays blocked till the server process responds. In asynchronous RPC,the client process continues with its prior task implementation while the remote server process invokes the required procedure. The result of task performed by the server is transmitted to the client through the use of callback functions.
Authentication methods are used by RPC for protecting the systems from threats and vulnerabilities. The client process must authenticate itself to obtain access to the server. The different authentication mechanisms include public key cryptography techniques like DES,triple DES among others. If authentication is not used unauthorized and unsanctioned clients can easily obtain access to the remote procedure leading to security risks and results in compromise of systems,loss of data. RPC is implemented using sockets. In bi-directional communication between two processes or applications on a network, a socket is considered to be a logical end point. Every socket has a port number associated with it. This is used to transmit the required data to the target application by the network layer present in the communication channel. Different types of sockets include Internet sockets,Unix sockets among others. The different communication protocols used by Internet sockets include user datagram protocol(UDP),transmission control protocol(TCP)/Internet protocol(IP). The two categories of Internet sockets are datagrams and stream(Shibu,2009).
Stream sockets are connection oriented and use TCP for establishing dependable links. Datagram sockets use UDP for creating connections. Sockets are used at client side and server side in the communication model. Both sockets are assigned a distinctive port number and both client,server must be aware of the number. The communication is initiated by the client which transmits a connection request to the concerned host server at the defined port number. The server receives the request of client at the port number. On successful authentication of client,the connection request is granted to the client by the server through establishment of communication channel between them. The client makes use of host server name and port number to transmit requests. The server sends responses and uses port number,name of the client. Data communication between server and client takes place through Wi-Fi or Ethernet medium.
Socket implementation is dependent on kernel and diverse socket interfaces exist on different operating systems. Many processes execute synchronously in a typical multi tasking environment(MTE). The system resources are shared among the processes. In a specific situation,two processes try simultaneously to access the monitor display of the computer. In another situation process p3 attempts writing operation to a particular location in memory. At the same time another process p4 attempts reading operation form the same location in memory. In the above two scenarios there are conflicts between the processes regarding sharing of resources and this can result in unforeseen consequences. To avoid conflicts, process or task synchronization is absolutely necessary. Every process should be directly or indirectly informed regarding the access to a shared resource. In a MTE, many issues arise with reference to synchronization. The issues are racing,deadlock,starvation,live-lock,dining philosopher's problems,priority inversion and readers-writers problem among others.
Race condition is a situation where multiple processes compete with one another to access the shared data and operate it simultaneously. The ultimate value of shared data depends on the process which operated it. This condition generates inaccurate outcomes. A situation of deadlock generates a scenario where the processes are unable to progress with respect to execution of their tasks. A process p5 possess a resource y and needs a resource x which is held by process p6 and it needs resource y. Both p5 and p6 compete against each another to get other's resource and they hold their own resources. The result is deadlock. In this situation both the processes cannot access each other's resources. Deadlock results from coffman conditions which are circular wait,hold and wait,mutual exclusion and no resource preemption(Shibu,2009).
The data structures which synchronize access to non-sharable resource by processes are called semaphores. They are used by competing processes for determining whether a particular resource is accessible. If it is not available at that particular time then the process which requested the resource is placed by the system in a related queue. When the resource is available the process which requested the resource is informed by the system. Semaphores can be either counting or binary type. The binary semaphore has one of the two values 0 or 1. If the value is 0, it indicates that the resource is currently in use and hence unavailable to the requesting process. If the value is 1, it indicates the availability of the resource to the requesting process(IBM,n.d.).
In the counting semaphore, the count is initialized to the number of available resources. When more resources are available the count is atomically incremented by the threads. On removal of resources the count is atomically decremented. A zero semaphore count indicates non-availability of resources. The count can be incremented by the threads only when the value of count is more than zero. There are no attributes present in semaphores and they should be initialized before they are used(Oracle,2010).
The IPC mechanisms supported on Windows OS include Windows sockets, pipes clipboard,component object module(COM),data copy,Dynamic Data Exchange(DDE),file mapping,mail-slots,RPC. The clipboard shares data among different applications. An user performs the operation of copy or cut related to data in a word processing application and the same is available on clipboard in standard formats. The data can be retrieved from other applications. The applications which use the clipboard can be present on the same processor or on other processors in the network.
Component Object Model (COM) is the foundation for object linking and embedding(OLE). COM is used for communication between software components. Interaction by components is in the form of clients and objects and clients. Distributed COM works across the computer network.
Applications using OLE are capable of managing compound documents which comprise of data from diverse applications. A word processing software which uses OLE can incorporate a graphical object present in spreadsheet. The user can edit the graph by starting the spread sheet software from the word document using embedded chart. After the graph is edited and the the user exists from the spreadsheet application, the graph is updated in the word document.
Data copy is used by an application to quickly send information to a different application and Windows messaging is used for the purpose. This procedure needs collaboration between sending and receiving application. The sender should be identified by the receiving application and it should be aware of the information format.
The applications which use DDE protocol are able to exchange data in diverse formats. DDE is initiated by the command of a user and it performs functions with no need for further interaction on the part of user. Customized data formats for DDE can be defined for IPC between those applications which have stringent communications requirements. The applications which use DDE can be present on the same processor or on different processors in the network. An efficient method to share data between two processes present on the same processor is through file mapping and synchronization must be present between processes.
Pointer operations are performed by the processes for examination and alteration of the file contents. Semaphore is used for synchronization purposes by the processes for preventing corruption of data in a typical multitasking environment. File mapping cannot be used on a computer network. It can only be used on the local processor(Microsoft,2017).
References
IBM. (n.d.). The Interprocess Communication (IPC) Overview. Retrieved February 2, 2017, from http://www-01.ibm.com/support/docview.wss?uid=isg3T1000410
Microsoft. (2017). Interprocess Communication. Retrieved February 2, 2017, from https://msdn.microsoft.com/en-us/library/windows/desktop/aa365574%28v=vs.85%29.aspx
Oracle. (2010). Counting Semaphores. Retrieved February 2, 2017, from https://docs.oracle.com/cd/E19455-01/806-5257/sync-34/index.html
Rouse , M. (2017). Interprocess communication (IPC) . Retrieved February 1, 2017, from http://whatis.techtarget.com/definition/interprocess-communication-IPC
Shibu, K. (2009). Introduction to Embedded Systems (1st ed.). McGraw Hill Education.
Techopedia. (2017). Inter Process Communication (IPC). Retrieved February 1, 2017, from https://www.techopedia.com/definition/3818/inter-process-communication-ipc