πŸ“’ Too many exams? Don’t know which one suits you best? Book Your Free Expert πŸ‘‰ call Now!

  • google app store apple app store
  • βœ–

      Question

      In the context of inter-process communication (IPC),

      which of the following mechanisms is used to ensure that only one process accesses a resource at a time?
      A Semaphore Correct Answer Incorrect Answer
      B Mutex Correct Answer Incorrect Answer
      C Message Queue Correct Answer Incorrect Answer
      D Shared Memory Correct Answer Incorrect Answer
      E Pipe Correct Answer Incorrect Answer

      Solution

      A Mutex (Mutual Exclusion) is a synchronization primitive used to prevent concurrent processes from accessing a shared resource simultaneously. By locking the resource when one process is using it, a mutex ensures that other processes must wait until the resource is released. This prevents data corruption and ensures that critical sections of code are executed safely, thereby facilitating proper synchronization in multi-threaded applications. Option A (Semaphore) is incorrect because, while it can also be used for synchronization, it allows a certain number of processes to access a resource concurrently, which does not guarantee exclusive access. Option C (Message Queue) is incorrect as it is primarily used for communication between processes rather than controlling access to shared resources. Option D (Shared Memory) allows multiple processes to access the same memory segment, but it does not inherently provide mechanisms for synchronization. Option E (Pipe) is incorrect because pipes are used for communication between processes but do not provide mutual exclusion for shared resources.

      Practice Next

      Relevant for Exams:

      ask-question