Process communication mode-thread communication mode

Source: Internet
Author: User
Tags posix semaphore

Interprocess: Pipeline, Message queue, signal, shared memory, socket

There are several ways to communicate between processes:

(1) Pipes: Pipelines can be used to communicate between affinity processes, allowing one process and another to communicate with a process that has a common ancestor to it.
(2) Named pipe (named pipe): The named pipe overcomes the limitation of the pipe without name, so that, in addition to having the functionality that the pipeline has, it allows for inter-process communication without affinity. Named pipes have corresponding file names in the file system. Named pipes are created by command Mkfifo or by system call Mkfifo.
(3) signal (Signal): signal is a more complex mode of communication, used to inform the receiving process of an event occurred, in addition to inter-process communication, the process can also send signals to the process itself; Linux in addition to supporting the UNIX early signal semantic function Sigal outside, It also supports the signal function sigaction that is semantically compliant with the POSIX.1 standard (in fact, the function is based on BSD, BSD in order to achieve a reliable signal mechanism, but also can unify the external interface, with the Sigaction function to re-implement the signal function).
(4) Message queue: Message Queuing is a linked table of messages, including POSIX Message Queuing system V Message Queuing. A process with sufficient permissions can add messages to the queue, and a process that is given Read permission can read the messages in the queue. Message queue overcomes the lack of signal carrying information, the pipeline can only carry the unformatted byte stream and the buffer size is limited.
(5) Shared memory: Allows multiple processes to access the same piece of memory space, is the fastest available IPC form. is designed for inefficient operation of other communication mechanisms. It is often used in conjunction with other communication mechanisms, such as semaphores, to achieve synchronization and mutual exclusion between processes.
(6) Memory mapping (mapped memories): Memory mapping allows any number of interprocess communication, and each process that uses the mechanism implements it by mapping a shared file to its own process address space.
(7) Semaphore (semaphore): primarily as a means of synchronization between processes and between different threads of the same process.
(8) Socket: A more general inter-process communication mechanism that can be used for inter-process communication between different machines. Originally developed by the BSD branch of the UNIX system, it can now be ported to other Unix-like systems: both Linux and System V variants support sockets.

Second, the method of thread communication

There are two main methods of thread communication:

Shared memory, Message Queuing, event objects, global variables

Process communication mode-thread communication mode

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.