|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--daj.Program | +--MutualExclusion.Prog
The code that will be executed on each node.
Field Summary | |
static int |
C
possible value for region: critical region entered |
protected int |
clock
the current clock value |
protected java.util.Vector[] |
deferred_ok
for every neighbour, the buffer for remembering deferred ok messages until critical region has been left |
protected java.util.Vector[] |
history
for every node, the message history |
protected int |
index
the node number |
protected LogicalTime |
lastTryTime
the logical time of the last "try" message that has been sent |
static int |
R
possible value for region: idle |
protected int |
region
the region can be either R, T, C or E |
static int |
T
possible value for region: try to get the ressource |
Fields inherited from class daj.Program |
node |
Constructor Summary | |
Prog(int index)
the default constructor initializes the index and the arrays |
Method Summary | |
private boolean |
checkOkMsgsReceived()
This is a helper function that checks if all "OK" messages have been recieved for the last try message. |
void |
freeRessource()
the user function for freeing the ressource (exiting the critical region) |
java.lang.String |
getText()
|
private void |
handleTryMessage(int received,
Msg msg)
This is a helper function that responds properly to a received "try" message. |
void |
main()
this method performs the node's main functions |
void |
ressourceAvailable()
this function is called when the ressource can be taken (the critical region can be entered) |
void |
ressourceFreed()
this function is called when the ressource has been freed (the critical region has been left) |
void |
tryRessource()
the user function for trying to get the ressource (getting the permission to enter the critical region) |
Methods inherited from class daj.Program |
assert, exit, getTime, in, in, interrupt, out, out, setNode, sleep, yield |
Methods inherited from class java.lang.Object |
|
Field Detail |
public static final int R
public static final int T
public static final int C
protected int index
protected int region
protected int clock
protected java.util.Vector[] history
protected java.util.Vector[] deferred_ok
protected LogicalTime lastTryTime
Constructor Detail |
public Prog(int index)
Method Detail |
public void tryRessource()
public void freeRessource()
public void ressourceAvailable()
public void ressourceFreed()
public void main()
main
in class daj.Program
public java.lang.String getText()
getText
in class daj.Program
private void handleTryMessage(int received, Msg msg)
private boolean checkOkMsgsReceived()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |