130 likes | 262 Views
1.10 Model 3: Message-Passing Text. We saw Diagrams Shared-variables text Now Message-passing text (like CSP). In the communication statements, we name a channel, and not the communication partner directly. This naming convention Leads to better encapsulation of processes,
E N D
1.10 Model 3: Message-Passing Text • We saw • Diagrams • Shared-variables text • Now • Message-passing text (like CSP)
In the communication statements, • we name a channel, • and not the communication partner directly. • This naming convention • Leads to better encapsulation of processes, • Allows many-to-many communication through a single channel.
Modifications to shared-variables text language: • Disallow the use of shared variables, omit synchronization statements based on them • Add new communication statements based on msg passing.
Communication statements • Channel dcl. • Send • Receive p. 71
Buffering capability • Unbounded buffering (async) • Bounded buffering (async) • No buffering (sync) • The usual convention in buffering: keeping the order of sending messages.
For buffered communication, we add a new variable to the set of state variables Π. • The domain of this variable consists of lists of elements of the declared type. • Transition relations in p. 72, 73
No buffering • Two parallel statements are considered to be matching if they form a send and receive pair on the same channel. • When two matching statements are jointly ready to execute, their execution is atomic and simultaneous and the effect is equivalent to an assignment statement. • P. 74
No buffering is not the same as buffering with N=0 • Buffering with N=0 does not allow any send statement to be executed. • (not the case in Promela) • See Fig. 1.15, p. 76 • Problem 1.6
Three examples for producer-consumer • With bounded buffering • Fig. 1.16, p.77 • With unbounded buffering • But the channel should never hold more than N pending message • Fig. 1.17, p.78 • Conditional communication statement • An additional statement
Conditional communication statement • Conditional send and receive • P. 79 • Async communication • Sync communication • Example: Prod-cons without buffering • Fig. 1.19, p. 81 • Problem 1.7
Comparison of sync and async models • We could implement an async problem, using sync constructs • By introducing a process as a channel • Sync communication is a more primitive concept than async (is it?) • We need some “ack” channel, like in Fig. 1.17 • ( extended Rebeca)
A Fair Server • There is a single process, server S, that is expected to provide services to N customer processes, called P[1], …, P[N]. • The server can serve only one customer at a time. • A fair server using shared variables, Fig. 1.20 p.84 • A fair server using message passing, Fig. 1.21 p.85 • It is different from 1.20
1.11 Model 4: Petri Nets • ∈ΣΠΛΦμθ≠