Inter-process communication in Linux-general Linux technology-Linux programming and kernel information. The following is a detailed description. There are roughly the following types of inter-process communication in Linux:
1. socket
2. Pipelines (including anonymous pipelines for parent and child processes and named pipelines)
3. semaphores
4. Shared Memory
5. Message Queue
1. socket
Socket can be used for local process communication or remote communication, which is the most common.
2. MPS queue-Anonymous MPs queue
Generally, pipe is used for communication between parent and child nodes. Close the read/write pipeline in the parent process and the write/read pipeline in the child process.
2. MPS queue-named MPs queue
Generally, mkfifo is used for creation. If it does not indicate that the MPs queue is not blocked, a read-enabled MPs queue will be blocked until a process opens this FIFO for writing. Similarly, the pipeline opened for write will be blocked until a process opens this FIFO for read.
3. semaphores
A process can send signals to another process using kill.
4. Shared Memory
Usage functions: shmget, shmat, shmctl, and shmdt
Use the shmget function to obtain a piece of memory and use the shmat to allow the process to use this shared memory. Use shmdt to delete memory blocks.
5. Message Queue
Functions: msgget, msgsnd, msgrcv, and msgctl
The procedure is the same as above.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service