1 advanced behavioral model part 1: processes and threads part 2: time and space chapter22~23...

18
1 Advanced Behavioral Advanced Behavioral Model Model Part 1: Processes and Threads Part 1: Processes and Threads Part 2: Time and Space Part 2: Time and Space Chapter22~23 Chapter22~23 Speaker: Speaker: 陳 陳 陳 陳 陳 陳 Real-time and Embedded System Lab Real-time and Embedded System Lab 10 Oct. 2002 10 Oct. 2002

Upload: walter-morris

Post on 04-Jan-2016

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Advanced Behavioral Model Part 1: Processes and Threads Part 2: Time and Space Chapter22~23 Speaker: 陳 奕 全 Real-time and Embedded System Lab 10 Oct

11

Advanced Behavioral Model Advanced Behavioral Model Part 1: Processes and ThreadsPart 1: Processes and Threads

Part 2: Time and SpacePart 2: Time and Space

Chapter22~23Chapter22~23

Speaker: Speaker: 陳 奕 全陳 奕 全Real-time and Embedded System LabReal-time and Embedded System Lab

10 Oct. 200210 Oct. 2002

Page 2: 1 Advanced Behavioral Model Part 1: Processes and Threads Part 2: Time and Space Chapter22~23 Speaker: 陳 奕 全 Real-time and Embedded System Lab 10 Oct

22

OutlineOutline

• IntroductionIntroduction• Active object and passive object Active object and passive object • Communication and SynchronizationCommunication and Synchronization• Modeling multiple flows of control and Modeling multiple flows of control and

Inter-process communication Inter-process communication • Time and spaceTime and space• Modeling timing constraintModeling timing constraint• Modeling distribution of object and objects Modeling distribution of object and objects

that migratethat migrate

Page 3: 1 Advanced Behavioral Model Part 1: Processes and Threads Part 2: Time and Space Chapter22~23 Speaker: 陳 奕 全 Real-time and Embedded System Lab 10 Oct

33

IntroductionIntroduction

• How to model a system of the real world?How to model a system of the real world?– Process view Process view

• The processes and threads: form the system’s concurrency The processes and threads: form the system’s concurrency and synchronization mechanismand synchronization mechanism

• Why need communication and synchronization?Why need communication and synchronization?– Share certain resourcesShare certain resources

• Ex, If hundreds of people work in the same building. All must Ex, If hundreds of people work in the same building. All must share the same facilitiesshare the same facilities

• In UML, an active object help us to synchronize In UML, an active object help us to synchronize the interactions among independent flowsthe interactions among independent flows

Page 4: 1 Advanced Behavioral Model Part 1: Processes and Threads Part 2: Time and Space Chapter22~23 Speaker: 陳 奕 全 Real-time and Embedded System Lab 10 Oct

44

Active object and passive Active object and passive object object • Active object: is an object that owns a Active object: is an object that owns a

process or thread and can initiate control process or thread and can initiate control activityactivity– Process: is a heavyweight flow that can execute Process: is a heavyweight flow that can execute

concurrently.concurrently.• Stereotype: processStereotype: process

– Threads: is a lightweight flow that can execute Threads: is a lightweight flow that can execute concurrently within the same processconcurrently within the same process• Stereotype: threadStereotype: thread

• Passive object: cannot initiate control activityPassive object: cannot initiate control activity

Page 5: 1 Advanced Behavioral Model Part 1: Processes and Threads Part 2: Time and Space Chapter22~23 Speaker: 陳 奕 全 Real-time and Embedded System Lab 10 Oct

55

Active object and passive Active object and passive object (Cont.)object (Cont.)

• In a purely sequential system:In a purely sequential system:– Only one flow of control (one thing only Only one flow of control (one thing only

can take place at a time)can take place at a time)– Execution flow from one statement to Execution flow from one statement to

another, in sequential orderanother, in sequential order– If there is any recursion, iteration, If there is any recursion, iteration,

branch, loop and jump, the flow circle branch, loop and jump, the flow circle back on itselfback on itself

Page 6: 1 Advanced Behavioral Model Part 1: Processes and Threads Part 2: Time and Space Chapter22~23 Speaker: 陳 奕 全 Real-time and Embedded System Lab 10 Oct

66

Active object and passive Active object and passive object (Cont.)object (Cont.)

• In a concurrent system:In a concurrent system:– More than one flow of control (more than onMore than one flow of control (more than on

w thing can take place at a time)w thing can take place at a time)– Each flow of control root at the head of an iEach flow of control root at the head of an i

ndependent process or threadndependent process or thread• In UML, an active class represents a procIn UML, an active class represents a proc

ess or thread and that is concurrent with ess or thread and that is concurrent with all peer flows of controlall peer flows of control

Page 7: 1 Advanced Behavioral Model Part 1: Processes and Threads Part 2: Time and Space Chapter22~23 Speaker: 陳 奕 全 Real-time and Embedded System Lab 10 Oct

77

Communication Communication andand synchronizationsynchronization• Communication: objects interact by passing Communication: objects interact by passing

messages from one to the othermessages from one to the other• Four possible combinations of interaction:Four possible combinations of interaction:

– Passive object to passive objectPassive object to passive object• Assuming there is only one flow of control passing through Assuming there is only one flow of control passing through

these objects at a timethese objects at a time– Active object to active objectActive object to active object

• Inter-process communication Inter-process communication – Synchronously callSynchronously call– Asynchronously callAsynchronously call

– Active object to passive objectActive object to passive object

– Passive object to passive objectPassive object to passive object

Page 8: 1 Advanced Behavioral Model Part 1: Processes and Threads Part 2: Time and Space Chapter22~23 Speaker: 陳 奕 全 Real-time and Embedded System Lab 10 Oct

88

Communication Communication andand synchronization (Cont.)synchronization (Cont.)

• When more than one flow of control is in one oWhen more than one flow of control is in one object at same timebject at same time– Mutual exclusion Mutual exclusion

• In UML, there are three alternatives to achieve In UML, there are three alternatives to achieve critical region:critical region:– Sequential: only one flow is in the object at a timeSequential: only one flow is in the object at a time– Guarded: sequentializing all calls to all guarded opGuarded: sequentializing all calls to all guarded op

erations to ensure semantics and integrityerations to ensure semantics and integrity– Concurrent: the presence of multiple flows of contrConcurrent: the presence of multiple flows of contr

ol by treating the operation as atomicol by treating the operation as atomic

Page 9: 1 Advanced Behavioral Model Part 1: Processes and Threads Part 2: Time and Space Chapter22~23 Speaker: 陳 奕 全 Real-time and Embedded System Lab 10 Oct

99

Modeling multiple flows of Modeling multiple flows of control and Inter-process control and Inter-process communicationcommunication• Common modeling techniques: chapter Common modeling techniques: chapter

22, page 317~32022, page 317~320• Figure 22-4: Modeling flows of controlFigure 22-4: Modeling flows of control

Page 10: 1 Advanced Behavioral Model Part 1: Processes and Threads Part 2: Time and Space Chapter22~23 Speaker: 陳 奕 全 Real-time and Embedded System Lab 10 Oct

1010

Modeling multiple flows of Modeling multiple flows of control and Inter-process control and Inter-process communication (Cont.)communication (Cont.)• Figure 22-5: Modeling inter-process Figure 22-5: Modeling inter-process

communicationcommunication

Page 11: 1 Advanced Behavioral Model Part 1: Processes and Threads Part 2: Time and Space Chapter22~23 Speaker: 陳 奕 全 Real-time and Embedded System Lab 10 Oct

1111

Time and SpaceTime and Space

• Frictionless environment Frictionless environment – Messages are sent in zero timeMessages are sent in zero time– Network never go downNetwork never go down– Workstations never failWorkstations never fail– And so onAnd so on

• But the real world doesn’t work that wayBut the real world doesn’t work that way– Have to take into account the issues of time and spaceHave to take into account the issues of time and space

• To represent the modeling needs of real-time and To represent the modeling needs of real-time and distributed systems, the UML provides a graphic distributed systems, the UML provides a graphic representation for timing marks, time representation for timing marks, time expressions, timing constraints, and location expressions, timing constraints, and location

Page 12: 1 Advanced Behavioral Model Part 1: Processes and Threads Part 2: Time and Space Chapter22~23 Speaker: 陳 奕 全 Real-time and Embedded System Lab 10 Oct

1212

Time and Space (Cont.)Time and Space (Cont.)

• Timing mark:Timing mark:– A denotation for the time at which an A denotation for the time at which an

event occursevent occurs– Graphically, it is formed as an expression Graphically, it is formed as an expression

from the name given to the messagefrom the name given to the message

• Time expression:Time expression:– is an expression that evaluates to an is an expression that evaluates to an

absolute or relative value of timeabsolute or relative value of time

Page 13: 1 Advanced Behavioral Model Part 1: Processes and Threads Part 2: Time and Space Chapter22~23 Speaker: 陳 奕 全 Real-time and Embedded System Lab 10 Oct

1313

Time and Space (Cont.)Time and Space (Cont.)

• Timing constraint:Timing constraint:– Is a semantic statement about the Is a semantic statement about the

relative or absolute value of timerelative or absolute value of time

• Location:Location:– Is the placement of a component on a Is the placement of a component on a

nodenode

Page 14: 1 Advanced Behavioral Model Part 1: Processes and Threads Part 2: Time and Space Chapter22~23 Speaker: 陳 奕 全 Real-time and Embedded System Lab 10 Oct

1414

Time and Space (Cont.)Time and Space (Cont.)

• Figure 23-1: timing constraints and locationFigure 23-1: timing constraints and location

Page 15: 1 Advanced Behavioral Model Part 1: Processes and Threads Part 2: Time and Space Chapter22~23 Speaker: 陳 奕 全 Real-time and Embedded System Lab 10 Oct

1515

Modeling timing constraintModeling timing constraint

• Figure 23-4: modeling timing constraintFigure 23-4: modeling timing constraint

Page 16: 1 Advanced Behavioral Model Part 1: Processes and Threads Part 2: Time and Space Chapter22~23 Speaker: 陳 奕 全 Real-time and Embedded System Lab 10 Oct

1616

Modeling distribution of object Modeling distribution of object and objects that migrateand objects that migrate• Consider the physical placement of both components and Consider the physical placement of both components and

class instancesclass instances

• Figure 23-5:Modeling the distribution of objectsFigure 23-5:Modeling the distribution of objects

Page 17: 1 Advanced Behavioral Model Part 1: Processes and Threads Part 2: Time and Space Chapter22~23 Speaker: 陳 奕 全 Real-time and Embedded System Lab 10 Oct

1717

Modeling distribution of object Modeling distribution of object and objects that migrate and objects that migrate (Cont.)(Cont.)• Certain classes of distributed Certain classes of distributed

systems will movesystems will move– Two reasons:Two reasons:

• In order to move closer to actors and other In order to move closer to actors and other objects they need to work with to do their objects they need to work with to do their job betterjob better

• In response to the failure of a node or In response to the failure of a node or connection or to balance the load across connection or to balance the load across multiple nodes. multiple nodes.

Page 18: 1 Advanced Behavioral Model Part 1: Processes and Threads Part 2: Time and Space Chapter22~23 Speaker: 陳 奕 全 Real-time and Embedded System Lab 10 Oct

1818

Modeling distribution of object Modeling distribution of object and objects that migrate and objects that migrate (Cont.)(Cont.)• Figure 23-6 : Modeling objects that migrateFigure 23-6 : Modeling objects that migrate