Linux interprocess communication (IPC) has several ways, which will be briefly described below:
one. Pipe
Pipeline is the initial IPC mode supported by Linux. Pipes can be divided into unnamed pipes, named pipes, and so on.
(1) Anonymous pipeline, which has several characteristics:
1) The pipeline is half-duplex and can only support one-way flow of data; it needs to be established when communication between two processes is required. Two pipes;
2) Nameless pipes are created using the pipe() function and can only be used between parent and child processes or between sibling processes;
3) Pipes for both ends of the communication In other words, it is essentially a separate file that exists only in memory;
4) Data read and write operations: A process writes data to the pipeline, and the data written is added to the end of the pipeline buffer. Another process reads data at the head of the buffer in the pipeline.
(2) Named Pipes
A named pipe is also half-duplex, but it allows communication between processes that are not related. Specifically, the well-known pipeline provides a path name associated with it, and exists in the file system in the form of FIFO (first in, first out). This allows even unrelated processes to communicate with each other through FIFOs as long as they have access to the paths already provided.
It is worth noting that it only makes sense to write data to the pipeline when the pipeline has a read end. Otherwise, the process that writes data to the pipe receives the SIGPIPE signal from the kernel; the application can customize the signal handler or ignore the signal directly.
Two. Semaphores
Semaphores are counters that control the simultaneous access of resources by multiple threads or processes across processes. It is often implemented as a lock mechanism. Essentially, the semaphore is a protected variable and can only be accessed through initialization and two standard atomic operations (P/V). (P, V operations are also often referred to as wait(s), signal(s))
three. Signals
Signals are one of the oldest methods of interprocess communication used in Unix systems. The operating system signals to a certain process that a predetermined event has occurred; the process that receives the signal can choose to process the signal in different ways. First, the default processing mechanism &mdash can be used; the process is interrupted or exited, and the process is ignored. The signal, as well as the processing function that customizes the signal, performs the corresponding action.
The kernel produces signals for processes to respond to different events, which are the source of the signal. The signal source can be: exception, other processes, terminal interrupt (Ctrl-C, Ctrl+\\, etc.), job control (front, background process management, etc.), allocation amount problem (cpu timeout or file too large, etc.), kernel Notifications (such as I/O Ready, etc.), alarms (timers).
Four. Message Queue
A message queue is a linked list of messages that allows one or more processes to write messages to it, and one or more processes read messages to it. Linux maintains a message queue vector table: msgque to represent all message queues in the system.
Message Queuing overcomes the lack of signaling information, and the pipeline can only support the disadvantages of unformatted byte streams and buffer limitations.
Five. Shared memory
Shared memory is mapped to a piece of memory that can be accessed by other processes. This shared memory is created by one process and then other processes can be mounted into this shared memory. Shared memory is the fastest IPC mechanism, but since Linux itself cannot implement synchronous control and requires user program for concurrent access control, it generally combines other communication mechanisms to achieve inter-process communication, such as semaphores.
Five. Sockets
Sockets are also an inter-process communication mechanism, but the main difference between it and other communication methods is that it can implement process communication between different hosts. A socket can be thought of as an endpoint for interprocess communication. The name of each socket is unique; other processes can access, connect, and communicate data.
Overview This article describes how to transfer files between a Linux host and a Windows host. Beca
got a long time (about 3 days), and finally got through. At first I wanted to give up but slowly beg
How to uninstall the built-in JDK under Linux, many of us can find java under the operating system
This article mainly introduces the DB2 database in the inux installation process detailed, the step
DirectAdmin enables HTTP/2 support
Linux installation and configuration SVN standalone server svnserve
Linux directory structure detailed
Memcacheq service installation and principle overview
Set the script to self-starting under Linux system
Using a Linux cluster to charge a billing system
Php+apache+mysql+worpress+linux platform build
RHEL5.4 install nginx-1.0 + php-5.2.17 (fastcgi) + mysql-5.1.40
Win7/Win8.1 disables the "Program Compatibility Assistant" two methods
Win8 system to open RAR file method
How to set reminder for Win10 alarm clock application
Issues related to XP system virus protection enabled
Windows XP power-on password is set to
When prompted to start the vi editor in Linux, prompt E325: What should ATTENTION do?
Microsoft Cup Only 1/3 of developers are interested in WP system
How to use the win7 system word document calculator function?