You are on page 1of 29

UNIT 5,

CHAPTER 5 in AN EMBEDDED SOFTWARE PRIMER


By DAVID E. SIMON: PEARSON EDUCATION, 1999

SURVEY OF SOFTWARE
ARCHITECTURES

RIZWAN AHMED – 4NMO6ECO75

1
OUTLINE

INTRODUCTION
ROUND ROBIN ARCHITECTURE
ROUND ROBIN WITH INTERRUPTS
FUNCTION QUEUES- SCHEDULING
RTOS ARCHITECTURE
SUMMARY

2
SURVEY OF SOFTWARE ARCHITECTURES

 Overview
◦ The basic ‘computational model’ that helps structuring or organizing the
components of your embedded software
◦ The underlying criterion is: how much (logical) control is needed to satisfy the
required system ‘response time.’
◦ Other factors affecting ‘response’ are: processor speed, system overhead

◦ Guides:
 A simple architecture: if response time is not a major issue.
 A complex architecture: if there are multiple, rapid deadline and priority requirements.

◦ Topics:
 Round-robin - simple
 Round-robin with interrupts - fairly complex
 Function-queue-scheduling - complex
 Real-time operating system - very complex

3
SURVEY OF SOFTWARE ARCHITECTURES

 5.1 Round-Robin Architecture


 Advantages:
◦ Simple
◦ No interrupts and no shared data
◦ No response latency (and no overhead)
◦ More suitable for systems that require one-at-a-time operation (e.g., digital watches,
microwave ovens with simple functionality)
 Disadvantages:
◦ If any device or service/processing needs response in less time than it takes the
microprocessor to complete processing any system component (e.g., a loop, a module,
a basic functionality) – then RR won’t work.
◦ Adding more functionality, devices, or service/processing introduces potential
‘timing’ or ‘response time’ problems, which weakens the RR architecture.

4
ROUND ROBIN ARCHITECTURE

5
6
MULTIMETER PROGRAM

7
SURVEY OF SOFTWARE ARCHITECTURES

 5.2 Round-Robin with Interrupts


◦ Offers more control over priorities via hardware interrupts
◦ Interrupt handlers implement higher priority functions (allowing the assignment of levels of
priority among devices/handlers)
◦ The handlers set flags, which are polled by the task code to continue when the handlers
complete their job
◦ Advantages:
 Still relatively simple.
 Hardware timing requirments better met.

◦ Disadvantages:
 All task code still executes at same priority.
 Maximum delay unchanged.
 Worst case response time = sum all other execution times + execution times of any other
interrupts that occur

8
ROUND ROBIN WITH INTERRUPT
ARCHITECTURE

9
PRIORITY LEVELS FOR ROUND
ROBIN ARCHITECTURE

10
SURVEY OF SOFTWARE ARCHITECTURES

 5.2 Round-Robin with Interrupts – Example: A Simple Bridge


◦ RR w/I is powerful enough to handle simple to fairly complex systems
◦ Consider: A two port bridge, with bi-directional encrypted/decrypted data property

◦ Assumptions:
 Characters arrives at the hardware I/O port, one at a time, causing interrupt routines to read/write out of
the port
 No hard deadline, or speed requirement, for the time to read/write from/to the port
 Read/write routines do so from/into a queue for the bridge to encrypt/decrypt, one character at a time
(the queue is a shared data, and it is handled in the task code to avoid problems)

◦ The task code protects the shared queue-data structure


◦ The task code (simulating the bridge) is supported by vEncrypt and vDecrypt routines

◦ (See Fig 5.6 and Fig 5.7)

11
12
13
14
15
16
17
SURVEY OF SOFTWARE ARCHITECTURES

 5.2 Round-Robin with Interrupts – 2

 Example – Bar Code Scanner


◦ The scanner’s (hardware) laser reads the bar code and transmits as radio waves
◦ Response time requirement is time for reading and transmitting signals
◦ Task code will be serviced quickly (making RR a sufficient architecture)

18
SURVEY OF SOFTWARE ARCHITECTURES

 5.2 Round-Robin with Interrupts – 3

 Characteristics of the Round-Robin with Interrupts

◦ Low priority tasks could experience longer delays, if higher priority tasks execute code (outside
their critical section) which take a long time
◦ Ex: If task A takes 200 ms to execute code outside its CS, then the waiting/response time for
lower priority tasks B, C, will be so increased
◦ Moving out-of-CS code for B and C into their interrupt handlers will help regain some time or
indirectly increase their priority levels. Meaning, the handlers for B and C will also take 200 ms
more to execute, increasing the overall response time for B and C
◦ One way to improve the response time of a task with lower priority is to ‘check’ its status flag
more frequently than others’ (typical RR technique in OS)

 Summary: Any task which is a processor hog will not be good to model using a RR with
interrupt architecture, since response time will be bad! [Ex. The laser printer task and
the underground tank-monitoring task in Chapter 1]

19
SURVEY OF SOFTWARE ARCHITECTURES

 5.3 Function-Queue-Scheduling Architecture

◦ Improves the response time of higher priority tasks.


◦ Interrupt routines add function-pointers to a queue for the main task to execute
◦ The main task continuously scans the queue and executes the corresponding function
◦ Allows placing function-pointers in the queue based on preferred priority scheme (placement
is done by a supporting/auxiliary routine invoked by the handlers)

◦ See Fig 5.8

◦ Characteristics:
 The worst-case response time for highest-priority tasks is: sum(longest task code, any interrupts this code
generates), and not the sum of the response times of all the handlers
 The response time for lowest-priority tasks could be long when their code segments are long

20
21
22
SURVEY OF SOFTWARE ARCHITECTURES

 5.4 Real-Time Operating Systems Architecture

◦ In this architecture, the handlers signal the OS when their work is done. The OS then
‘switches’ control to the task code (when appropriate) to continue its job.
◦ Most complex.
◦ Interrupts handle urgent operations, the signal that there is more work to do for task code.

• Differences with previous architecture


• We don’t write signal flags (RTOS takes care of it)
• No loop in our code decides what is executed next(RTOS does this)
• RTOS knows relative task priorities and controls what is executed next
• RTOS can suspend a task in the middle to execute code of higher priority
• Now we can control task response AND interrupt response!!!!

23
24
25
REAL TIME ARCHITECTURE
PRIORITIES AND COMPARISION

26
SELECTING AN ARCHITECTURE

27
summary

28
THANK YOU
ALL THE BEST

29

You might also like