20
CIS 725 Lecture 2

CIS 725

Embed Size (px)

DESCRIPTION

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 - PowerPoint PPT Presentation

Citation preview

Page 1: CIS 725

CIS 725

Lecture 2

Page 2: CIS 725

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

Page 3: CIS 725

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

Page 4: CIS 725

Protocol

• A collection of CFSMs

Page 5: CIS 725

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

Page 6: CIS 725

Protocol actions

• Each protocol action results in a change in the global state

Page 7: CIS 725
Page 8: CIS 725
Page 9: CIS 725
Page 10: CIS 725

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.

Page 11: CIS 725
Page 12: CIS 725

Meeting appointment

!meeting

waiting

meeting

?OK

- Initial state: studying- Send a message for meeting- May decide to cancel anytime

studyingstudying

Page 13: CIS 725

Two-process mutual exclusion: Token ring protocol- Single token circulates among two nodes- Node with the token can enter the critical section

Page 14: CIS 725

Request-based Token ring protocol- To get the token, send a request to the other node

Page 15: CIS 725

Request-based Token ring protocol

no_tokenno_token

enter exit

in_cs&req_recd

token &req_recd

?req

?req

!tokenreq_sent req_sent

tokentoken

?token

!req

?token

!req

in_cs

enter exit

in_cs

enter exit

Page 16: CIS 725
Page 17: CIS 725
Page 18: CIS 725

Programming language style notation

• Guarded actions• en(a) a en(a): guard of the action boolean condition or boolean condition + receive statement

Page 19: CIS 725

Normal form

• init; do en(a1) a1

[] en(a2) a2

: : od

Page 20: CIS 725

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