0% found this document useful (0 votes)
16 views3 pages

Process Synchronization Descriptive Questions

Uploaded by

Sapna Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

Process Synchronization Descriptive Questions

Uploaded by

Sapna Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Process Synchronization - Descriptive Questions & Solutions

1. Define Process Synchronization. Why is it needed?

Process synchronization ensures multiple processes execute concurrently without data

inconsistency or resource conflicts.

Need:

- Prevent race conditions

- Ensure data consistency

- Coordinate critical section access

- Prevent deadlock/starvation

2. What is a Critical Section? Explain the Critical Section Problem.

Critical section: Code segment accessing shared resources.

Problem: Design protocol ensuring:

- Mutual Exclusion

- Progress

- Bounded Waiting

3. Describe Peterson's Solution for the Critical Section Problem.

Software solution for 2 processes:

- Shared: flag[2], turn

- Each sets flag & turn, waits until safe to enter critical section.

4. What are Semaphores? Explain with an example.

Semaphore: Integer used for signaling.

Types: Binary & Counting

Page 1
Process Synchronization - Descriptive Questions & Solutions
Operations: wait(), signal()

Example:

wait(S);

// critical section

signal(S);

5. Differentiate between Mutex and Semaphore.

| Feature | Mutex | Semaphore |

|---------------|--------------------|--------------------|

| Value | 0 or 1 | Integer |

| Ownership | Yes | No |

| Use | Exclusive resource | Multiple instances |

6. Explain Deadlock and the necessary conditions for its occurrence.

Deadlock: Processes blocked holding/waiting for resources.

Conditions:

1. Mutual Exclusion

2. Hold and Wait

3. No Preemption

4. Circular Wait

7. What is the Producer-Consumer Problem? Provide a Semaphore-based solution.

Problem: Producers add, consumers remove from buffer.

Solution:

Semaphore full=0, empty=n, mutex=1

Page 2
Process Synchronization - Descriptive Questions & Solutions
Producer: wait(empty); wait(mutex); produce; signal(mutex); signal(full);

Consumer: wait(full); wait(mutex); consume; signal(mutex); signal(empty);

8. Explain Monitors and their role in process synchronization.

Monitor: High-level construct providing mutual exclusion and condition variables (wait, signal).

Example in Java:

synchronized method using wait() and notify().

Page 3

You might also like