Unit – 6
chapter – 3
Processes and Threads
• In the UML, each independent flow of control is modeled as an
active object.
• An active object is a process or thread that can initiate control
activity.
• As for every kind of object, an active object is
an instance of a class.
• An active object is an instance of an active class.
• Each independent flow of control is modeled as an active
object.
• An active object is a process or thread that can initiate control
activity.
• An active object is an object that owns a
process or thread and can initiate control
activity. An active class is a class whose
instances are active objects.
• A process is a heavyweight flow that can
execute concurrently with other processes.
• A thread is a lightweight flow that can execute
concurrently with other threads within the
same process.
Flow control
• In a purely sequential system, there is one
flow of control. This means that one thing,
and one thing only, can take place at a time.
• When a sequential program starts, control is
rooted at the beginning of the program and
operations are dispatched one after another.
Classes and events
• Active classes are just classes, albeit ones with a
very special property.
• An active class represents an independent flow
of control, whereas a plain class embodies no
such flow.
• You use active classes to model common
families of processes or threads.
• Active classes share the same properties as all
other classes. Active classes may have instances.
Standard Elements
Communication
• When objects collaborate with one another, they interact by passing
messages from one to the other.
• In a system with both active and passive objects, there are four
possible combinations of interaction that you must consider.
• First, a message may be passed from one passive object to another.
• Second, a message may be passed from one active object to another.
• 1. one active object might synchronously call an operation of another.
• 2. one active object might asynchronously send a signal or call an
operation of another object.
• Third, a message may be passed from an
active object to a passive object.
• Fourth, a message may be passed from a
passive object to an active one.
Communication
Synchronization
• The problem arises when more than one flow of control is
in one object at the same time.
• If you are not careful, anything more than one flow will
interfere with another , corrupting the state of the object.
• There are three alternatives to this approach, each of
which involves attaching certain synchronization
properties to the operations defined in a class. In the
UML, you can model all three approaches.
• Sequential : Callers must coordinate outside the
object so that only one flow is in the object at a
time.
• Gaurded : The semantics and integrity of the object
is guaranteed in the presence of multiple flows of
control by sequentializing all calls to all of the
object's guarded operations.
• Concurrent : The semantics and integrity of the
object is guaranteed in the presence of multiple
flows of control by treating the operation as atomic.
synchronization
Process Views
• Active objects play an important role in visualizing,
specifying, constructing, and documenting a system's
process view.
• The process view of a system encompasses the threads
and processes that form the system's concurrency and
synchronization mechanisms.
• This view primarily addresses the performance,
scalability, and throughput of the system.
Common modeling techniques
- modeling multiple flows of control
• Identify the opportunities for concurrent action
and reify each flow as an active class.
• Consider a balanced distribution of
responsibilities among these active classes, then
examine the other active and passive classes
with which each collaborates statically.
• Capture these static decisions in class diagrams,
explicitly highlighting each active class.
• Consider how each group of classes
collaborates with one another dynamically.
• Pay close attention to communication among
active objects. Apply synchronous and
asynchronous messaging, as appropriate.
• Pay close attention to synchronization among
these active objects and the passive objects
with which they collaborate.
Process View of a trading System
Modeling Interprocess communication
• Model the multiple flows of control.
• Consider which of these active objects represent processes
and which represent threads.
• Distinguish them using the appropriate stereotype.
• Model messaging using asynchronous communication; model
remote procedure calls using synchronous communication.
• Informally specify the underlying mechanism for
communication by using notes, or more formally by using
collaborations.
Modeling interprocess communication