Sunteți pe pagina 1din 8

Principles of Embedded Systems

UNIT-III
Software Architecture of Embedded Systems:
 We will discuss four architectures starting with the simplest one, which
practically has no control of your response and priorities, moving on to
others that give greater control but at a cost of increased complexity.
1)Round-Robin

 It is one of the simplest


architectures.
 The main loop in the code
simply checks each of the I/O
devices and services any that
need services.
 It is simple architecture with:
 No interrupts
 No Shared Data Problem
 No Latency concerns
 We can use this architecture for
making a digital multimeter.

 Digital Multimeter: It is a device that measures electrical resistance,


current and potential in units of ohms, amps, volts and in several other
ranges.
 It consists of:
 Two probes to measure by touching two points on the circuit.
 Digital Display
 Rotatory Switch that selects which measurement to make in what
range.
 In the code, each time the loop
checks the position of the
rotatory switch and then:
 branches/jumps to a code to
make the measurement.
 formats its result
 write the results to the
display.
 Round-Robin works well with
this system because:
 There are only 3 I/O devices
 No lengthy processing.
 No tight response
requirements
 Advantage: Simplicity
 Disadvantage: The system will not work properly for the following:
 If any one device needs response in less time and if worst-case scenario
is encountered it takes more time for µp to get around the loop.
 Even if none of the required response times are absolute deadlines
system will not work well if there is lengthy processing to do.
 Architecture is fragile, in a sense that even if efforts are made for µp to
get around the loop quickly. A single device or requirement might break
everything.
2)Round-Robin with Interrupts
 It is a more sophisticated architecture.
 In this architecture:
 the ISR deals with the very urgent needs of the H/W and then set flags
 the main loop polls i.e) decides over the flags and does any follow up
processing required by the interrupts.
 The ISR can get good response, as the H/W interrupt signal causes the µp
to stop whatever its doing in the main function and execute the ISR
instead.
 Since all the processing i.e) instructions..etc that is in the ISR has higher
priority than the task code in the main function, we can assign priorities to
various individual interrupts. (as discussed in UNIT-II)
 The contrast of priority control
b/w the round-robin and
round-robin with interrupts is
shown on the right.
 Advantage: Using interrupts to
get good response.
 Disadvantage: Shared Data
Problem.

Interrupt Service Routines


The main loop

 This architecture is suitable for many system:


 Communications bridge.
 Cordless Bar-Code Scanner.
 Characteristics of the round-robin with interrupts:
 If devices A, B and C all interrupt when the µp is executing the loop
then task code for device C has to wait for A and B to execute.
 Putting the C’s task code directly in the ISR to get a device execute at
higher priority than A and B.
 Testing the flag for device C more than the flags for other devices by
the main loop in a sequence like A, C, B, C, D, C, E, C…..
 Worst-case response for the task code happens of any device occurs
when the round-robin loop passes the task code for that device.
 Examples for system for which this architecture does not work for are
laser printer and underground tank-monitoring system.

3)Function-Queue-Scheduling Architecture
 In this architecture, the interrupt service routines add function pointers
to a queue of function pointers.
 The main routine just reads
pointers from the queue can
calls the function.
 The advantages:
 No rule says main has to call the functions in the order that the
interrupt routines occurred.
 Any task code functions that need quicker response can be executed
earlier.
 All this takes is a little clever coding in the routines that queue up the
function pointers.
 worst wait: The length of the longest of the task code function s.
 The trade-off/ compromise for better response:
 The response for the lower-priority task code functions may get worse.
 Lower-priority functions may never execute if the interrupt service
schedule the higher-priority functions frequently enough to use up all
of the microprocessor’s available time.
4)Real-Time Operating System Architecture (RTOS)
 The difference b/w this architecture and others are that:
 The necessary signalling b/w the ISR and the task code is handled by the
RTOS which is not present in this code (Fig 5.8), and does not use
shared variables for this purpose.
 No loop in the code decides what needs to be done next, the code in
the RTOS decides which task code function/subroutine is more urgent
and should run.
 The RTOS can suspend one task code subroutine in the middle of its
processing in order to run another.
 Advantages:
 RTOS can control task code response as well as ISR response.
 The worst-case wait for the highest-priority task code is zero.
 Therefore, your system’s response will be relatively stable.
 RTOSs are widely available for purchase.
 Disadvantage: RTOS itself uses certain amount of processing time by
getting better response at the expense of little bit of throughput.
 Comparison:
5)Selecting an Architecture
 Select the simplest architecture that will meet your response
requirements.
 If your system has response requirements that might demand using a
RTOS use it.
 Hybrid architectures make sense for some systems.

THE END

S-ar putea să vă placă și