Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 18 Self-Stabilization. Introduction Self-stabilization: Tolerate ‘data faults’  Example: Parent pointers in a spanning tree getting corrupted.

Similar presentations


Presentation on theme: "Chapter 18 Self-Stabilization. Introduction Self-stabilization: Tolerate ‘data faults’  Example: Parent pointers in a spanning tree getting corrupted."— Presentation transcript:

1 Chapter 18 Self-Stabilization

2 Introduction Self-stabilization: Tolerate ‘data faults’  Example: Parent pointers in a spanning tree getting corrupted Assume that the code does not get corrupted System state: legal or illegal Faults may result in an illegal system state Self-Stabilizing system: Irrespective of the initial state always reaches a legal state in finite time

3 Mutual exclusion Legal state: Exactly one machine in the system is ‘privileged’ Assume there are N machines 0 … N-1 Each machine is a K-State machine  Label the possible states from the set {0…K-1} There is one special machine called the bottom machine L, S, R = States of left machine, self, right machine respectively

4 Algorithm Bottom: Privileged if L=S Other machines: Privileged if L  S

5 Algorithm: A move by bottom machine

6 Algorithm: A move by a normal machine

7 Implementation Each process needs to query its left neighbor Instead of periodic queries use a TOKEN for message efficiency What if the token gets lost ?  Bottom machine maintains a timer  If it does not receive a token for a long time it regenerates the token  Multiple tokens do not affect the correctness of the algorithm

8 //Program for the bottom node public class StableBottom extends Process implements Lock { int myState = 0; int leftState = 0; int next; Timer t = new Timer(); boolean tokenSent = false; public StableBottom(Linker initComm) { super(initComm); next = (myId + 1) % N; } public synchronized void initiate() { t.schedule(new RestartTask(this), 1000, 1000); } public synchronized void requestCS() { while (leftState != myState) myWait(); } public synchronized void releaseCS() { myState = (leftState + 1) % N; } public synchronized void sendToken() { if (!tokenSent) { sendMsg(next, "token", myState); tokenSent = true; } else tokenSent = false; } public synchronized void handleMsg(Message m, int src, String tag) { if (tag.equals("token") ) { leftState = m.getMessageInt(); notify(); Util.mySleep(1000); sendMsg(next, "token", myState); tokenSent = true; } else if (tag.equals("restart") ) sendToken() }

9 //Program for a normal node public class StableNormal extends Process implements Lock { int myState = 0; int leftState = 0; public StableNormal(Linker initComm) { super(initComm); } public synchronized void requestCS() { while (leftState == myState) myWait(); } public synchronized void releaseCS() { myState = leftState; sendToken(); } public synchronized void sendToken() { int next = (myId + 1) % N; sendMsg(next, "token", myState); } public synchronized void handleMsg(Message m, int src, String tag) { if (tag.equals("token")) { leftState = m.getMessageInt(); notify(); Util.mySleep(1000); sendToken(); }

10 Self-stabilizing spanning tree Maintain a spanning tree rooted at the ‘root’ node A data fault may corrupt the ‘parent’ pointer at any node Recalculate parent pointers regularly

11 Algorithm dist maintains the distance of a node from the root

12 Algorithm The root periodically sets parent to -1(null) and dist to 0 A non-root reads dist from all neighbors and points its parent to the node with the least distance from the root


Download ppt "Chapter 18 Self-Stabilization. Introduction Self-stabilization: Tolerate ‘data faults’  Example: Parent pointers in a spanning tree getting corrupted."

Similar presentations


Ads by Google