written 8.6 years ago by | modified 8.6 years ago by |
Inter-process communication (IPC) is the activity of sharing data across multiple and commonly specialized processes using communication protocols.
Typically, applications using IPC are categorized as clients and servers, where the client requests data and the server responds to client requests.
Many applications are both clients and servers, as commonly seen in distributed computing.
Methods for achieving IPC are divided into categories which vary based on software requirements, such as performance and modularity requirements, and system circumstances, such as network bandwidth and latency.
There are several reasons for implementing inter-process communication systems:
1. Sharing information; for example, web servers use IPC to share web documents and media with users through a web browser.
2. Distributing labor across systems; for example, Wikipedia uses multiple servers that communicate with one another using IPC to process user requests.
3. Privilege separation; for example, HMI software systems are separated into layers based on privileges to minimize the risk of attacks. These layers communicate with one another using encrypted IPC.
Shared Memory:
In computer programming, shared memory is a method by which program processes can exchange data more quickly than by reading and writing using the regular operating system services.
For example, a client process may have data to pass to a server process that the server process is to modify and return to the client.
Ordinarily, this would require the client writing to an output file (using the buffers of the operating system) and the server then reading that file as input from the buffers to its own work space.
Using a designated area of shared memory, the data can be made directly accessible to both processes without having to use the system services.
To put the data in shared memory, the client gets access to shared memory after checking a semaphore value, writes the data, and then resets the semaphore to signal to the server (which periodically checks shared memory for possible input) that data is waiting.
In turn, the server process writes data back to the shared memory area, using the semaphore to indicate that data is ready to be read.
Message Passing:
Message passing sends a message to a process and relies on the process and the supporting infrastructure to select and invoke the actual code to run.
Message passing differs from conventional programming where a process, subroutine, or function is directly invoked by name.
Message passing is key to some models of concurrency and object-oriented programming.
Message passing is used ubiquitously in modern computer software. It is used as a way for the objects that make up a program to work with each other and as a way for objects and systems running on different computers to interact.
Message passing may be implemented by various mechanisms, including channels.
Message passing is a technique for invoking behavior on a computer.
In contrast to the traditional technique of calling a program by name, message passing uses an object model to distinguish the general function from the specific implementations.
The invoking program sends a message and relies on the object to select and execute the appropriate code.
The justifications for using an intermediate layer essentially falls into two categories: encapsulation and distribution.
Encapsulation is the idea that software objects should be able to invoke services on other objects without knowing or caring about how those services are implemented.
Encapsulation can reduce the amount of coding logic and make systems more maintainable.
Distributed message passing provides developers with a layer of the architecture that provides common services to build systems made up of sub-systems that run on disparate computers in different locations and at different times.
Synchronous Messag Passing Asynchronous Message Passing Synchronous message passing occurs between objects that are running at the same time. Asynchronous message passing it is possible for the receiving object to be busy or not running when the requesting object sends the message. Synchronous message passing is what typical object-oriented programming languages such as Java and Smalltalk use Asynchronous message passing requires additional capabilities for storing and retransmitting data for systems that may not run concurrently.