Linux interprocess communication: Pipelines, semaphores, message queues, signals, shared memory, sockets

Source: Internet
Author: User
Tags message queue semaphore

The process communication methods under Linux are basically inherited from the process communication methods on the UNIX platform. And the two main at& that make a major contribution to the development of UnixT's Bell Labs and BSD (UC Berkeley's Berkeley Software Release Center) have a different focus on inter-process communication. The former is a systematic improvement and expansion of early UNIX inter-process communication means, which forms "system V IPC", whose communication process is confined to a single computer, while the latter skips the limit and forms an inter-process communication mechanism based on socket. And Linux has inherited the advantages of both the Linux interprocess communication (IPC) There are several ways, the following will be a brief description: # pipe: Pipe is a half-duplex communication, the data can only flow in one direction, and can only be used in the relationship between the processes. A process's affinity usually refers to a parent-child process relationship. # famous pipe (named pipe): A well-known pipe is also a half-duplex mode of communication, but it allows communication between unrelated processes. # semaphore (Semophore): Semaphore is a counter that can be used to control access to shared resources by multiple processes. It is often used as a locking mechanism to prevent a process from accessing the shared resource while other processes are accessing the resource. Primarily as a means of synchronization and mutual exclusion between processes and between different threads within the same process. # message Queue: Message Queuing is a linked list of messages, stored in the kernel and identified by message queue identifiers. Message Queuing overcomes the disadvantages of less signal transmission information, only unformatted byte stream, and limited buffer size. A process with Write permission can add a new message to a message queue in accordance with certain rules, and a process that has read access to a message queue can read a message from the message queue. # signal (sinal): signal is a more complex way of communication, used to inform the receiving process that an event has occurred, a process received a signal with the processor received an interrupt request effect can be said to be the same. # Shared Memory: Shared memory is the fastest IPC method. Maps a section of memory that can be accessed by other processes, which is created by a process, but can be accessed by multiple processes. is designed specifically for inefficient operation of other interprocess communication modes. It is often used with other communication mechanisms, such as semaphores, to achieve synchronization and communication between processes. This kind of communication needs to rely on some kind of synchronization mechanism, such as mutual exclusion lock and semaphore. # Socket: Socket is also an inter-process communication mechanism, unlike other communication mechanisms, it can be used for different and inter-process communication. For inter-process communication between different machines in the network, the application is very extensive. In Unix systems, there are many ways to implement interprocess communication, and unfortunately, very few methods can be ported across all UNIX systems (the only half-duplex pipeline, which is also the most primitiveCommunication mode). Linux, as an emerging operating system, supports almost all of the inter-process communication methods that are commonly used under UNIX.

Linux interprocess communication: Pipelines, semaphores, message queues, signals, shared memory, sockets

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.