Maekawa's Quorum-Based Mutual Exclusion Algorithm
Experiment Controls
- Number of Processes (N): Total processes in the distributed system. Vary this to observe impact on message count and deadlock probability.
- Quorum Size (K): Approximately sqrt(N), determining how many processes must approve each request.
- Critical Section Execution Time: Duration a process occupies the critical section, affecting contention levels.
Phase 1: System Setup
Initialize Processes:
- Start N processes in the distributed system.
- Arrange processes in a sqrt(N) x sqrt(N) grid to facilitate quorum construction.
Define Quorums:
- For each process
Pi, define its quorumSias the union of its row and column in the grid. - Why: This ensures any two quorums share at least one process (intersection property), which prevents simultaneous critical section access.
- For each process
Phase 2: Critical Section Access Protocol
Request Entry:
- When process
Pineeds the critical section, it sendsREQUESTmessages to all processes in its quorumSi. - Why: Pi must obtain permission from its entire quorum to guarantee mutual exclusion.
- When process
Process Incoming Requests:
- When
Pjreceives aREQUESTfromPi:- If
Pjhasn't granted permission since its lastRELEASE, sendGRANTtoPi. - Otherwise, queue the request.
- If
- Why: Each process can grant to only one requester at a time, enforcing the mutual exclusion constraint.
- When
Enter Critical Section:
- Process
Pienters the critical section only after receivingGRANTfrom all processes inSi. - Why: Full quorum approval ensures no other process can simultaneously obtain permission.
- Process
Release and Notify:
- After exiting,
PisendsRELEASEmessages to all processes in its quorum. - Why: This frees quorum members to grant permission to waiting processes.
- After exiting,
Grant Queued Requests:
- When
PjreceivesRELEASEfromPi, it sendsGRANTto the next process in its queue.
- When
Phase 3: Deadlock Prevention (Advanced)
- Implement Priority-Based Resolution:
- When
Pjreceives a request fromPibut has already granted toPk:- Compare timestamps: if
Pi's request is earlier (higher priority), sendINQUIREtoPk. - If
Pkhasn't received all grants yet, it sendsRELINQUISHtoPj. Pjthen grants toPiinstead.
- Compare timestamps: if
- Why: This breaks circular wait chains by allowing lower-priority requests to yield to higher-priority ones.
- When
Phase 4: Monitoring and Analysis
Collect Performance Metrics:
- For each critical section entry, record:
- Total messages sent (REQUEST + GRANT + RELEASE).
- Waiting time per process.
- Deadlock occurrences (if any).
- For each critical section entry, record:
Analyze Results:
- Calculate average message complexity and verify it approaches 3 * sqrt(N).
- Compare with Lamport's (3 * (N-1)) and Ricart-Agrawala's (2 * (N-1)) algorithms.
- Identify patterns in deadlock occurrence relative to N and concurrent request frequency.
- Why: This validates the theoretical O(sqrt(N)) complexity and demonstrates the algorithm's efficiency advantages.