310 likes | 502 Views
Dynamic Modeling. for real-time issues other complex systµems also use it. Active Classes and Objects. own an execution thread, i.e. can initiate control activity by own code sending messages can execute concurrently
E N D
Dynamic Modeling • for real-time issues • other complex systµems also use it
Active Classes and Objects • own an execution thread, i.e. can initiate control activity by • own code • sending messages • can execute concurrently • passive class instance can execute only when some other object performs some operation on it (sends a message to it)
Active Class Implementation • typically impl’d as process or thread • class library with • superclass or • interface that can be implemented that maps process/thread operations e.g. start, stop, suspend, resume, priority handling to operating system calls
Active Object Interactions • issues • communication between active objects • usage of shared resources • often package/component controlled by an active object • much more passive than active objects(active need much more resources from the system)
Active Object Internal Structure • internal classes can be both active and passive
Communication • asynchronous • unpredictablean event can occur at any time • synchronous • events can occur only at specified times(can be found when by reading the code) • typical of passive objectsone object sends a message(calls an operation) and waits till that executes (maybe a value is returned (return value))
Communication (2) of active objects • operation call, i.e. synchronous message • mailbox/message queuealso called publish/subscribe modelasynchronous messages • shared memoryaccess to be guarded • rendezvous • RPC (remote procedure call) • calling thread identifies operation in an object • request is furthered to RPC library • RPC finds the object in the network • request is sent over the network • receiving side receives and translates the format and then makes a call • when call is finished, the result is returned in a similar manner
Events and Triggers • event • The specification of a significant occurrence that has a location in time and space and can cause the execution of an associated behavior. In the context of state diagrams, an event is an occurrence that can trigger a transition. • signal • The specification of an asynchronous stimulus that triggers a reaction in the receiver in an asynchronous way and without a reply. The receiving object handles the signal as specified by its receptions. The data carried by a send request and passed to it by the occurrence of the send invocation event that caused the request is represented as attributes of the signal instance. A signal is defined independently of the classifiers handling the signal.
Trigger Types • Changea Boolean expression becomes truee.g. guard condition(triggers even if the expression later becomes false) • Signalreceipt of async signal, i.e.AcceptEventAction • Callof an operation (other’s or own)considered as synchronous message • Timea specified amount of time has passedalso absolute time (e.g. tax-report deadline)
Signals • signala classifier passed between objects for communication • can have attibutes and operations (information, behavior) • passed asynchronously in the system • as a classifier can use Class notation, see e.g. hierarchy of signal classes
Message • objects interact thru messages • can be implemented by • operation call • signal put into a mailbox or a queue
Message Types • reception of message represents an event that can trigger a behaviour kinds • Synchronous • wait semantics, i.e. sender waits for handlingtypically a method call • Reply • shows return message from another message • Create • call of a constructor • Asynchronous • no-wait semantics; no explicit return to caller;allows concurrency
Message Types(cont’d) • Lost • sender is know, but there is no reception • allows dynamic models to be built from fragments • Found • receiver know, but sender is unknown • balking • msg sent only if receiver is ready to accept it • time-out • canceled if not handled within a specified amount of time
Synchronization and Concurrency Issues • incorrect shared access - mutual exclusion necessary • inefficient resource usage • e.g. busy-wait loop • deadlock • starvation – incorrect priority assignment • priority inversion • happens when resources are locked for exclusive use • a lower-priority object holds resources needed by a higher-priority object, i.e. causes stalling/blocking
Synchronization and Concurrency (cont’d) Synchronization mechanisms • Guard mechanisms • semaphores, monitors, critical regions • Scheduling algorithm • Set priorities, other parameters • Supervisor thread • Active objects • priority as tagged value • Concurrency requirements of a class • sequential, guarded, concurrent • stereotype <<semaphore>>
Fault Tolerance ability of system to function in presence of HW and SW failures. A number of techniques to help achieve it • Error and exception handling • built into many languages; can be modeled in activity diagrams, state machines, sequence diagrams; • Multiple Systems • supervisor process monitoring; • Formal proofs • UML ”united with” such methods
Sequence Diagram withTiming Indicator and Constraint • time expression • write-once attibute • t=now • e.g. bid is not accepted after closing time
Sequence Diagram withDurations and Timing Constraints • duration
Streaming Input and Output Example • stream: like a conveyor belt • exception: triangle • {weight=12} indicates that 12 are needed before the next action can execute
House Alarm SystemDetailed Activity Diagram with Message Handling