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:
-
Mutual Exclusion β Only 1 process in the Critical Section
-
Progress β No unnecessary blocking
-
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
turnorflag[]?”
β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
π Resetflag[i] = false, setturn = other
β‘ Example (Peterson’s):
π 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!
