All Exams Test series for 1 year @ ₹349 only
Question

In UNIX, which system call is used for inter process communication via shared memory ?

The correct answer is
shmget()

UNIX Shared Memory IPC: Using shmget()

Inter-Process Communication (IPC) allows different processes to exchange data. Shared memory is an efficient IPC method where processes can access a common region of memory.

System Call Analysis for Shared Memory

The question asks for the UNIX system call specifically used for creating or accessing shared memory segments.

  • pipe(): This system call creates a unidirectional data stream (a pipe) between processes. It's used for stream-based communication, not direct memory access.
  • msgget(): This system call is used with message queues. It retrieves a message queue identifier, facilitating message-based IPC, not shared memory.
  • shmget(): This system call is used to obtain a shared memory identifier. It either creates a new shared memory segment or returns the identifier of an existing one based on the provided key. This is the primary system call for managing shared memory segments.
  • semctl(): This system call performs control operations on semaphores. Semaphores are often used to synchronize access to shared resources (like shared memory), but $semctl()$ itself doesn't manage the shared memory segment.

Therefore, $shmget()$ is the correct system call for initiating shared memory inter-process communication in UNIX.

Was this answer helpful?

Important Questions from Miscellaneous

  1. Which of the following scheduler/schedulers is/are also called CPU scheduler ?
    (A). Short Term Scheduler
    (B). Long Term Scheduler
    (C). Medium Term Scheduler
    (D). Asymmetric Scheduler
    Choose the correct answer from the options given below:
  2. A situation where two or more processes are blocked, waiting for resources held by each other is called:
  3. External fragmentation occurs ________.
  4. Which disk scheduling algorithm looks for the track closest to the current head position?
  5. Which CPU scheduling algorithm prefers the process with the shortest burst time?
Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App