Title: Design Patterns for DistributedRealTime Systems ::Active Object:: ::Monitor Object::
1Design Patterns forDistributed/Real-TimeSystems
Active ObjectMonitor Object
- Group 5
- Eric Au
- Sandeep Mistry
- Amirsam Khataei
- Ravisangar Sathiyaseelan
2Introduction
- A Design Pattern is a general reusable solution
to a commonly occurring problem in software
design.1 - A Distributed Computing System is a method of
computer processing in which different parts of a
program run simultaneously on two or more
computers that are communicating with each other
over a network. 2 - A Real-Time Computing System is the study of
hardware and software systems which are subject
to a "real-time constraint.3
3Distributed/ Real-Time SystemDesign Pattern
- Its a reusable solution that can be applied
either - A Distributed System
- or
- A Real-Time System
4Active Object
- Intent
- Decouples method execution from method
invocation to enhance concurrency and simplify
synchronized access to an object that resides in
its own thread of control. 4 - This design pattern may also be referred to as
Concurrent Object and Actor
5Structure of an Active Object Design Pattern
6Active Object Sequence Diagram
7Active Object Design Pattern Example - Restaurant
- Customer -gt Client
- Waiter -gt Proxy
8Active Object Design Pattern Example - Restaurant
- Manager -gt Scheduler
- Order Queue -gt Activation Queue
9Active Object Design Pattern Example - Restaurant
- Order -gt Method Request
- Servant -gt Chef
10Active Object Design Pattern Consequences
- Pros
- Enhances concurrency
- Simplifies synchronization
- Method execution order can differ from invocation
order - Cons
- Performance overhead
- Hard to debug
11Active Object Design Pattern Known Uses
- CORBA ORBs
- ACE Framework
- Siemens MedCom
- Siemens Call Center management system
- Actors
12Monitor Object
- Intent
- The Monitor Object pattern synchronizes method
execution to ensure only one method runs within
an object at a time. It also allows an objects
methods to cooperatively schedule their execution
sequences. 5 - This design pattern may also be referred to as
Thread-safe Passive Object.
13Structure of a Monitor Object Design Pattern
14Monitor Object Design Pattern Sequence Diagram
15Monitor Object Design Pattern Example
A monitor is an approach to synchronize two or
more computer tasks that use a shared resource.
Separation of toilet and lock
16Monitor Object Design Pattern Example
- Next people waiting in order of arrival
17Monitor Object Design Pattern Pitfalls
- Calling wait() in unstable state
- Forget to release lock when an exception occurs
- Not making the method synchronized when needed
18Monitor Object Design Pattern Another Example
monitor account int balance 0
function withdraw(int amount) if amount lt 0
then error "Amount may not be negative" else if
balance lt amount then error "Insufficient funds"
else balance balance - amount
function deposit(int amount) if amount lt 0
then error "Amount may not be negative" else
balance balance amount
19Monitor Object Design Pattern Consequences
- Pros
- Simplification of concurrency control
implementation - Simplify synchronization of methods invoked
concurrently on an object - Synchronized methods can cooperatively schedule
their order of execution - Cons
- Concurrency remains complicated
- Tightly coupling between object functionality and
synchronization mechanisms - Nested monitor lockout
- New problems, deadlocks and starvation
20Monitor Object Design Pattern Known Uses
21Conclusion
- Active Object
- Separates method invocation from method
execution. - Monitor Object
- Synchronizes method execution to ensure only one
method runs within an object at a time.
22References
- 1 Wikipedia Design Patterns
- http//en.wikipedia.org/wiki/Design_pattern_(compu
ter_science) - 2 Wikipedia Distributed Computing
- http//en.wikipedia.org/wiki/Distributed_computing
- 3 Wikipedia Real-Time Computing
- http//en.wikipedia.org/wiki/Real-time_system
- 4 Active Object
- http//www.cs.wustl.edu/7Eschmidt/PDF/Act-Obj.pdf
- 5 Active Object Pattern
- http//www.cs.uu.nl/docs/vakken/no/active_object_p
attern.pdf - 6 Monitor Object
- http//www.cs.wustl.edu/schmidt/PDF/monitor.pdf
- 7 Monitor Object Concurrency Pattern
- http//www.cs.uu.nl/docs/vakken/no/monitor20objec
t.pdf
23Thank You