DigestCPP

Lets Understand With Example

  • Home
  • Design Principal
  • Design Patterns
  • C++ 11 Features
  • C++11 Multithreading
  • Contact Us

Linux IPC

IPC stands for inter-process-communication. There are 6 ways of communication and processes can talk to each other.

Types of IPC in Linux:

  • Pipe
  • Message Queue
  • Shared Memory
  • Socket
  • Semaphore
  • Signal


Message Queue:

  • Easy way to pass data between processes.
  • This is the advance version of pipes and here we don’t need to worry about opening and closing of pipes.
  • Message Queue exists independently (if processes they were using it and terminated now but MQ still exists in system).
  • Disadvantage: Size restriction, they can be full at some point (same like pipes).

Shared Memory:

  • Highly efficient way of data sharing between processes.
  • When we need to share huge data then we can go shared memory.
  • It is a special range of address that appear in process that created.
  • Other process can attached the above address.
  • If any change happens in that share address then this modification will be visible to attached process.
  • It does n’t provide any synchronisation (its developer responsibility to take care of  synchronisation).

Semaphore:

  • For managing access to resources.
  • when we have critical section of code where you need to ensure that a single process has exclusive access to resource.
  • Here, we are NOT passing any data between process.
  • Here, two process are communicating (talking to each other)BUT not sharing any data.

Pipe:

  • There are 2 type of pipe (unnamed and named pipes)
  • Unnamed pipes are used for only related processes.
  • Named pipes can be used with unrelated processes also.
  • Its developer responsibility to take care of open/close of pipes.
  • Disadvantage: Size restriction, they can be full at some point.

Signal:

  • Their names are self explanatory (like SIGINT etc).
  • Their are 30 signal in Linux kernel (like CTRL+C, segmentation fault etc).
  • They don’t carry any argument.
  • They are like notification or alert.
  • They are one way asynchronous notification.
  • They may send from kernel to process or process to another process or process to itself.

Primary Sidebar




DigestCPP © 2023. All rights reserved.

    About Privacy Policy Terms and Conditions Contact Us Disclaimer