Dssss
Dssss
1. Explain the concept of consistent global state and transitless global state.
Resource Deadlock:
Jab processes ek dusre ke resources ka wait karte hain aur ek cyclic dependency ban jata hai.
o Example: P1 ko R1 chahiye, jo P2 ke pass hai. Aur P2 ko R2 chahiye, jo P1 ke pass hai.
Communication Deadlock:
Jab processes message send/receive ke liye ek dusre ka wait karte hain.
o Example: P1 reply ke liye P2 ka wait kare aur P2 reply ke liye P1 ka wait kare.
3. Show how vector clocks are more suitable than Lamport’s logical clock in distributed systems.
Lamport clocks event ordering ensure karte hain, lekin causal dependency nahi dikhate.
Vector Clock Advantage:
1. Vector clocks causal relationships (e.g., "happens-before") dikhate hain.
2. Har process apna vector maintain karta hai aur messages exchange ke through update karta
hai.
o Example: Agar P1 ke event ka impact P2 ke event par hai, to vector clocks dependency
explicitly track karenge.
4. List the performance metrics used for evaluating distributed mutual exclusion algorithms.
Forward Recovery:
System fault ke baad new state se recover karta hai.
o Example: Data ko dynamically adjust karke computation resume karna.
Backward Recovery:
Fault ke baad system previous stable state (checkpoint) par wapas chala jata hai.
o Example: Crash hone ke baad last checkpoint load karke system restart karna.
6. Rank the basic, multi-version, and conservative timestamp ordering algorithms in increasing order
of transaction abort rates.
1. Basic Timestamp Ordering Algorithm (Most Aborts): Direct conflicts me transactions abort hoti
hain.
2. Multi-Version Timestamp Ordering Algorithm: Conflict hone par old versions maintain kar leta
hai, isliye kam aborts hoti hain.
3. Conservative Timestamp Ordering Algorithm (Least Aborts): Conflicts avoid karne ke liye
transactions ko delay karta hai, abort ka chance sabse kam hota hai.
Flat Transactions: Single-level transactions. Agar ek fail ho jaye, to poori transaction fail hoti hai.
o Example: Bank transaction fail hone par pura rollback hota hai.
Nested Transactions: Ek parent transaction ke andar sub-transactions hoti hain. Agar ek sub-
transaction fail kare, to parent transaction decide karti hai ki rollback hona chahiye ya nahi.
8. Explain the need for fault-tolerance in distributed systems and the concept of transparent failure
handling.
Need for Fault-Tolerance: Distributed systems me failures (node crashes, network errors) avoid
nahi kiya ja sakta, isliye system ko fault-tolerant hona zaroori hai.
Transparent Failure Handling:
User ko failures ke effects ka pata nahi chalna chahiye.
o Example: Replica systems me agar ek server fail ho jaye, to dusra server automatically use
handle kare.
10. What is the domino effect in distributed recovery systems? How can it be avoided?
Domino Effect:
Jab ek process failure ke baad recover hone ke liye apne dependent processes ko rollback karna padta
hai, aur ye rollback ek chain reaction ban jata hai.
o Example: Multiple checkpoints par dependency ho aur ek checkpoint fail ho jaye, to poore
system ko rollback karna padta hai.
Avoidance:
1. Consistent checkpoints lena.
2. Message logging: Saari states ko log karke recovery ke liye use karna.
1. Classify Deadlock Detection Algorithms and Describe Path-Pushing Deadlock Detection Algorithm
Steps:
2. Ek process (P1) apne dependencies ko ek path ki form me propagate karta hai agar wo kisi resource
ke liye wait kar raha hai.
3. Jis process ko path receive hota hai (e.g., P2), wo apne dependencies ke saath updated path ko aage
forward karta hai.
4. Agar koi process apne hi node ka cyclic path detect kare, to deadlock confirm hota hai.
Example:
What is DFS?
Distributed File System (DFS) ek system hai jisme data multiple nodes ya servers me distributed hota hai, jo
ek large-scale environment me file sharing aur data storage ko optimize karta hai.
Key Components:
1. Clients:
o File access aur modification requests bhejte hain.
2. Metadata Server (Master):
o File location aur metadata (e.g., permissions) manage karta hai.
o Example: Google File System (GFS) me Master Node.
3. Storage Nodes (Slaves):
o Files ko distributed chunks me store karte hain.
o Example: Hadoop Distributed File System (HDFS) me DataNodes.
Characteristics of DFS:
Comparison Table:
1. Dynamic quorum adjust hota hai jo nodes ki availability aur failures ke basis par hota hai.
2. Partitioned network me consistency aur reliability ensure karta hai.
1. Quorum size fixed hota hai, jo failure aur partition hone par badal nahi sakta.
2. System fail hone ke chances zyada hote hain.
Types of Locks:
1. Shared Locks:
o Multiple transactions ko read operation karne ki permission milti hai.
o Example: Two processes P1 and P2 can read the same data at the same time.
2. Exclusive Locks:
o Sirf ek transaction ko data modify karne ki permission milti hai.
o Example: P1 modifies a record, so P2 cannot read or modify it until P1 releases the lock.
3. Two-Phase Locking Protocol (2PL):
o Locks do phases me handle kiye jate hain:
Growing Phase: Locks acquire hote hain.
Shrinking Phase: Locks release hote hain.
o Advantage: Serializability ensure karta hai.
o Disadvantage: Deadlocks ho sakte hain.
Limitations:
1. Latency Issues:
o Processes ke beech communication me time lagta hai.
o Impact: Low-latency networks design karne padte hain.
2. Fault Handling Complexity:
o Multiple nodes me fault detect karna aur recover karna challenging hota hai.
o Impact: Fault-tolerance mechanisms (replication, checkpointing) design karne ki zarurat hoti hai.
3. Consistency Challenges:
o Distributed environment me consistent data maintain karna difficult hota hai.
o Impact: Strong consistency protocols (e.g., quorum, Paxos) use karne padte hain.
4. Security Risks:
o Distributed systems network-based hote hain, isliye attacks ke chances zyada hote hain.
o Impact: Strong encryption aur authentication techniques lagani padti hain.
Resource Management:
Why Agreement Cannot Be Reached if More Than 1/3 Nodes Are Faulty:
Proof:
1. Agar fff faulty nodes hain, to non-faulty nodes apne messages ke basis par majority decide karenge.
2. Agar faulty nodes f>n/3f > n/3f>n/3 ho jayein, to majority consensus impossible ho jata hai kyunki faulty
nodes genuine nodes ko confuse kar deti hain.
Example:
1. Consistency Models:
o Different nodes me data consistency ensure karna mushkil hota hai.
o Models: Sequential consistency, causal consistency, eventual consistency.
2. Replication:
o Memory ka replication karte hain taaki faster access mile, lekin replicas ko sync karna challenging
hai.
3. Communication Overhead:
o Data synchronization ke liye frequent communication lagta hai.
4. Fault Tolerance:
o DSM me faults handle karna mushkil hota hai, kyunki ek memory failure poore system ko impact kar
sakta hai.
1. Write-Invalidate Protocol:
o Write hone par purane replicas invalidate hote hain.
o Example: Cache coherence protocols.
2. Write-Update Protocol:
o Write hone par updated data sab replicas me broadcast hota hai.
1. Mutual Exclusion:
o Sirf ek process ek samay par critical section (CS) me enter kar sakta hai.
2. Fairness:
o Processes ki CS requests ko timestamp ke basis par process karna chahiye.
3. Progress:
o Koi bhi process indefinite time tak wait na kare (no starvation).
4. Fault Tolerance:
o Agar kisi process ya communication ka failure ho jaye, to system mutual exclusion ko impact nahi
hone dega.
Message Passing: Distributed systems me mutual exclusion ensure karne ke liye message exchange ki
zarurat hoti hai, jo latency aur failures ki wajah se complex ho jata hai.
Lack of Shared Memory: Processes distributed hone ki wajah se shared memory ka use nahi kar sakte.
Fault Handling: Failures ka impact har process par ho sakta hai.
Example Algorithm:
Ricart-Agrawala Algorithm: Messages ka timestamp-based exchange critical section access ensure karta hai.
1. Fault Detection:
o System me faults timely detect karna zaruri hai.
2. Redundancy:
o Backup components design karne padte hain taaki system operational rahe.
3. Recovery Mechanisms:
o Consistent checkpoints aur logs fault recovery me help karte hain.
4. Complexity of Distributed Failures:
o Distributed systems me ek fault ka impact multiple nodes par ho sakta hai.
Types of Faults:
Purpose:
Chandy-Lamport Algorithm distributed systems me ek consistent global snapshot lene ke liye use hota hai.
Snapshot system ke processes aur communication channels ke current state ko represent karta hai.
1. Initiation:
o Snapshot start karne wala process apni state ko record karta hai aur marker messages bhejta hai
apne outgoing channels pe.
2. Marker Reception Rules:
o Jab ek process first marker receive karta hai, to:
1. Apni current local state record karta hai.
2. Apne outgoing channels pe marker message send karta hai.
o Marker ke baad aane wale messages channel state me record hote hain.
3. Channel State Recording:
o Jab koi message marker se pehle receive hota hai, to wo snapshot me include nahi hota. Marker ke
baad messages channel state me record hote hain.
4. Snapshot Completion:
o Jab har process apna local state aur incoming channel states record kar leta hai, to snapshot
complete hota hai.
Process states aur channel states ko aise record kiya jata hai ki ek consistent global state mile jo ongoing
computations se unaffected ho.
Scenario:
6 Processes: P1, P2, P3, P4, P5, P6
Process IDs: {12, 9, 4, 6, 15, 10}
Highest ID: 15 (P5 will become the leader).
Step-by-Step Execution:
1. Failure Detection:
o Let’s assume the current leader (P5 with ID = 15) crashes.
o Remaining processes detect the failure and initiate the election.
2. Election Initiation (P1 starts):
o P1 (ID = 12) sends an Election Message to higher ID processes: P5 (15), P6 (10).
3. Responses:
o P5 has crashed, so it won’t respond.
o P6 (ID = 10) replies but can’t become leader as its ID is lower than P1.
4. P2 and P3 Participate:
o Similarly, P2 (ID = 9) and P3 (ID = 4) start election messages, but they both get overridden by P1.
5. P5 Recovers:
o After recovering, P5 with the highest ID (15) overrides the current election and sends Coordinator
Messages to all processes.
Final Outcome:
P5 is declared the new leader as it has the highest ID among the processes.
1. Initial Setup:
o Processes periodically save their states as checkpoints during the transaction.
o Communication between processes occurs via message passing.
2. Scenario Example:
o P1, P2, P3 are performing a distributed transaction.
o A checkpoint is created after every step.
Execution:
1. Consistent Checkpoints: All processes must synchronize checkpoints to create a global consistent snapshot.
2. Message Logging: Log messages so that states can be recreated without rollback.
3. Chandy-Lamport Snapshot Algorithm: Use snapshotting to avoid incomplete states.
Phases:
1. Prepare Phase:
o Coordinator: Sends prepare message to all participants asking if they are ready to commit.
o Participants: Reply with “YES” if they are ready or “NO” if they can’t commit.
2. Commit/Abort Phase:
o If all participants reply “YES,” the coordinator sends a Commit Message and the transaction is
committed.
o If any participant replies “NO,” the coordinator sends an Abort Message and the transaction is
aborted.
Example:
Limitations of 2PC:
1. Blocking Problem: If the coordinator crashes after sending prepare messages, participants cannot make
progress.
2. No Recovery Mechanism: Recovery depends entirely on the coordinator.
Phases:
Comparison Example:
If the coordinator crashes after pre-commit in 3PC, participants can use the pre-commit signal to finalize or
abort the transaction.