4.5 Proposed Scheme for Deadlock Detection
4.5.2 Representation of Deadlock in NoC using CFSM
A transition in a CFSM based system is possible iff a message generation or message con- sumption is possible. Gouda et al. [77] describe deadlock as a reachable global state [S, Q].
A global state [S, Q] is said to be a deadlock state iff i) all states ∈ S, are in receiving state, and ii) all message queues ∈ Q, are empty. Since all states are in receiving state, a transition due to the generation of a new message is not possible. A transition due to the
consumption of a new message is also not possible due to the absence of any message in the message queue. In a system, modeled using CFSM, if neither message generation nor mes- sage consumption is possible, it indicates no transition is possible in the system. Therefore, no further transition is possible from a deadlock state of a system. The deadlock description in [77] has not considered the possibility of delayed reception. In this work, we have defined the deadlock in a CFSM based network model where delayed reception is permitted.
Definition 4.5.1. Consider a CFSM model of a system with n number of processes, where delayed reception is permitted. A reachable global state [S, Q] is said to be a deadlock state iff i) All states ∈ S, are in receiving state and ii) Either all message queues are empty or some other message queues are not empty but no further transition is possible.
The condition, “All message queues are empty”- is already mentioned in the deadlock definition in [77]. The other case, where some message queues are not empty becomes applicable due to presence of delayed reception. Let us consider each process Pi, where i = 1,2,3, . . . , n and the current state of Pi is si. The state si is a receiving state and waiting for message from some processPj, i.e., from message queueQji. The message queues from where Pi receives messages areQki, wherek = 1,2,3, . . . , j, . . . , nandj 6=i. IfQji is empty even though some other message queues inQki are not empty, the transition from the current state si of process Pi cannot consume any message from any other message queue Qki. In such a situation, no transition is possible from any process Pi and the global state [S, Q] is a deadlock state of the CFSMs.
Example 4.5. We have illustrated deadlock in a CFSM model with delayed reception in Fig. 4.9. The color of the states and the edges have the same meaning as mentioned in the previous example in Fig. 4.8. There are six processes in this example. Initially, all processes are in the respective initial states, represented by the global state G0. A possible sequence of global state transitions for these CFSMs are shown in Fig. 4.10. Suppose P1 transmits message −p1p3 towards P3. At the same moment, P4 also transmits message
−p4p6 towards P6. The new global state is G1. After consuming these messages by P3 and P6, global state changes to G2. In this way, there is a possible sequence of global state
−p1p3 +p3p1
WT1 I1
+p6p2 −p2p6 −p2p3
+p3p2
I2 Ir2 Ak2 WT2
−p3p1
+p1p3
−p3p5 +p5p3
+p2p3 −p3p5 +p5p3
−p3p2 I3
st3 tr3 ret3
stw3 trw3 retw3
−p4p6 +p6p4
I4 WT4
+p3p5 −p5p3 −p5p6
+p6p5
I5 Ir5 Ak5 WT5
−p6p4
−p6p2 +p2p6
+p4p6
+p5p6 −p6p2 +p2p6
−p6p5 I6
st6 tr6 ret6
stw6 trw6 retw6
P1 P2
P3
P4 P5
P6
Figure 4.9: CFSMs with Cyclic Dependency
transitions that are illustrated in Fig. 4.10. Finally, the system reaches a global state Gf: [W T1, W T2, trw3, W T4, W T5, trw6, Q13 ={p1p3}, Q35 ={p3p5}, Q46 ={p4p6}, Q62 = {p6p2} ]. From the global state Gf, all the processes are in receiving states and no further transition is possible although some of the message queues are not empty. If we observe carefully, it reveals that processes P2, P3, P5 and P6 are waiting for each other and they form a cycle of dependency. The dependency graph is shown in Fig.4.11. In this graph, the current state of each CFSM and the message for which the CFSM is waiting is shown. There is no further transition possible after reaching global state Gf, due to cyclic dependency
G0 = [ I1, I2, I3, I4, I5, I6 ]
G1 = [ WT1, I2, I3, WT4, I5, I6, Q13 = {p1p3}, Q46 = {p4p6} ]
G2 = [ WT1, I2, st3, WT4, I5, st6 ]
G3 = [ WT1, I2, tr3, WT4, I5, tr6, Q35 = {p3p5}, Q62 = {p6p2} ]
G4 = [ WT1, Ir2, tr3, WT4, Ir5, tr6 ]
G5 = [ WT1, Ak2, tr3, WT4, Ak5, tr6, Q26 = {p2p6}, Q53 = {p5p3} ]
G7 = [ WT1, WT2, I3, WT4, WT5, I6,
Q23 = {p2p3}, Q56 = {p5p6}, Q31 = {p3p1}, Q64 = {p6p4}]
G8 = [ I1, WT2, stw3, I4, WT5, stw6 ]
Gf = [ WT1, WT2, trw3, WT4, WT5, trw6,
Q13= {p1p3}, Q46 = {p4p6}, Q35={p3p5}, Q62 = {p6p2} ]
G6 = [ WT1, WT2, ret3, WT4, WT5, ret6, Q23 ={p2p3}, Q56 ={p5p6}]
Figure 4.10: Global State Transitions of CFSMs in Fig. 4.9
even if some messages (p1p3, p3p5, p4p6, p6p2) are present in the message queues. This is a deadlock situation defined in Definition 4.5.1, where message queues are not empty. This behavior can be exploited for deadlock detection of NoC. We put forth this behavior in our proposed Theorem 4.5.2.
Theorem 4.5.2. Consider a communication system withn CFSMs, where delayed reception is present but no unspecified reception is present. If all CFSMs are in receiving states and no transition is possible in those CFSMs, it is a deadlock situation due to cyclic dependencies on waiting for messages amongst CFSMs to proceed with further transitions.
(WT2)
P2 P3
(trw3)
(WT1)
P1
P4
(WT4)
P6
(trw6) (WT5)
P5 +p3p2
+p3p1
+p2p6
+p6p5
+p5p3
+p6p4
Figure 4.11: Cyclic Dependency Graph for the CFSMs in Fig. 4.9
Proof. Let us consider a CFSM based communication system with n number of processes P1, P2, P3, . . . , Pn, with no unspecified reception or design error. After some transitions, the system reaches a global state Gf. Let there be no further transition possible from Gf and all CFSMs are in receiving states. Let Gf = [s1, s2, . . . , sn, Q] and current states of P1, P2, P3, . . . , Pnares1, s2, . . . , sn, respectively. It is given that all CFSMs are in receiving states. Therefore, they cannot generate any message and no transition is possible due to generation of new messages. The set of messages that are waiting at their specific message queues to be consumed are represented by Q. There are two possible scenarios in Q. i) All message queues are empty, i.e.,Q=φ. If there is no message in the message queues, there is no chance of consuming a message. or ii) There are some messages present in the message queue. For each processPi, i= 1,2,3, . . . , n, is waiting for message from some processPj, i.e., from message queue qji. Since it is given that no transition is possible, any message consumption is also not possible. Therefore, the message queue qji must be empty, even though other message queues from where Pi can receive message may not be empty.
In both the cases, no transition is possible from any process and the global state Gf is in a deadlock state. Now we have to prove that the deadlock is due to the presence of a cyclic dependency in the system. We are proving this by the method of contradiction. Let us assume, there is no cyclic dependency for messages in the system. Since all processes are in receiving state and no transition is possible, each process is waiting for a specific
message from one specific machine. Let us assume, P1 is waiting for a message from P2. Similarly, P2 is waiting for a processP3 and P3 is waiting for a process P4. IfP4 is waiting for P1 or P2 or P3, it creates a cyclic dependency. Therefore, P4 must be waiting for some process, other than P1, P2 and P3, say P5. In similar fashion, the waiting chain continues and reaches a situation where Pn−1 is waiting for Pn. It is given that, no transition is possible from Pn as well. It must be waiting for a message from another processes Px. We assume that there is no cyclic dependency in the system. If Px ∈ {P1, P2, P3, . . . , Pn−1}, it creates a dependency cycle. Therefore, to satisfy our assumption, it must be true that, Px 6∈ {P1, P2, P3, . . . , Pn−1}. But there is no other process left in the system. Therefore, Px∈ {P1, P2, P3, . . . , Pn−1}. Thus,Pxcompletes a cycle where processes are waiting for each other. Thus we reach a contradiction of our assumption that there is no cyclic dependency present in the system. Hence, we conclude that, if all CFSMs are in receiving states and no transition is possible in those CFSMs, there are cyclic dependencies on waiting for messages amongst CFSMs that create a deadlock.