The operating system processes and threads 3

Processes and threads - Communication

  • Interprocess communication refers to transmission or exchange of information between different processes. Interprocess communication divided into two categories: a synchronization , two messaging .

  • Used in synchronization are: semaphores, monitors and the like.

  • Messaging are: pipes (known unknown), message queues, sockets, signals, shared memory.

  • Synchronize

    • This classification includes those, that is, communication processes related to the synchronization process is responsible for the coordination between cooperation is generally not responsible for messaging in addition to the synchronization.

    • signal

    • Inter-process synchronization use, PV operation.

    • The tube

    • The tube can be seen as a software module, which is shared for these variables and shared variables packaging operation to form a functional module having a certain interface, process the tube can call to implement concurrency control process level.

  • Messaging

    • pipeline

      • Unnamed pipes
      • Acronym unnamed pipe conduit (pipe), communication is half-duplex, one-way data flow, and must pass messages between parent and child processes.
      • Named Pipes
      • Named pipe (fifo) is half-duplex, and it's the main difference is that unnamed pipes, named pipes has a name, and corresponding to a disk inode, any process can access it,
  • message queue

  • List message composed by the kernel in the message queue identifier. Signaling message queue overcome the less information, only the carrier pipe plain byte stream buffer size is limited and disadvantages

  • Shared memory

  • Shared memory allows multiple processes to share a given memory area, this section of the shared memory region may be mapped to its own process address space, a process for writing information in the shared memory, this can be used other processes shared memory, through simple memory read operation to read, in order to achieve the inter-process communication.

  • The main advantage of using a shared memory communication of high efficiency, because the process can be directly read and write memory, without requiring any copies of the data, for other team like pipes, and message communication mode, the kernel and user space need to be four times data copying, and copying shared memory only twice: once from the input file to a shared memory area, the shared memory from another to the output file.

  • Sockets

    • Socket (Socket) is an abstraction layer, mainly for passing messages between networks, an application can send or receive data through it, it can be the same as file open, close, and write operations. Sockets allow an application I / O into the network, and communicate with other applications in the network. Network socket is a combination of IP addresses and ports.
Published 27 original articles · won praise 1 · views 893

Guess you like

Origin blog.csdn.net/hu853996234/article/details/104758623