Operating System: Question Set – 15

Operating System: Question Set – 15

What is the Dining Philosophers Problem?

The Dining Philosophers Problem is a well-known synchronization problem in which philosophers use forks (resources) to alternate between eating and thinking. It demonstrates how to allocate resources and prevent deadlocks.

What are spinlocks?

A procedure that “spins” (continuously checks) until the lock becomes accessible is known as a spinlock. They are useful for short critical sections.

What is busy waiting, and how can it be avoided?

  • Busy Waiting: A process continuously checks for a condition, wasting CPU cycles.
  • Avoided by: Using blocking synchronization mechanisms like semaphores or condition variables.

What is test-and-set instruction?

One atomic operation utilized in synchronization is the test-and-set instruction. It ensures mutual exclusion by testing and changing a memory location in a single step.

What is the difference between a binary semaphore and a mutex?

  • A binary semaphore can be used for signaling between processes.
  • A mutex is specifically designed for mutual exclusion and usually has ownership.

What is fairness in process synchronization?

Fairness ensures that no process is starved and all processes get a chance to access shared resources in a reasonable amount of time.

What are some real-world examples of synchronization problems?

  • File systems: Multiple processes accessing the same file.
  • Databases: Transactions updating shared tables.
  • Multithreaded programs: Threads updating shared variables.

How does the OS enforce synchronization?

  • Using hardware support like atomic instructions (e.g., test-and-set, compare-and-swap).
  • Kernel-level synchronization primitives like semaphores, locks, and monitors.

How can deadlocks be avoided?

  • Deadlock avoidance algorithms like the Banker’s Algorithm.
  • Resource allocation graphs.
  • Imposing a strict order on resource requests.

What is priority inversion?

Priority inversion occurs when a high-priority process is waiting for a resource held by a lower-priority process, which cannot proceed because of an intermediate-priority process.

Leave a Reply

Your email address will not be published. Required fields are marked *