The communication mechanism of Linux

Source: Internet
Author: User

Communication is a more important concept. As long as there is more than one execution unit (concurrency), there is a possibility of communication.

Concurrency on Linux is mainly divided into multiple processes (tasks) and multithreading. Linux also provides multiple communication mechanisms to support the transfer of information between different processes or between different threads.

Communication methods mainly include pipeline, socket, message queue, shared memory, semaphore, mutex, signal (such as kill-0 detection process is normal) and so on.

Pipeline:

1. CGI technology. After the Deamon process receives a request, the child process is created to execute the CGI program, communicates with the child process through the nameless pipe, the parent process writes Fd[0], and the child process is responsible for writing fd[1]. The Deamon program then returns to the client by reading the output pipeline of the child process. (The limitation of communication is that processes must be related to each other)

2. Shell pipelines such as ps-ef |grep xxx

Sockets: Can be understood as the most common CS model. Multi-client and a server communication (such as Nginx use FCGI to execute PHP program, between FCGI and Nginx is through socket communication, nginx to 9000 port send request).

Message Queuing: Multiple processes can read and write message queues at the same time, often combining mutexes to achieve multi-threaded synchronization

Shared memory: The fastest means of communication, often combined with semaphores (the PV operation of the semaphore is guaranteed by the system kernel) to achieve multi-process synchronization

In communication, the more special is the parent-child process communication, because the child process inherits many things from the parent process, so in addition to the above mentioned means of communication, but also through the environment variable communication.

The communication mechanism of Linux

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.