Design Patterns For Distributed/real-time Systems:::active Object::::monitor Object:

  • Uploaded by: ANKIT AGG
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Design Patterns For Distributed/real-time Systems:::active Object::::monitor Object: as PDF for free.

More details

  • Words: 635
  • Pages: 23
Design Patterns for Distributed/Real-Time Systems ::Active Object:: ::Monitor Object:: 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]

Distributed/ 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

Structure of an Active Object Design Pattern

Active Object Sequence Diagram

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

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.

Structure of a Monitor Object Design Pattern Client Monitor +synchronized method_1()() +synchronized method_2()() 1

1

Client2 * MonitorCondition +notify()() +release()()

MonitorLock +acquire()() +release()()

Monitor Object Design Pattern Sequence Diagram

Monitor Object Design Pattern Example

• Free toilet

A monitor is an approach to synchronize two or more computer tasks that use a shared resource.

Separation of toilet and lock

Monitor Object Design Pattern Example

• Next people waiting in order of arrival

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.

References • [1] Wikipedia: Design Patterns – http://en.wikipedia.org/wiki/Design_pattern_(computer_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_pattern.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/monitor%20object.pdf

Thank You

Questions?

Related Documents

Design Patterns
June 2020 16
Design Patterns
May 2020 17
Design Patterns
May 2020 17
Design Patterns
November 2019 29
Design Patterns
April 2020 21
Design Patterns
June 2020 5

More Documents from ""