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!
