PDF

Free PDF Source

PDF

Free PDF Source

Short Trick Of Process Synchronization ( Solve any question in few minutes).

Short Trick Of Process Synchronization ( Solve any question in few minutes).

[fvplayer id=”361″]

Here’s a short trick guide to help you quickly solve any Process Synchronization question in GATE (or similar competitive exams) in a few minutes:


๐Ÿง  Topic: Process Synchronization

๐ŸŽฏ Goal: Identify Mutual Exclusion, Progress, Bounded Waiting in code
๐Ÿงช Target: GATE-level MCQs or code analysis


โœ… TRICK 1: Look for the 3 Magic Words

Always check if the algorithm/code satisfies:

  1. Mutual Exclusion โ€“ Only 1 process in the Critical Section

  2. Progress โ€“ No unnecessary blocking

  3. Bounded Waiting โ€“ Every process eventually gets a turn

๐Ÿ“ Tip: If even one of these is violated, itโ€™s not a correct solution.


โœ… TRICK 2: Remember the CORE ALGORITHMS

Algo No. Name Processes Hardware Needed Reliable? Notes
1 Simple Lock 2+ No โŒ Violates progress
2 Dekkerโ€™s Algo 2 No โœ… Software-only
3 Petersonโ€™s Algo 2 No โœ… Easy to simulate
4 Test-and-Set Lock 2+ Yes (Atomic op) โœ… Uses hardware instruction
5 Semaphore 2+ No โœ… wait() and signal()
6 Monitor 2+ No โœ… High-level abstraction

๐Ÿ”‘ Petersonโ€™s = Most Common in GATE Questions!


โœ… TRICK 3: Identify the Entry & Exit Sections

Quickly scan the code for these patterns:

๐ŸŸฉ Entry Section (wants to enter CS):

  • flag[i] = true; โ†’ intention to enter

  • turn = 1 - i; โ†’ gives other process a chance

  • while(...) โ†’ busy wait / condition checking

๐ŸŸฅ Exit Section (leaves CS):

  • flag[i] = false;

  • turn = ...; โ†’ resets turn for the other process


โœ… TRICK 4: Use This YES/NO Table

Condition to Check Look for in Code Shortcut Decision
Mutual Exclusion? Only one process allowed in CS โœ… if while(flag[] && turn) pattern exists
Progress? No unnecessary delay if CS is free โœ… if turn changes appropriately
Bounded Waiting? Process wonโ€™t wait forever โœ… if turn is assigned fairly

โœ… TRICK 5: Look for Common MCQ Keywords

Watch for these question patterns:

  • “Which condition is violated?”
    โ†’ Use the YES/NO table above

  • “How many processes can be in CS?”
    โ†’ If more than one, Mutual Exclusion is violated

  • “What is the purpose of turn or flag[]?”
    โ†’ flag[] = intent, turn = fairness

  • “Identify correct algorithm from options”
    โ†’ Match pattern to Peterson, Dekker, etc.


โœ… Super Short Summary

๐Ÿ”“ flag[] = true โ†’ process wants to enter
๐Ÿ›‘ while (flag[other] && turn == other) โ†’ wait
โœ… Critical Section
๐Ÿ” Reset flag[i] = false, set turn = other


โšก Example (Peterson’s):

c
flag[i] = true;
turn = 1 - i;
while (flag[1 - i] && turn == 1 - i)
; // wait

// Critical Section

flag[i] = false;

๐Ÿ“Œ This ensures:
โœ” Mutual Exclusion
โœ” Progress
โœ” Bounded Waiting


Would you like:

  • A printable cheat sheet?

  • Practice MCQs with answers?

  • Visual flowcharts for each algorithm?

Let me know!

Short Trick Of Process Synchronization ( Solve any question in few minutes).

Process Synchronization Race Condition: Critical Section …

Chapter 5: Process Synchronization

Short Trick Of Process Synchronization ( Solve any question in few minutes).

Leave a Reply

Scroll to top