Top Banner
Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321
110

Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Mar 29, 2015

Download

Documents

Noe Henley
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Dr. Thomas HicksComputer Science Department

Trinity University 1

Software EngineeringCSCI 3321

Page 2: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Software Engineering : A Practitioner’s Approach

Agile Development & Real Time Systems

Dr. Thomas E. HicksComputer Science Department

Trinity University

Thanks To Ian Sommerville & Roger Pressman For Much Of The Slide Content

Chapter 4

Page 3: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Agile Development

Lite or Lean Methods

Page 4: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

“We are uncovering better ways of developing software by

doing it and helping others do it. Through this work we

have come to value:

1. Individuals and interactions over processes and tools

2. Working software over

comprehensive documentation

3. Customer collaboration over

contract negotiation

4. Responding to change over following a plan

That is, while there is value in the items on the right, we value

the items on the left more.”

The Manifesto for Agile Software Development

Kent Beck et alKent Beck et alThe_Agile_Manifesto_SDMagazine.pdf

Page 5: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

“Agility 1, Everything Else 0”

TomTomDemarcoDemarco

Page 6: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Politics Agile Software Development

“Considerable Debate about the benefits and applicability”

• Pro Agile : “Traditional methodologies are a bunch of

stick-in-the-muds who’d rather produce flawless

documentation than a working system that meets

business needs.”

• Pro Traditional: “Lightweight, agile methodologists are

a bunch of glorified hackers who are going to be in for a

heck of a surprise when they try to scale up their toys

into enterprise-wide software”

This methodology risks degeneratingThis methodology risks degenerating

into a religious war. into a religious war. Pressman

Page 7: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Ivar Jacobson - 1

“Agility has become today’s buzz word when

considering a modern software process. An agile team

is a nimble team able to appropriately respond to

changes.

Changes in the software being built, changes in the

team members, changes because of new technology,

changes of all kinds that may have impact upon the

product they build or the project that creates the

product.

Page 8: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Ivar Jacobson – 2

Support for changes should be built-in every

thing we do in software, something we embrace

because it is the heart and soul of software.

An agile team recognizes that software is developed by

individuals working in teams and that the skills of

those people, their ability to collaborate, is at the core

for the success of the project.”

Page 9: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

7 Human Factors Of Agile Software Development

Proponents of the Agile Process emphasize the human factors:

1. Competence – innate talent and overall knowledge of the process – teach needed info to all team members

2. Common Focus – the agile team will focus the different talents working on different portions of the project on the deliverable.

3. Collaboration – quality software requires the collaboration & communication of customer & software engineers

4. Decision Making Ability – teams must be able to make those decisions necessary to control their destiny

Pressman

Page 10: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

7 Human Factors Of Agile Software Development

Proponents of the Agile Process emphasize the human factors:

Fuzzy-Problem-Solving-Ability – managers realize teams

deal with ambiguity and change – sometimes must accept

the fact that problem solving today will be different than

problem solving tomorrow – maybe use some of same code.

Mutual Trust & Respect – Agile teams must become what

DeMarco & Lister call “Jelled Teams” – whole greater than

sum of its parts.

Self Organization – self organized to complete work, meet

deadlines, etc. Moral booster.

Pressman

Page 11: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

“There is no substitute for rapid feedback,

both on the developer process and on the

product itself”

Martin Martin FowlerFowler

Page 12: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

12 Principles Adopted By The “Agility Conference” 1-4

1. Highest Priority is to satisfy the customer through early

and continuous delivery of valued software.

2. Welcome change requirements even late in the

development. Agile processes harness change for the

customer’s competitive advantage.

3. Deliver working software frequently, from a couple of

weeks to a couple of months, with a preference to the

shorter time scale.

4. Business people, and developers, must

work together daily throughout the project.

Page 13: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

12 Principles Adopted By The “Agility Conference” 5-8

5. Build projects around motivated individuals. Give them

the environment and the support they need. Trust them to

get the job done.

6. The most efficient and effective method of conveying

information to and within a development team is face to

face conversation.

7. Working software is the primary measure of progress.

8. Agile processes promote sustainable

development. The sponsors, developers,

users should be able to maintain constant

pace indefinitely.

Page 14: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

12 Principles Adopted By The “Agility Conference” 9-12

9. Continual attention to technical excellence and good

design enhances agility.

10. Simplicity, the art of minimizing the amount of work not

done, is essential.

11. The best architectures, requirements, and designs

emerge from self organizing teams.

12. At regular intervals, the team reflects

on how to become more effective, then

tunes and tunes and adjusts its behavior

accordingly.

Page 15: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Agile Lite Less Time Planning Faster Coding

Page 16: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Agility Software Development Research Tells Us That :

Effective response to change; rapid and adaptive

Effective communication among all stakeholders

Drawing the customer onto the team

Organizing a team so that it is in control of the work performed

Yields …

Rapid, incremental delivery of software

Page 17: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

About The Agile Process

Agile Process is driven by customer descriptions of what is required; these descriptions are called scenarios

Agile Process recognizes that plans are short-lived

Agile Process develops software iteratively with a heavy emphasis on construction activities

Agile Process delivers multiple ‘software increments’

Agile Process adapts as changes occur

Page 19: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Extreme Programming (XP)4 Step XP Planning Process

The most widely used agile process, originally proposed

by Kent Beck

XP Planning XP Planning

1. XP Planning begins with the creation of “user stories”

2. An XP Agile team assesses each story and assigns a

cost

3. These XP Stories are grouped to

for a deliverable increment

4. A commitment is made on delivery

date

Page 20: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

About Extreme Programming (XP) DesignXP Design

XP Design follows the KIS principleXP Design encourage the use of CRC cards (see Chapter 8)

Class Responsibility Collaborator

For difficult design problems, XP suggests the immediate creation of “spike solutions”; spikes solutions are an operational design prototype of the problem area.

XP design encourages “refactoring”; refactoring an iterative refinement of the internal program design – it is cleaning up the code after it has been written.

Class:

Description:

Responsibility: Collaborator:

Class:

Description:

Responsibility: Collaborator:

Class:

Description:

Responsibility: Collaborator:

Class: FloorPlan

Description:

Responsibility: Collaborator:

incorporates walls, doors and windows

shows position of video cameras

defines floor plan name/type

manages floor plan positioning

scales floor plan for display

scales floor plan for display

Wall

Camera

Page 21: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

XP Coding

XP coding recommends the construction of a unit test for a story before coding commences

XP coding encourages “pair programming” – two people work together at one computer to complete code for one story.

About Extreme Programming (XP) Coding

Page 22: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

XP Testing

XP testing recommends that all unit tests be executed daily to encourage regression analysis (i.e. to make sure code still works after it has been modified)

“XP testing requires “acceptance tests”, also called “customer tests” that are defined by the customer and executed to assess customer visible functionality

About Extreme Programming (XP) Testing

Page 23: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

“Extreme Programming is a

discipline of software

development based on values

of simplicity, communication, feedback, and

courage.”

RonRonJeffriesJeffries

Page 24: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

ASD

Adaptive Software Development

Page 25: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Adaptive Software Development (ASD)

ASD was originally proposed by Jim Highsmith

6 Distinguishing Features Of ASD 1-3

1. ASD uses mission-driven planning; accomplish the task

2. ASD partitions the project into components; it is a component-based focus

3. Uses “time-boxing” – each task associated with a box; if the project cannot be delivered on time, the work moves forward to the next task when ~90% of the task is complete. Although this is not always acceptable, it is often the case that the last 10% can be completed later.

Page 26: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Adaptive Software Development (ASD)

ASD was originally proposed by Jim Highsmith

6 Distinguishing Features Of ASD – 4-6

4. ASD explicitly considers all of risks

5. ASD emphasizes collaboration for requirements gathering

6. ASD emphasizes “learning” throughout the process

Page 27: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

3 Major Steps of Adaptive Software Development (ASD)

1. Speculation Use the customer mission statement, project

constraints, and basic requirements to define sets of cycles (software releases) for the project.

2. Collaboration The collaboration method is central to all of the agile

processes. Using highly motivated people, working collaboratively together to multiply their talents beyond individual expectations. Trust is central.

Create Requirements and Mini-Specs.

3. Learning Implement and test components Technical Reviews Focus Group Feedback

Page 28: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Adaptive Software Development

ad apt ive cycle planning uses m issio n st at em ent pro ject co nst raint s basic requirem ent s t ime-b ox ed release plan

Requirement s g at hering J A D mini- specs

c omp o nent s implement ed/ t est ed f o cus gro ups f or f eedb ac k f ormal t echnical review s p o st mort ems

s oftw ar e incr ementadj ustm ents f or subsequent cy cles

Release

Page 29: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

“I like to listen. I have learned a great deal from

listening carefully. Most people never

listen.”Ernest Ernest

HemingwayHemingway

Page 30: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

DSDMDynamic Software

Development Method

Page 31: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Dynamic Systems Development Method - DSDM

DSDMDSDM—distinguishing features

Similar in most respects to XP and/or ASD

8 Guiding Principles Of DSDM – 1-4

1. Active user involvement is imperative.

2. DSDM teams must be empowered to make decisions.

3. The focus is on frequent delivery of products.

4. Fitness for business purpose is the essential criterion for acceptance of deliverables.

Promoted by the DSDM Consortium (www.dsdm.org)

Page 32: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Dynamic Systems Development Method - DSDM

8 Guiding Principles Of DSDM 5 - 8

5. Iterative and incremental development is necessary

to converge on an accurate business solution.

6. All changes during development are reversible.

7. Requirements are baselined at a high level

8. Testing is integrated throughout the life-cycle.

Page 33: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Dynamic Systems Development Method

Page 34: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

“Our profession goes through Methodologies like a 14 year-old goes

through clothing”

Stephen Hawrysh & Stephen Hawrysh & Jim RuprechtJim Ruprecht

Page 35: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Scrum

Page 36: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Scrum – (rugby match term)

Developed by Jeff Sutherland in early 1990’s

Expanded upon by Schwaber and Beedle in 2001

Scrum—distinguishing features – very “agile like”

1. Scrum has small teams to maximize communication

and minimize costs

2. The Scrum process must be adaptable to business

and technological changes

3. The Scrum process yields software that can be

inspected, adjusted, tested, documented, and built on.

4. The Scrum process partitions the project

into low-coupling partitions, or “packets”.

Page 37: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Scrum (cont)

5. The Scrum process constantly tests and documents as

the project is built.

6. The Scrum process provides the ability to declare the

product “done”

7. Scrum work occurs in “sprints” and is derived from a

“backlog” of existing requirements

8. Scrum meetings are very short and sometimes

conducted without chairs

9. Scrum “demos” are delivered to the

customer with the time-box allocated

Page 38: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Scrum

http://www.controlchaos.com/about/

Page 39: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

“Scrum allows us to build Software..”

Mike Mike Beetle et al.Beetle et al.

Page 40: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Crystal

Page 41: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Crystal

Proposed by Cockburn and Highsmith

Crystal—distinguishing features

Actually a family of process models that allow “maneuverability” based on problem characteristics

Face-to-face communication is emphasized

Suggests the use of “reflection workshops” to review the work habits of the team

Page 42: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

FDD

Feature Driven Development

Page 43: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Feature Driven Development (FDD)

Originally proposed by Peter Coad et al as a process model for OOP

FDD—distinguishing features

1. Emphasis is on defining “features”

a feature “is a client-valued function that can be implemented in two weeks or less.”

2. Uses a feature template

<action> the <result> <by | for | of | to> a(n) <object>

3. A features list is created and “plan by feature” is conducted

4. Design and construction merge in FDD

Page 44: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Feature Driven Development

Page 45: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Agile Modeling

Page 46: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Agile Modeling

Originally proposed by Scott Ambler

Suggests a set of agile modeling principles

1. Model with a purpose

2. Use multiple models

3. Travel light

4. Content is more important than representation

5. Know the models and the tools you use to create them

6. Adapt locally

Page 47: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Computer World

Computer World Link

http://www.computerworld.com/softwaretopics/software/appdev/story/0,10801,67952,00.html

Page 48: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real TimeSoftware Design

Page 49: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real-time Software Design

Real-time Software Design is designing embedded software systems whose behaviour is subject to timing constraints

Page 50: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real Time Systems

Page 51: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real-time systems

Real-time systems are used to monitor and control their environment

Real-time systems inevitably are associated with hardware devices

Sensors: Collect data from the system environment

Actuators: Change (in some way) the system's environment

Time is critical. Real-time systems MUST respond within specified times

Page 52: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real-time Definitions

A real-time system is a software system where the correct functioning of the system depends on the results produced by the system and the time at which these results are produced

A ‘soft’ real-time system is a system whose operation is degraded if results are not produced according to the specified timing requirements

A ‘hard’ real-time system is a system whose operation is incorrect if results are not produced according to the timing specification

Page 53: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Stimulus &Responses

Page 54: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Stimulus/Response Systems

Given a stimulus, the system must produce a response within a specified time

Periodic Stimuli: Stimuli which occur at predictable time intervals

For example, a temperature sensor may be polled 10 times per second

Aperiodic stimuli: Stimuli which occur at unpredictable times

For example, a system power failure may trigger an interrupt which must be processed by the system

Page 55: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

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 usually designed as cooperating processes with a real-time executive controlling these processes

Page 56: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

A Real-time System Model

Real-timecontrol system

ActuatorActuator ActuatorActuator

SensorSensorSensor SensorSensorSensor

Page 57: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real Time System Elements

Page 58: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real-time System Elements

Sensors control processes

Collect information from sensors. May buffer information collected in response to a sensor stimulus

Data processor

Carries out processing of collected information and computes the system response

Actuator control

Generates control signals for the actuator

Page 59: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Sensor/Actuator Processes

Dataprocessor

Actuatorcontrol

Actuator

Sensorcontrol

Sensor

Stimulus Response

Page 60: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real Time DesignHardware & Software

Page 61: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real-time System Design – 2 Stages

Real-time system engineers must design both the hardware and the software associated with system.

Real-time system engineers then partition functions to either hardware or software

Design decisions should be made on the basis on non-functional system requirements

Hardware delivers better performance but potentially longer development and less scope for change

Page 62: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Hardware & Software Design

Establish systemrequirements

Partitionrequirements

Hardwarerequirements

Hardwaredesign

Softwarerequirements

Softwaredesign

Page 63: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

R-T Systems Design Process – 6 Steps

1. The first step in the R-T design process is to identify the stimuli to be processed and the required responses to these stimuli

2. The second step in the R-T design process is to identify the timing constraints for each stimulus and response

3. The third step in the R-T design process is to aggregate the stimulus and response processing into concurrent processes. A process may be associated with each class of stimulus and response.

Page 64: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

The fourth step in the R-T design process is to design algorithms for each concurrent process. These must meet the given timing requirements

The fifth step in the R-T design process is to design a scheduling system which will ensure that processes are started in time to meet their deadlines

The sixth step in the R-T design process is to integrate the real-time executive with an operating system (if necessary)

R-T Systems Design Process – 6 Steps

Page 65: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real Time Timing Constraints

Page 66: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Timing Constraints

Meeting timing constraints may require extensive simulation and experiment to ensure that these are met by the system

Meeting timing constraints may mean that certain design strategies such as object-oriented design cannot be used because of the additional overhead involved

Meeting timing constraints may mean that low-level programming language features have to be used for performance reasons

Page 67: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real Time State Machines

Page 68: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

State Machine Modelling

The effect of a stimulus in a real-time system may trigger a transition from one state to another.

Finite state machines can be used for modelling real-time systems.

However, FSM models lack structure. Even simple systems can have a complex model.

The UML includes notations for defining state machine models

Page 69: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Microwave Oven State Machine

Full power

Enabled

do: operateoven

Fullpower

Halfpower

Halfpower

Fullpower

Number

TimerDooropen

Doorclosed

Doorclosed

Systemfault

Start

do: set power = 600

Half powerdo: set power = 300

Set time

do: get numberexit: set time

Disabled

Operation

Timer

Cancel

Waiting

do: display time

Waiting

do: display time

do: display 'Ready'

do: display 'Waiting'

Page 70: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real Time Programming

Page 71: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real-time Programming & Languages

Hard-real time systems may have to programmed in assembly language to ensure that deadlines are met

Languages such as C allow efficient programs to be written but do not have constructs to support concurrency or shared resource management

Ada as a language designed to support real-time systems design so includes a general purpose concurrency mechanism

Page 72: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Java As a Real-time Language

Java supports lightweight concurrency (threads and synchronized methods) and can be used for some soft real-time systems

Java 2.0 is not suitable for hard RT programming or programming where precise control of timing is required

1. Not possible to specify thread execution time

2. Uncontrollable garbage collection

3. Not possible to discover queue sizes for shared resources

4. Variable virtual machine implementation

5. Not possible to do space or timing analysis

Page 73: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real Time Executives

Page 74: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real-time Executives

Real-time executives are specialized operating systems which manage the processes in the RTS

Real-time executives are responsible for process management and resource (processor and memory) allocation

Real-time executives may be based on a standard RTE kernel which is used unchanged or modified for a particular application

Real-time executives do not include facilities such as file management

14

Page 75: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

R-T Executive Components

Real-time clock

Provides information for process scheduling.

Interrupt handler

Manages aperiodic requests for service.

Scheduler

Chooses the next process to be run.

Resource manager

Allocates memory and processor resources.

Dispatcher

Starts process execution.

Page 76: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

R-T Non-stop System Components

Configuration manager

Responsible for the dynamic reconfiguration of the system software and hardware. Hardware modules may be replaced and software upgraded without stopping the systems

Fault manager

Responsible for detecting software and hardware faults and taking appropriate actions (e.g. switching to backup disks) to ensure that the system continues in operation

Page 77: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real-time Executive Components

Process resourcerequirements

Scheduler

Schedulinginformation

Resourcemanager

Despatcher

Real-timeclock

Processesawaitingresources

Readylist

Interrupthandler

Availableresource

list

Processorlist

Executingprocess

Readyprocesses

Releasedresources

Page 78: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real Time Process Priority & Servicing

Page 79: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

R-T Process Priority

The processing of some types of stimuli must sometimes take priority

Interrupt level priority. Highest priority which is allocated to processes requiring a very fast response

Clock level priority. Allocated to periodic processes

Within these, further levels of priority may be assigned

Page 80: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

R-T Interrupt Servicing

Control is transferred automatically to a pre-determined memory location

This location contains an instruction to jump to an interrupt service routine

Further interrupts are disabled, the interrupt serviced and control returned to the interrupted process

Interrupt service routines MUST be short, simple and fast

Page 81: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

R-T Periodic Process Servicing

In most real-time systems, there will be several classes of periodic process, each with different periods (the time between executions), execution times and deadlines (the time by which processing must be completed)

The real-time clock ticks periodically and each tick causes an interrupt which schedules the process manager for periodic processes

The process manager selects a process which is ready for execution

Page 82: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real Time Process Management

Page 83: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

R-T Process Management

Concerned with managing the set of concurrent processes

Periodic processes are executed at pre-specified time intervals

The executive uses the real-time clock to determine when to execute a process

Process period - time between executions

Process deadline - the time by which processing must be complete

Page 84: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

R-T Process Management

Resource manager

Allocate memoryand processor

Scheduler

Choose processfor execution

Despatcher

Start execution on anavailable processor

Page 85: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Process Switching

The scheduler chooses the next process to be executed by the processor. This depends on a scheduling strategy which may take the process priority into account

The resource manager allocates memory and a processor for the process to be executed

The dispatcher takes the process from ready list, loads it onto a processor and starts execution

Page 86: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real Time Scheduling Strategies

Page 87: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

R-T Scheduling Strategies

Non pre-emptive scheduling

Once a process has been scheduled for execution, it runs to completion or until it is blocked for some reason (e.g. waiting for I/O)

Pre-emptive scheduling

The execution of an executing processes may be stopped if a higher priority process requires service

Scheduling algorithms

Round-robin

Rate monotonic

Shortest deadline first

Page 88: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real Time Monitoring & Control

Systems

Page 89: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Monitoring & Control Systems

Monitoring & control systems are an important class of real-time systems

Monitoring & control systems continuously check sensors and take actions depending on sensor values

Monitoring systems examine sensors and report their results

Control systems take sensor values and control hardware actuators

Page 90: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real Time Monitoring Systems

Burglar Alarm

Page 91: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Designing A Burglar Alarm SystemExample Of A Monitoring System

A system is required to monitor sensors on doors and windows to detect the presence of intruders in a building

When a sensor indicates a break-in, the system switches on lights around the area and calls police automatically

The system should include provision for operation without a mains power supply

Page 92: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Sensors

Movement detectors, window sensors, door sensors.

50 window sensors, 30 door sensors and 200 movement detectors

Voltage drop sensor

Actions

When an intruder is detected, police are called automatically.

Lights are switched on in rooms with active sensors.

An audible alarm is switched on.

The system switches automatically to backup power when a voltage drop is detected.

Sensors & Actions Of A Burglar Alarm SystemExample Of A Monitoring System

Page 93: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real Time System Design

Page 94: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

The 5 Step R-T System Design Process

1. Identify stimuli and associated responses

2. Define the timing constraints associated with each stimulus and response

3. Allocate system functions to concurrent processes

4. Design algorithms for stimulus processing and response generation

5. Design a scheduling system which ensures that processes will always be scheduled to meet their deadlines

Page 95: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Stimuli To Be Processed - A Burglar Alarm System

Power failure

Generated aperiodically by a circuit monitor. When received, the system must switch to backup power within 50 ms

Intruder alarm

Stimulus generated by system sensors. Response is to call the police, switch on building lights and the audible alarm

Page 96: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Stimulus/Response Timing requirementsPower fail interrupt The switch to backup power must be completed

within a deadline of 50 ms.Door alarm Each door alarm should be polled twice per

second.Window alarm Each window alarm should be polled twice per

second.Movement detector Each movement detector should be polled twice

per second.Audible alarm The audible alarm should be switched on within

1/2 second of an alarm being raised by a sensor.Lights switch The lights should be switched on within 1/2

second of an alarm being raised by a sensor.Communications The call to the police should be started within 2

seconds of an alarm being raised by a sensor.Voice synthesiser A synthesised message should be available

within 4 seconds of an alarm being raised by asensor.

A Burglar Alarm System’s Timing Requirements

Page 97: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

A Burglar Alarm System’s Architecture Diagram

Lighting controlprocess

Audible alarmprocess

Voice synthesizerprocess

Alarm systemprocess

Power switchprocess

Building monitorprocess

Communicationprocess

Door sensorprocess

Movementdetector process

Window sensorprocess

560Hz

60Hz400Hz 100Hz

Power failureinterrupt

Alarmsystem

Building monitor

Alarmsystem

Alarm system

Alarm system

Detector status Sensor status Sensor status

Room number

Alert message

Room number

Room number

Page 98: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Building_monitor process 1 }

// See http://www.software-engin.com/ for links to the complete Java code for this// example

class BuildingMonitor extends Thread {

BuildingSensor win, door, move ;

Siren siren = new Siren () ;Lights lights = new Lights () ;Synthesizer synthesizer = new Synthesizer () ;DoorSensors doors = new DoorSensors (30) ;WindowSensors windows = new WindowSensors (50) ;MovementSensors movements = new MovementSensors (200) ;PowerMonitor pm = new PowerMonitor () ;

BuildingMonitor(){

// initialise all the sensors and start the processessiren.start () ; lights.start () ;synthesizer.start () ; windows.start () ;doors.start () ; movements.start () ; pm.start () ;

A Burglar Alarm System’s

Sample Code

Page 99: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Building_monitor process 2

public void run (){

int room = 0 ;while (true){

// poll the movement sensors at least twice per second (400 Hz)move = movements.getVal () ;// poll the window sensors at least twice/second (100 Hz)win = windows.getVal () ;// poll the door sensors at least twice per second (60 Hz)door = doors.getVal () ;if (move.sensorVal == 1 | door.sensorVal == 1 | win.sensorVal == 1)

{// a sensor has indicated an intruder if (move.sensorVal == 1) room = move.room ;if (door.sensorVal == 1) room = door.room ;if (win.sensorVal == 1 ) room = win.room ;

lights.on (room) ; siren.on () ; synthesizer.on (room) ;break ;

}}lights.shutdown () ; siren.shutdown () ; synthesizer.shutdown () ;windows.shutdown () ; doors.shutdown () ; movements.shutdown () ;

} // run} //BuildingMonitor A Burglar Alarm

System’s Sample Code

Page 100: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Real Time Control Systems

Temperature Control

Page 101: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Control Systems

A burglar alarm system is primarily a monitoring system. It collects data from sensors but no real-time actuator control

Control systems are similar but, in response to sensor values, the system sends control signals to actuators

An example of a monitoring and control system is a system which monitors temperature and switches heaters on and off

Page 102: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

A Temperature Control System

Thermostatprocess

Sensorprocess

Furnacecontrol process

Heater controlprocess

500Hz

500Hz

Thermostat process500Hz

Sensorvalues

Switch commandRoom number

Page 103: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Data Acquisition Systems

Data Acquisition Systems collect data from sensors for subsequent processing and analysis.

Data collection processes and processing processes may have different periods and deadlines.

Data collection may be faster than processing e.g. collecting information about an explosion.

Circular or ring buffers are a mechanism for smoothing speed differences.

Page 104: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Nuclear Reactor Data CollectionAnother Control System Example

A system collects data from a set of sensors monitoring the neutron flux from a nuclear reactor.

Flux data is placed in a ring buffer for later processing.

The ring buffer is itself implemented as a concurrent process so that the collection and processing processes may be synchronized.

Page 105: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Nuclear Reactor Flux MonitoringAnother Control System Example

DisplayProcess

dataSensor data

bufferSensorprocess

Sensoridentifier and

value

Processedflux level

Sensors (each data flow is a sensor value)

Page 106: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

A Ring Buffer

Consumerprocess

Producerprocess

Page 107: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Mutual Exclusion

Producer processes collect data and add it to the buffer. Consumer processes take data from the buffer and make elements available

Producer and consumer processes must be mutually excluded from accessing the same element.

The buffer must stop producer processes adding information to a full buffer and consumer processes trying to take information from an empty buffer.

Page 108: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Java implementation of a ring buffer 1

class CircularBuffer{

int bufsize ;SensorRecord [] store ;int numberOfEntries = 0 ;int front = 0, back = 0 ;

CircularBuffer (int n) {bufsize = n ;store = new SensorRecord [bufsize] ;

} // CircularBuffer

synchronized void put (SensorRecord rec ) throws InterruptedException{

if ( numberOfEntries == bufsize)wait () ;

store [back] = new SensorRecord (rec.sensorId, rec.sensorVal) ;back = back + 1 ;if (back == bufsize)

back = 0 ;numberOfEntries = numberOfEntries + 1 ;notify () ;

} // putA Circular Buffer

Sample Code

Page 109: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Java implementation of a ring buffer 2

synchronized SensorRecord get () throws InterruptedException{

SensorRecord result = new SensorRecord (-1, -1) ;if (numberOfEntries == 0)

wait () ;result = store [front] ;front = front + 1 ;if (front == bufsize)

front = 0 ;numberOfEntries = numberOfEntries - 1 ;notify () ;return result ;

} // get} // CircularBuffer

A Circular Buffer Sample Code

Page 110: Dr. Thomas Hicks Computer Science Department Trinity University 1 Software Engineering CSCI 3321.

Software EngineeringCSCI 3342

Dr. Thomas E. HicksComputer Science Department

Trinity University

Textbook: Software EngineeringBy Roger Pressman

Textbook: Software EngineeringBy Ian Sommerville

Special Thanks To WCB/McGraw-Hill & Addison Wesley For Providing Graphics Of Some Of Text Book Figures For Use In This

Presentation.