Real-time Software Design
Design Patterns for Real-Time Systems Guide Faculty Mrs. Barkha Vijh Presented By; kaushik
Mayank
Introduction
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]
Real-Time System Design Pattern It’s a reusable solution that can be applied either A Distributed System or A Real-Time System
Active 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
Architectural considerations
Because of the need to respond to timing demands made by different stimuli/responses, the system architecture must allow for fast switching between stimulus handlers. Timing demands of different stimuli are different so a simple sequential loop is not usually adequate. Real-time systems are therefore usually designed as cooperating processes with a real-time executive controlling these processes.
Active Object Design Pattern Example - Restaurant
Customer -> Client
Waiter -> Proxy
Active Object Design Pattern Example - Restaurant
Manager -> Scheduler
Order Queue -> Activation Queue
Active Object Design Pattern Example - Restaurant
Order -> Method Request
Servant -> Chef
Active Object Design Pattern Consequences
Pro’s • • •
Enhances concurrency Simplifies synchronization Method execution order can differ from invocation order
Con’s
• Performance overhead • Hard to debug
R-T systems design process Design algorithms to process each class of stimulus and response. These must meet the given timing requirements. Design a scheduling system which will ensure that processes arestarted in time to meet their deadlines. Integrate using a real-time operating system.
Active Object Design Pattern Known Uses CORBA ORBs ACE Framework Siemens MedCom Siemens Call Center management system Actors
Monitor 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 object’s methods to cooperatively schedule their execution sequences. “ [5] This design pattern may also be referred to as Thread-safe Passive Object.
Monitor Object Design Pattern Pitfalls Calling wait() in unstable state
Forget to release lock when an exception occurs Not making the method synchronized when needed
Monitor Object Design Pattern Another Example monitor account { int balance := 0 function withdraw(int amount) { if amount < 0 then error "Amount may not be negative" else if balance < amount then error "Insufficient funds" else balance := balance - amount }
}
function deposit(int amount) { if amount < 0 then error "Amount may not be negative" else balance := balance + amount }
Monitor Object Design Pattern Consequences
Pro’s
• Simplification of concurrency control implementation • Simplify synchronization of methods invoked concurrently on an object • Synchronized methods can cooperatively schedule their order of execution
Con’s
• Concurrency remains complicated • Tightly coupling between object functionality and synchronization mechanisms • Nested monitor lockout • New problems, deadlocks and starvation
Monitor Object Design Pattern Known Uses
Java Objects ACE Gateway
Conclusion 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.
Thank You
Questions?