You are on page 1of 29

CSE 6255

Advanced Internet Computing


Lecture 1: Concurrency Theory

Summer – 2012 | Hasan Mahmud | hasan@iut-dhaka.edu


Contents
• Introduction to concurrency theory
• Models of Concurrency
• Calculus of Communicating Systems (CCS)
– Syntax of CCS
– Operation semantics of CCS
– SOS : Structured Operational Semantics
– Behavioral equivalence
• Introduction to π-calculus

CSE 6255 | Advanced Internet Computing 2


Concurrency Theory …
• In a computing environment concurrent execution of
processes is a critical part to be considered.
• A concurrent system consists of multiple agents
(processes) that interact among each other
• Some fundamental concurrent systems are:
– Reactive system
– Synchronous communicating system
– Mobile system

CSE 6255 | Advanced Internet Computing 3


Concurrency Theory …
• Reactive system : a system that computes by reacting to stimuli from the computing
environment.
– operating systems
– communication protocols
– control programs
– software running in embedded system devices like mobile telephones
– A sequential program can be viewed as a reactive system that interacts only at the beginning and
at the end of the computation
• Synchronous communicating system
– Client – Server computing
• Mobile system
• Internet can be a complex scenario where computation may require the combination of
these concurrent systems.
• Concurrency theory gives an abstraction for modeling and verification of such concurrent
systems.
CSE 6255 | Advanced Internet Computing 4
Models of concurrency
• Formal Models to describe and analyze concurrent systems.
• As other models of reality, these models must be
– be simple
– be expressive
– be formal
– provide reasoning techniques.
• Concurrent computation is usually
– Non-Terminating
– Reactive (or Interactive)
– Nondeterministic (Unpredictable).
• Some well established model of concurrency:
– CCS (Synchronous communication)
– π-calculus (CCS Extension to Mobility)
– Petri Nets (Like Automata)
CSE 6255 | Advanced Internet Computing 5
Process algebras
• Mathematical models for concurrent communicating
processes which can be defined by Structural Operational
Semantics.
• Process = system with a specified behavior
• Process calculus is a specification language for reactive
systems
– Algebra: collection of (basic processes and) operations for building new
processes from existing ones
• In the process calculus the structure of terms represent the
structure of processes. E.g. P | Q
• Operational Semantics to represent computational steps. E.g.
P  P
PAR
P | Q  P | Q
CSE 6255 | Advanced Internet Computing 6
Communication
• Communication: Information exchange between the
producer of information (sender) and the consumer
(receiver)
• Communication medium
– Buffers, shared variables, tuple spaces, …
• Idea: no need to distinguish between active
components (senders/receivers) and passive ones
(communication media)
– Everything is a process
– Interaction via message passing, modeled as synchronized
communication
CSE 6255 | Advanced Internet Computing 7
Calculus of Communicating Systems (CCS)

• CCS is a kind of process algebra in the approach to concurrency


theory.
• CCS has Introduced by [Milner 1980]
• Milner’s general model:
– A concurrent system is a collection of processes.
– A process is an independent agent that may perform internal activities
in isolation or may interact with the environment to perform activities
• Milner’s insight: Concurrent processes have an algebraic
structure
P operation Q ⇒ P operation Q

CSE 6255 | Advanced Internet Computing 8


An example of simple process
• A coffee and tea machine may take an order for either tea or coffee,
accept the appropriate payment, pour the ordered drink, and
terminate:

tea.coin.cup_of_tea.0 + coffee.coin.coin.cup_of_coffee.0

• We have the following elements of syntax:


– Actions: tea, coin, cup_of_tea, etc.
– Sequential composition: the dot “.” (first do action tea, then coin, ...)
– Non-deterministic choice: the plus “+” (either do tea or coffee)
– Terminated process: 0

CSE 6255 | Advanced Internet Computing 9


Execution of the simple process
• When a process executes it performs some action, and
becomes a new process
• The execution of an action a is symbolized by a transition 
a

tea.coin.cup_of_tea.0 + coffee.coin.coin.cup_of_coffee.0

tea
coin.cup_of_tea .0
coin
 cup_of_tea .0
cup_of_tea
  0

CSE 6255 | Advanced Internet Computing 10


CCS process constructions
• CCS process can be considered as a black box which is
identified by an name.
• The process has an interface that describes the collection of
communication ports, also referred to as channels.
• Ports are used for inputting or outputting information by the
processes to perform interactions among them.

coffee CS pub

coin
CSE 6255 | Advanced Internet Computing 11
Syntax of CCS
• Basic principle
– Define atomic processes that model the simplest
possible behavior
• Atomic instruction: assignment (e.g. x:=2 and x:=x+2)
– Define compositionally new operations (building
more complex process behavior from simple ones).
• sequential composition (P1; P2)
• parallel composition (P1 || P2)
• Now e.g. (x:=1 || x:=2); x:=x+2; (x:=x-1 || x:=x+5) is a
process.

CSE 6255 | Advanced Internet Computing 12


The terminal process
• The simplest possible behavior is no behavior
- the process that does nothing.
• We write 0 (pronounced “nil”) for the terminal
or inactive process
• 0 models a system that is either deadlocked or
has terminated
• 0 is the only atomic process of CCS

CSE 6255 | Advanced Internet Computing 13


Names and Actions
• We assume an infinite set A of port names, and a set Ᾱ = { ā |
a ∈ A} of complementary port names
• Input actions
– When modeling we use a name a to denote an input action, i.e. the
receiving of input from the associated port a
• Output actions
– We use a co-name ā to denote an output action, i.e. the sending of
output to the associated port a
• Internal actions
– We use τ to denote the distinguished internal action
• The set of actions Act is given by Act = A ∪ Ᾱ ∪ {τ}
CSE 6255 | Advanced Internet Computing 14
Action Prefixing
• The simplest actual behavior is sequential behavior
• Action prefixing
– If P is a process we write α.P to denote the prefixing of P with the action α
– α.P models a system that is ready to perform an action α and then behave
like P, i.e.
• Clock = tick.Clock α.P 

α
P
– Types of actions:
• ᾱ : send a signal on channel α
• α: receive a signal on channel α
• τ: silent action
– CM = coin.coffee.CM

CSE 6255 | Advanced Internet Computing 15


Action Prefixing…
• A process that starts a timer, performs some
internal computation, and then stops the
timer:
go τ stop .0 stop
go . .stop .0  τ .stop .0 
  0

CSE 6255 | Advanced Internet Computing 16


Process Interface
• The set of input and output actions that a
process P may perform in isolation constitutes
the interface of P
• The interface enumerates the ports that P may
use to interact with the environment
• Example: The interface of the coffee and tea
machine is:
tea, coffee, coin, cup_of_tea, cup_of_coffee

CSE 6255 | Advanced Internet Computing 17


Non-deterministic Choice
• A more advanced sequential behavior is that of alternative be
• If P and Q are processes then we write
P+Q
to denote the non-deterministic choice between P and Q.

• P + Q models a process that can either behave as P


(discarding Q) or as Q (discarding P)
• Example:
– CTM = coin.(coffee.CTM + tea.CTM)

CSE 6255 | Advanced Internet Computing 18


Process constants and recursion
• The most advanced sequential behavior is the recursive
behavior
• Process constants
– A process may be the invocation of a process constant, K ∈
K
• Recursive definition
– If K is a process constant and P is a process we write

to give a recursive definition of the behavior of K (recursive if


P invokes K)
CSE 6255 | Advanced Internet Computing 19
Example: process constants and recursion

• we may define the behavior of an everlasting


clock as:

CSE 6255 | Advanced Internet Computing 20


Example: process constants and recursion..
• As another recursive process specification, consider that of a
simple coffee
• A fully automatic coffee and tea machine CTM works as follows:

CSE 6255 | Advanced Internet Computing 21


Parallel Composition
• Parallel composition exposes the concurrent behavior
• If P and Q are processes then we write
P|Q
to denote the parallel composition of P and Q.
• P |Q models a process that behaves like P and Q in
parallel:
– Each may proceed independently
– If P is ready to perform an action a and Q is ready to perform the
complementary action ā, they may interact

CSE 6255 | Advanced Internet Computing 22


Example: parallel composition
• Recall the coffee and tea machine:

• Now consider the regular customer – the Computer Scientist, CS:

• CS must drink coffee to publish


• CS can only teach on tea

CSE 6255 | Advanced Internet Computing 23


Example: parallel composition
• On an average Tuesday morning the system
CTM | CS
is likely to behave as follows:

• Note that the synchronization of actions such as tea/tea is


expressed by a τ -action (i.e. regarded as an internal step)
CSE 6255 | Advanced Internet Computing 24
Restriction
• We control unwanted interactions with the environment
by restricting the scope of port names
• if P is a process and A is a set of port names we write

P\A
for the restriction of the scope of each name in A to P
• Removes each name a ∈ A and the corresponding co-
name ā from the interface of P
• Makes each name a ∈ A and the corresponding co-name
ā inaccessible to the environment
CSE 6255 | Advanced Internet Computing 25
Example: Restriction
• Recall the coffee and tea machine and the
computer scientist:
CTM|CS
• Restricting the coffee and tea machine on
coffee makes the coffee-button inaccessible to
the computer scientist:
(CTM \ {coffee}) |CS
• As a consequence CS can only teach, and
never publish
CSE 6255 | Advanced Internet Computing 26
Summary: Syntax of CCS
P :: = K | process constants ( K ∈ K )
α.P | prefixing (α ∈ Act)
P i
| summation (I is an arbitrary index set)
PiI1|P2 | parallel composition
P\L | restriction (L ⊆ A)

• The set of all terms generated by the abstract syntax


is called CCS process expressions
• Notation:

CSE 6255 | Advanced Internet Computing 27


CCS program
• CCS program is a collection of defining equations of the form
K=P def

• where K ∈ K is a process constant and P ∈ P is a CCS


process expression
– Only one defining equation per process constant
– Recursion is allowed: e.g. A = a.A
def | A

– Note that the program itself gives only the definitions of process
constants: we can only execute processes (which can however
mention the process constants defined in the program)

CSE 6255 | Advanced Internet Computing 28


Exercise: Syntax of CCS
• Which of the following expressions are correctly built CCS
expressions?
• Assume that A, B are process constants and that a, b are port
names.
• a.b.A + B 
• (a.0 + ā.A) \ {a, b} 
• (a.0 | ā.A) \ {a, τ} x
• τ.τ.B + 0 
• (a.b.A + ā.0) |B 
• (a.b.A + ā.0).B x

CSE 6255 | Advanced Internet Computing 29

You might also like