Rhapsody in C++ Tool Training "Essential" © I-Logix 1999-2000 v3.0 1/29/2001 Adv-1 Section 4 Advanced Level Concurrency.

Slides:



Advertisements
Similar presentations
UML State Machine Diagrams and Modeling
Advertisements

Chapter 24 Lists, Stacks, and Queues
Python Objects and Classes
Essential Rhapsody in C++
Written by: Dr. JJ Shepherd
1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
The Rhapsody in C++ Tool Training "Essential" © I-Logix v2.3 25/9/2000 Bas-1 Essential Rhapsody in C++ Section 2 Basic Level.
Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-1 Section 4 Advanced Mutexes.
1 Chapter 24 Lists Stacks and Queues. 2 Objectives F To design list with interface and abstract class (§24.2). F To design and implement a dynamic list.
The Rhapsody in C++ Tool Training "Essential" © I-Logix v2.3 25/9/2000 EI-1 “Essential” Rhapsody in C++ Introduction.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
© I-Logix Rhapsody C++ V /01/2004 E1-1 Exercise 2 : Count Down.
אביב תשס"ה JCTתיכון תוכנה: ד"ר ראובן גלנט1 פרק 8 נקודות חשובות בתרגילים 7-9.
© Andy Wellings, 2004 Roadmap  Introduction  Concurrent Programming  Communication and Synchronization  Completing the Java Model  Overview of the.
The Rhapsody in C++ Tool Training "Essential" © I-Logix v2.3 25/9/2000 Adv-1 Essential Rhapsody in C++ Section 4 Advanced Level Modified.
Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Int-1 Section 3 Intermediate Inherited Sensor.
© Copyright Eliyahu Brutman Programming Techniques Course.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment Chapter 8: Implementing and Managing Printers.
Multithreading in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
© I-Logix Rhapsody C++ V /01/2004 E1-1 Exercise 3 : Dishwasher.
Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-1 Essential Rhapsody in C++ Section 4 Advanced Level.
The Rhapsody in C++ Tool Training "Essential" © I-Logix v2.3 25/9/2000 Int-1 Essential Rhapsody in C++ Section 3 Intermediate Level.
Presentation Outline What is JUnit? Why Use JUnit? JUnit Features Design of JUnit Downloading JUnit Writing Tests – TestCase – TestSuite Organizing The.
OOP Week 3 1 Object Oriented Programming in Java Monday, Week 3 Interface PinBallTarget OOP Concepts Last Week’s Assignment Arrays Collection Class --
Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-1 Section 4 Advanced Level Multiplicity.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. The Factory Method Design Pattern (1) –A creational design.
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
1 I-Logix Professional Services Specialist Rhapsody IDF (Interrupt Driven Framework) CPU External Code RTOS OXF Framework Rhapsody Generated.
Nachos Phase 1 Code -Hints and Comments
Design patterns. What is a design pattern? Christopher Alexander: «The pattern describes a problem which again and again occurs in the work, as well as.
1 JavaScript. 2 What’s wrong with JavaScript? A very powerful language, yet –Often hated –Browser inconsistencies –Misunderstood –Developers find it painful.
Advanced Programming Rabie A. Ramadan 7.
Chapter 15: Advanced Topics: Introducing Data Structures and Recursion Visual Basic.NET Programming: From Problem Analysis to Program Design.
1 CSC 222: Computer Programming II Spring 2004 See online syllabus at: Course goals:
1 Web Based Programming Section 8 James King 12 August 2003.
The Rhapsody in C++ Tool Training "Essential" © I-Logix v2.3 25/9/2000 Adv-1 Essential Rhapsody in C++ Section 4 Advanced Level.
1 Chapter 17 Object-Oriented Data Structures. 2 Objectives F To describe what a data structure is (§17.1). F To explain the limitations of arrays (§17.1).
Design Analysis builds a logical model that delivers the functionality. Design fully specifies how this functionality will be delivered. Design looks from.
Design Patterns Gang Qian Department of Computer Science University of Central Oklahoma.
The Strategy Pattern SE-2811 Dr. Mark L. Hornick 1 Class 1-2.
Concurrent Programming and Threads Threads Blocking a User Interface.
By: David Harel & Eran Grey Presenter: Elizabeth Antony CISC 836.
Programming in Java CSCI-2220 Object Oriented Programming.
Multithreading in Java Sameer Singh Chauhan Lecturer, I. T. Dept., SVIT, Vasad.
Design Patterns -- Omkar. Introduction  When do we use design patterns  Uses of design patterns  Classification of design patterns  Creational design.
SE-2811 Software Component Design Week 1, Day 2 (and 1-3 and 2-1) SE-2811 Dr. Josiah Yoder Slide style: Dr. Hornick 1.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 26 - Java Object-Based Programming Outline 26.1Introduction.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Class Builder Tutorial Presented By- Amit Singh & Sylendra Prasad.
Design Patterns David Talby. This Lecture Re-routing method calls Chain of Responsibility Coding partial algorithms Template Method The Singleton Pattern.
The Strategy Pattern SE-2811 Dr. Mark L. Hornick 1.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
Chapter11 Concurrent. 集美大学 计算机工程学院 Java 程序设计 年 第二版 Concurrent ●Computer users take it for granted that their systems can do more than one thing.
Classes, Interfaces and Packages
© I-Logix Rhapsody C++ V /01/2004E1-1 “Essential” Tool Training Basic Rhapsody Basic Rhapsody Rhapsody in C++ V /01/04.
Written by: Dr. JJ Shepherd
Session 7 Introduction to Inheritance. Accumulator Example a simple calculator app classes needed: –AdderApp - contains main –AddingFrame - GUI –CloseableFrame.
L10: Model-View-Controller General application structure. User Interface: Role, Requirements, Problems Design patterns: Model – View – Controller, Observer/Observable.
1 Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
Fusion Design Overview Object Interaction Graph Visibility Graph Class Descriptions Inheritance Graphs Fusion: Design The overall goal of Design is to.
Concurrent Programming in Java Based on Notes by J. Johns (based on Java in a Nutshell, Learning Java) Also Java Tutorial, Concurrent Programming in Java.
Generator Design Patterns: Singleton and Prototype
A brief intro to: Parallelism, Threads, and Concurrency
Group 4 Anders Linseth Magdalena Lipska Nicolai Friis Tobias Melcher
Chapter 17 Object-Oriented Data Structures
Advanced Java Programming
CS 350 – Software Design Singleton – Chapter 21
Lecture 19 Threads CSE /6/2019.
Essential Rhapsody in C++
Presentation transcript:

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-1 Section 4 Advanced Level Concurrency

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-2 Code Generation Per Package Generated code for each package can be directed into separate directories:

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-3 Concurrency We want each Sensor to run on its own thread (active class). To do so, we need each Sensor to be Reactive (class that waits for events). So we will create a Statechart for the base Sensor class as follows:

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-4 Active Classes With the browser, change the concurrency of the Sensor class from sequential to active.

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-5 Inheriting Behavior Open the Statecharts for the PressureSensor and TemperatureSensor. Note that they have inherited the base class Statechart. Specialize the behavior of the TemperatureSensor as below: Grayed out indicating inherited behavior

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-6 Starting the Behavior Add a call to startBehavior() from the TemperatureSensor and PressureSensor constructors to initialize the statecharts. If we had used a composite class, Rhapsody would have done this for us, but that would have been too easy !

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-7 Multi-threads Save / Generate / Make / Run Check that there are four active threads. Setting the focus to a particular thread displays the call stack and event queue for that thread. There will always be one thread called mainThread.

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-8 Suspending Threads Note that a thread can be suspended.

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-9 Extended Exercise I Add two new operations to the Motor class deleteSensor & addSensor

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-10 Extended Exercise II Modify the Motor Statechart to add two static reactions in state for evAdd and evDelete.

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-11 Extended Exercise III Save / Generate/Make/Run Inject events evAdd and evDelete Note that threads are created & deleted.

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-12 Extended Exercise IV Try adding a SpeedSensor that is a new type of Sensor.

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-13 Problems with the Design With the current design there are a few potential problems: –The Motor class needs to know about all the different types of Sensor. –If another class wants access to the Sensors, it too will need to depend upon all the different types of Sensor. –Starting the behavior of a Sensor, in the constructor is not very elegant. –Adding a new type of Sensor means finding and modifying all classes that use Sensor.

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-14 Improving the Design Using the “factory method design pattern” will solve all these concerns. A SensorFactory class can be introduced that is used by all classes ( ex: Motor ) that need to get a Sensor. This decouples the Motor class from the actual Sensors and can also start the behavior of the Sensors. The SensorFactory will be implemented using the “Singleton design pattern” (to ensure that there is only one instance of SensorFactory). See the “SensorFactory” example.

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-15 The Improved Design

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-16 The Singleton Design Pattern I Protected constructor Static attribute

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-17 The Singleton Design Pattern II Static factory operation Calling the createRandomSensor operation

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-18 More Design Improvements In all the constructors of the sensors passing a string by value is not very efficient, it would be better to pass a reference to a string.

Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-19 Setting Priority, Stack Size,... For an active class, the stack size, priority, name, etc can be set through the following properties: