200 likes | 265 Views
CIS 725. Lecture 2. Finite State Machine Model. FSM = (A, S, T, s 0 ) A = set of actions S = set of states s 0 = initial states T = transition relation S * A S. Communicating FSM. send actions: -m or !m q ! m = send message m to q
E N D
CIS 725 Lecture 2
Finite State Machine Model • FSM = (A, S, T, s0) A = set of actions S = set of states s0 = initial states T = transition relation S * A S
Communicating FSM • send actions: -m or !m q ! m = send message m to q • receive actions: +m or ? m q ? m = receive message from q • internal actions
Protocol • A collection of CFSMs
Asynchronous coupling • Channels ch1 = channel from M to N ch2 = channel from N to M • Global state: (q1, q2, x, y) q1 = state of M q2 = state of N x = messages in transit to M y = messages in transit to N
Protocol actions • Each protocol action results in a change in the global state
Error states • Deadlock states: - state from which no transition is enabled • Unspecified reception: - a state in which a message exists in a channel but no transition is enabled in the state to receive it.
studying studying !meeting waiting Meeting appointment • - Initial state: studying • Send a message for meeting • May decide to cancel anytime ?OK meeting
Two-process mutual exclusion: Token ring protocol • Single token circulates among two nodes • Node with the token can enter the critical section
Request-based Token ring protocol - To get the token, send a request to the other node
no_token no_token !req !req ?token ?token !token req_sent req_sent enter enter enter exit exit exit ?req token & req_recd token token ?req in_cs in_cs& req_recd in_cs Request-based Token ring protocol
Programming language style notation • Guarded actions • en(a) a en(a): guard of the action boolean condition or boolean condition + receive statement
Normal form • init; do en(a1) a1 [] en(a2) a2 : : od
Token-based system • P1: hold = false; in_cs = false do ? token hold = true [] hold /\ not in_cs ! Token; hold =false [] hold in_cs = true [] in_cs in_cs = false od