Erts Course Material
Erts Course Material
(AUTONOMOUS)
NAMAKKAL- TRICHY MAIN ROAD, THOTTIAM
DEPARTMENT OF ELECTRONICS AND COMMUNICATION
ENGINEERING
EC8791-EMBEDDED AND
REAL TIME SYSTEMS
Course Material
Regulation-2017
IV ECE/VII SEM
UNIT I
INTRODUCTION TO EMBEDDED SYSTEM DESIGN
Complex systems and micro processors– Embedded system design
process –Design example: Model train controller-Design
methodologies- Design flows - Requirement Analysis – Specifications-
System analysis and architecture design – Quality Assurance
techniques - Designing with computing platforms – consumer
electronics architecture – platform-level performance analysis.
Introduction-Embedded Systems
An Embedded system is an electronic system that has a software and is
embedded in computer hardware.
It is a system which has collection of components used to execute a task
according to a program or commands given to it.
Examples →Microwave ovens, Washing machine, Telephone answering
machine system, Elevator controller system, Printers, Automobiles,
Cameras, etc.
Components of Embedded system
Microprocessor
Memory Unit(RAM,ROM)
Input unit(Keyboard,mouse,scanner)
Output unit(pinters,video monitor)
Networking unit(Ethernet card)
I/O units(modem)
Real Time Operating System-RTOS
Real-Time Operating System (RTOS) is an operating system (OS)
intended to serve real-time applications that process data as it comes
in, typically without buffer delays.
It schedules their working and execution by following a plan to control
the latencies and to meet the dead lines.
Modeling and evaluation of a real-time scheduling system concern is
on the analysis of the algorithm capability to meet a process deadline.
A deadline is defined as the time required for a task to be processed.
Classification of Embedded system
1. Small scale Embedded system→(8/16bit microcontroller)
2. Medium Scale Embedded system→ →(16/32bit microcontroller,
more tools like simulator, debugger)
3. Sophisticated Embedded system →(configurable processor and PAL)
Embedded designer-skills
Designer has a knowledge in the followings field,
Microcontrollers, Data comm., motors, sensors, measurements ,C
programming, RTOS programming.
1) COMPLEX SYSTEMS AND MICROPROCESSORS
Embedded(+)computer system
Embedded system is a complex system
It is any device that includes a programmable computer but is not
itself intended to be a general-purpose computer.
History of Embedded computer system
Computers have been embedded into applications since the earliest days of
computing.
In 1940s and 1950s→Whirlwind, designed a first computer to support real-time
operation for controlling an aircraft simulator.
In 1970s→ The first microprocessor( Intel 4004) was designed for an embedded
application (Calculator), provided basic arithmetic functions.
In 1972s→ The first handheld calculator (HP-35 ) was to perform
transcendental functions , so it used several chips to implement the CPU,
rather than a single-chip microprocessor.
Designer faced critical problems to design a digital circuits to perform
operations like trigonometric functions using calculator.
But ,Automobile designers started making use of the microprocessor for to
control the engine by determining when spark plugs fire, controlling the
fuel/air mixture
Levels of Microprocessor
1. 8-bit microcontroller→ for low-cost applications and includes on-board
memory and I/O devices.
2. 16-bit microcontroller → used for more sophisticated applications that may
require either longer word lengths or off-chip I/O and memory.
3. 32-bit RISC microprocessor →offers very high performance for
computation-intensive applications.
Microprocessor Uses/Applications
Microwave oven has at least one microprocessor to control oven operation
Thermostat systems, which change the temperature level at various times during
the day
The modern camera is a prime example of the powerful features that can be
added under microprocessor control.
Digital television makes extensive use of embedded processors.
Embedded Computing Applications
Ex→BMW 850i Brake and Stability Control System
The BMW 850i was introduced with a sophisticated system for controlling the
wheels of the car.
Which uses An antilock brake system (ABS) and An automatic stability
control (ASC +T) system.
1. An antilock brake system (ABS)
Reduces skidding by pumping the brakes.
It is used to temporarily release the brake on a wheel when it rotates
too slowly—when a wheel stops turning, the car starts skidding and
becomes hard to control.
It sits between the hydraulic pump, which provides power to the
brakes.
It uses sensors on each wheel to measure the speed of the wheel.
The wheel speeds are used by the ABS system to determine how to vary
the hydraulic fluid pressure to prevent the wheels from skidding.
2. An automatic stability control (ASC +T) system
It is used to control the engine power and the brake to improve the car’s
stability during maneuvers.
It controls four different systems: throttle, ignition timing, differential
brake, and (on automatic transmission cars) gear shifting.
It can be turned off by the driver, which can be important when
operating with tire snow chains.
It has control unit has two microprocessors , one of which concentrates
on logic-relevant components and the other on performance-specific
components.
The ABS and ASC+ T must clearly communicate because the ASC+ T
interacts with the brake system.
Characteristics of Embedded Computing
Applications
1. Complex algorithms-The microprocessor that controls an automobile engine
must perform complicated filtering functions to optimize the performance of
the car while minimizing pollution and fuel utilization.
2. User interface-The moving maps in Global Positioning System (GPS)
navigation are good examples of user interfaces.
3. Real time-Embedded computing systems have to perform in real time—if the
data is not ready by a certain deadline, the system breaks. In some cases,
failure to meet a deadline or missing a deadline does not create safety
problems but does create unhappy customers
4. Multirate-Multimedia applications are examples of multirate behavior.
The audio and video portions of a multimedia stream run at very different
rates, but they must remain closely synchronized. Failure to meet a deadline
on either the audio or video portions spoils the perception of the entire
presentation.
5. Manufacturing cost- It is depends on the type of microprocessor used, the
amount of memory required, and the types of I/O devices.
6. Power and energy-Power consumption directly affects the cost of the
hardware, since a larger power supply may be necessary.
7. Energy consumption →affects battery life, which is important in many
applications, as well as heat consumption, which can be important even in
desktop applications.
Why Use Microprocessors?
Microprocessors are a very efficient way to implement digital systems.
It make it easier to design families of products with various feature at
different price points
It can be extended to provide new features to keep up with rapidly
changing markets.
It executes program very efficiently
It make their CPU run very fast
Implementing several function on a single processor
Why not use PCs for all embedded
computing?
Real time performance is very less in PC because of
different architecture.
It increases the complexity and price of components due to
broad mix of computing requirements.
Challenges in Embedded Computing System Design
1. How much hardware do we need?
To meet performance deadlines and manufacturing cost constraints, the choice of
Hardware is important.
Too much hardware and it becomes too expensive.
2. How do we meet deadlines?
To speed up the hardware so that the program runs faster. But the system more
expensive.
It is also entirely possible that increasing the CPU clock rate may not make
enough difference to execution time, since the program’s speed may be limited by
the memory system.
3. How do we minimize power consumption?
In battery-powered applications, power consumption is extremely important.
In non-battery applications, excessive power consumption can increase heat
dissipation.
Careful design is required to slow down the noncritical parts of the machine for
power consumption while still meeting necessary performance goals.
4) How do we design for upgradability?
The hardware platform may be used to add features by changing software.
4.1) Complex testing: Run a real machine in order to generate the proper data.
Testing of an embedded computer from the machine in which it is embedded.
4.2) Limited observability and controllability→No keyboard and screens, in real-
time applications we may not be able to easily stop the system to see what is
going on inside and to affect the system’s operation.
4.3) Restricted development environments:
We generally compile code on one type of machine, such as a PC, and
download it onto the embedded system.
To debug the code, we must usually rely on programs that run on the PC or
workstation and then look inside the embedded system.
Performance in Embedded Computing
Embedded system designers have to set their goal —their program must meet its
deadline.
Performance Analysis
1. CPU: The CPU clearly influences the behavior of the program, particularly when
the CPU is a pipelined processor with a cache.
2. Platform: The platform includes the bus and I/O devices. The platform
components that surround the CPU are responsible for feeding the CPU and can
dramatically affect its performance.
3. Program: Programs are very large and the CPU sees only a small window of the
program at a time. We must consider the structure of the entire program to
determine its overall behavior.
4. Task: We generally run several programs simultaneously on a CPU, creating a
multitasking system. The tasks interact with each other in ways that have profound
implications for performance.
5. Multiprocessor: Many embedded systems have more than one processor—they
may include multiple programmable CPUs as well as accelerators. Once again, the
interaction between these processors adds yet more complexity to the analysis of
overall system performance.
2)EMBEDDED SYSTEM DESIGN PROCESS
Design process has two objectives as follows.
1. It will give us an introduction to the various steps in embedded system
design.
2. Design methodology
I. Design to ensure that we have done everything we need to do, such as
optimizing performance or performing functional tests.
II. It allows us to develop computer-aided design tools.
III. A design methodology makes it much easier for members of a design
team to communicate.
Levels of abstraction in the design process.
1)Requirements
•It can be classified in to functional or nonfunctional
1.1)Functional Requirements
•Gather an informal description from the customers.
•Refine the requirements into a specification that contains
enough information to design the system architecture.
•Ex:Sample Requirements form
•Name→Giving a name to the project
Purpose→Brief one- or two-line description of what the system
is supposed to do.
•Inputs& Outputs →Analog electronic signals? Digital data?
Mechanical inputs?
•Functions→ detailed description of what the system does
Performance→ computations must be performed within a
certain time frame
•Manufacturing cost→ cost of the hardware components.
Power→ how much power the system can consume
Physical size and weight→ indication of the physical size
of the system
1.2) Non-Functional Requirements
Performance→ depends upon approximate time to perform a user-
level function and also operation must be completed within deadline.
Cost→Manufacturing cost includes the cost of components and
assembly.
• Nonrecurring engineering (NRE) costs include the personnel and other
costs of designing the
system
Physical Size and Weight→The final system can vary depending upon
the application.
Power Consumption→Power can be specified in the requirements stage
in terms of battery life.
2)SPECIFICATION
The specification must be carefully written so that it accurately reflects the
customer’s requirements.
It can be clearly followed during design.
3) Architecture Design
The architecture is a plan for the overall structure of the system.
It is in the form block diagram that shows a major operation and data flow.
4) Designing Hardware and Software Components
The architectural description tells us what components we need include both
hardware—FPGAs, boards & software modules
5)System Integration
Only after the components are built, putting them together and seeing a
working system.
Bugs are found during system integration, and good planning can help us find
the bugs quickly.
Embedded system Design Example
GPS moving map
Design Process Steps
1. Requirements analysis of a GPS moving map
The moving map is a handheld device that displays for the user a map of the
terrain around the user’s current position.
The map display changes as the user and the map device change position.
The moving map obtains its position from the GPS, a satellite-based navigation
system.
Name GPS moving map
Purpose Consumer-grade moving map for driving use
Inputs Power button, two control buttons
Outputs Back-lit LCD display 400 600
Functions Uses 5-receiver GPS system; three user-selectable
resolutions;always displays current latitude and
longitude
Performance Updates screen within 0.25 seconds upon movement
Manufacturing cost $30
Power 100mW
Physical size and No more than 2”X 6, ” 12 ounces
weight
Design Process Steps
2) Functionality→This system is designed for highway driving and similar uses.
The system should show major roads and other landmarks available in
standard topographic databases.
3)User interface→The screen should have at least 400X600 pixel resolution. The
device should be controlled by no more than 3 buttons.
→A menu system should pop up on the screen when buttons are
pressed to allow the user to make selections to control the system.
5)Cost→ The selling cost of the unit should be no more than $100.
6)Physical size and weight→The device should fit comfortably in the palm of the
hand.
7) Power consumption→ The device run for at least 8 hrs on 4 AA batteries.
8) specification
1. Data received from the GPS satellite constellation.
2. Map data.
3. User interface.
4. Operations that must be performed to satisfy customer requests.
5. Background actions required to keep the system running, such as
operating the GPS receiver.
Block Diagram
Hardware architecture
•one central CPU surrounded by
memory and I/O devices.
• It used two memories: a frame buffer
for the pixels to be displayed and a
separate program/data memory for
general use by the CPU.
Software architecture
•Timer to control when we read the buttons
on the user interface and render data onto
the screen.
•Units in the software block diagram will be
executed in the hardware block diagram and
when operations will be performed in time.
3)FORMALISM FOR SYSTEM DESIGN
UML(Unified Modeling Language) is an object-oriented modeling language→
used to capture all these design tasks.
It encourages the design to be described as a number of interacting objects,
rather than blocks of code.
objects will correspond to real pieces of software or hardware in the system.
It allows a system to be described in a way that closely models real-world
objects and their interactions.
Classification of descriptor
3.1)Structural Description
3.2)Behavioral Description
3.1)Structural Description
It gives basic components of the system and designers can learn how to
describe these components in terms of object.
3.1.1) OBJECT in UML NOTATION
An object includes a set of attributes that define its internal state.
An object describing a display (CRT screen) is shown in UML notation in
Figure.
The object has a unique name, and a member of a class.
The name is underlined to show that this is a description of an object and not
of a class.
The text in the folded-corner page icon is a note.
State
Signal →is an asynchronous occurrence.
It is defined in UML by an object that is labeled as a <<signal>>.
Signal may have parameters that are passed to the signal’s receiver.
Call event→ follows the model of a procedure call in a programming
language.
Time-out event→ causes the machine to leave a state after a certain
amount of time.
The label tm(time-value) on the edge gives the amount of time after
which the transition occurs.
State Machine specification in UML
The start and stop states are special states which organize the flow of the state
machine.
The states in the state machine represent different operations.
Conditional transitions out of states based on inputs or results of some
computation.
An unconditional transition to the next state.
Sequence diagram in UML
Sequence diagram is similar to a hardware timing diagram, although the time
flows vertically in a sequence diagram, whereas time typically flows horizontally
in a timing diagram.
It is designed to show particular choice of events—it is not convenient for
showing a number of mutually exclusive possibilities.
4) Design:Model Train Controller
In order to learn how to use UML to model systems→ specify a simple system
(Ex: model train controller)
The user sends messages to the train with a control box attached to the tracks.
The control box may have controls such as a throttle, emergency stop button,
and so on.
The train Rx its electrical power from the two rails of the track.
CONSOLE
Each packet includes an address so that the console can control several trains
on the same track.
The packet also includes an error correction code (ECC) to guard against
transmission errors.
This is a one-way communication system—the model train cannot send
commands back to the user.
Model Train Control system
REQUIREMENTS
The console shall be able to control up to eight trains on a single track.
The speed of each train controllable by a throttle to at least 63 different
levels in each direction (forward and reverse).
There shall be an inertia control→ to adjust the speed of train.
There shall be an emergency stop button.
An error detection scheme will be used to transmit messages.
Requirements:Chart Format
Name Model train controller
Purpose Control speed of up to eight model trains
Inputs Throttle, inertia setting, emergency stop, train
number
Outputs Train control signals
Functions Set engine speed based upon inertia settings;
respond
•The Panel class defines a behavior for each of the controls on the panel.
• The new-settings behavior uses the set-knobs behavior of the Knobs*
•Change the knobs settings whenever the train number setting is changed.
•The Motor-interface defines an attribute for speed that can be set by other
classes.
.
Class diagram for the Transmitter and Receiver
•They provide the software interface to the physical devices that send
and receive bits along the track.
•The Transmitter provides a behavior message that can be sent
• The Receiver class provides a read-cmd behavior to read a message off
the tracks.
Class diagram for Formatter
The formatter holds the current control settings for all of the trains.
The send-command serves as the interface to the transmitter.
The operate function performs the basic actions for the object.
The panel-active behavior returns true whenever the panel’s values do not
correspond to the current values
Class diagram for Controller
For example, bus to carry four bytes or 32 bits per transfer, we would reduce
the transfer time to 0.058 s. If we also increase the bus clock rate to 2 MHz,
then we would reduce the transfer time to 0.029 s ,which is within our time
budget for the transfer.
t=TP
t→bus cycle counts
T→bus cycles.
p→bus clock period
9.1)Parallelism
Direct memory access is a example of parallelism.
DMA was designed to off-load memory transfers from the CPU.
The CPU can do other useful work while the DMA transfer is running.
1. Marilyn Wolf, “Computers as Components – Principles of
Embedded Computing System Design”, Third Edition “Morgan
Kaufmann Publisher (An imprint from Elsevier), 2012.
(UNIT I, II, III, V)
2.Jane W.S.Liu,‖ Real Time Systems‖, Pearson Education, Third
Indian Reprint, 2003.(UNIT IV)
UNIT II
ARM PROCESSOR AND PERIPHERALS
ARM Architecture Versions – ARM Architecture – Instruction Set –
Stacks and Subroutines – Features of the LPC 214X Family – Peripherals
– The Timer Unit – Pulse Width Modulation Unit – UART – Block
Diagram of ARM9 and ARM Cortex M3 MCU.
2.1) ARM Architecture Versions
ARM stands for ‘Advanced RISC Machine’.
It was developed in the year 1980
In year 1985 ARM1, which had less than 25,000 transistors, and operated at
6 MHz
In year 1987 ARM2 with 30,000 transistors.
In year 1990 ARM3-4-5 with 30,000 transistors.
As of 2011, ARM processors account for approximately 90 per cent of all
embedded 32-bit RISC processors.
Advanced processors of the ARM family (ARM9, ARM10, ARM11, Cortex)
have been built on the success of the ARM7 processor, which is still the
most popular and widely used member of the ARM family.
Applicaions
Consumer electronics, including PDAs, mobile phones, digital media and
music players, handheld game consoles, calculators and computer
peripherals such as hard drives and routers
2.1.1)ARM CORTEX
A profile
This profile which has the ARMv7-A architecture is meant for
high end applications.(mobile phones and video systems)
R profile
This profile which has the ARMv7-R architecture has been
designed for high-end applications which require real-time
capabilities. (automatic braking systems and other safety critical
applications)
M profile
This profile which has the ARMv7-M architecture has been
designed for industrial control applications where a large
number of peripherals may have to be handled and controlled.
2.1.2)Features of ARM
It is a 32 bit processor also supports 8 and 16 bits data types.
It can be configured either Little-endian mode ( lowest-order byte stored in the
low-order bits of the word) or Big-endian mode (lowest-order byte stored in the
highest bits of the word).
It uses a Intelligent Energy Meter(IEM) technology to optimally balancing the
workload and energy consumption.
It use Advanced High Performance Bus interface(AMBA) for on-chip
interconnect purpose.
Data bus width→The processor has a 32-bit data bus width, which means that it
can read and write 32 bits in one cycle.
Computational capability→ The instruction set of ARM has been cleverly
designed to facilitate very good computational capability.
Low power→ ARM operates at relatively low frequencies from 60 MHz to at the
most 1 GHz.
Pipelining→Any time, there are three instructions simultaneously present in the
pipeline, at different levels of processing.
Multiple register instructions→ There are instructions which access memory and
load data into multiple registers – also, contents of multiple registers can be
stored in memory, with a single instruction.
2.2)ARM-Architecture
Arrow→
represents
flow of data.
Line→
represents
the buses
Boxes→
Represent
either
storage area
or operation
unit
Data enters the processor core through data bus. It is either data
item or instruction to execute.
If it is a instruction then the instruction decoder translates
instructions before they are executed.
If it is data then the data item are placed in the register file (32bit
size).
It have register (Rn,Rm-source register and Rd-destination
register).
Source operands are read from the register file using internal
buses Aand B.
ALU takes the register values Rn and Rm from A and B buses and
write the result Rd directly to the register file using result bus.
Load and store instructions use the ALU to generate an address
and it stores in address register.
CPU modes
User mode→ The only non-privileged mode.
FIQ (fast Interrupt request)mode→A privileged mode that is entered
whenever the processor accepts a fast interrupt request.
IRQ mode→A privileged mode that is entered whenever the processor
accepts an interrupt.
Supervisor (svc) mode→ A privileged mode entered whenever the CPU
is reset or when an SVC instruction is executed.
Abort mode→A privileged mode that is entered whenever a pre-fetch
abort or data abort exception occurs.
Undefined mode→ A privileged mode that is entered whenever an
undefined instruction exception occurs.
System mode→It can only be entered by executing an instruction that
explicitly writes to the mode bits of the Current Program Status Register
(CPSR) from another privileged mode (not from user mode).
Data Operations
In ARM processor→ Arithmetic and logical operations can’t be performed
directly on memory locations.
ARM is a load-store architecture—data operands must first be loaded into
the CPU and then stored back to main memory to save the results.
Current program status register (CPSR)→ set automatically during every
arithmetic, logical, or shifting operation.
Based on the result of arithmetic/logical operation,CPSR four bits are
affected as follows
The negative (N) bit is set when the result is negative in two’s-complement
arithmetic.
The zero (Z) bit is set when every bit of the result is zero.
The carry (C) bit is set when there is a carry out of the operation.
The overflow(V) bit is set when an arithmetic operation results in an
overflow.
2.3)Instruction Set
The instruction set can be broadly classified as follows:
i) Data processing instructions
ii) Load store instructions—single register, multiple register
iii) Branch instructions-
iv) Status register access instructions
2.3.1)Data Processing Instructions
a)Move instructions
MOV and MVN Instructions→The ‘MOV’ instruction is a ‘register to
register’ data movement instruction with the format MOV destination,
source where both the source and destination have to be registers.
b)Conditional Execution
→Instructions are executed only if a specified condition is true.
In the instruction code, four bits are allotted for the condition under
which the instruction is to be executed.
c)Shift Instructions
Logical Shift Left (LSL)→ Logical Shift
Left of a 32-bit number causes it to shift
left and the vacant bits on the right are
filled with zeros.
Logical Shift Right (LSR)→ The
vacant bit positions on the left are filled
with zeros, and the last bit shifted out is
retained in the carry flag
Arithmetic Shift Right (ASR)→ The
vacant bit positions on the left are filled
with the MSB of the original number.
Rotate Right (ROR)→ The data is
moved right, and the bits shifted out
from the right are inserted back through
the left.
Rotate Right Extended (RRX)→
Rotating right through the carry bit,
that the bit that drops off from the right
side is moved to C and the carry bit
enters through the left of the data
d)Arithmetic Instructions
Addition-Subtraction-Multiplication→The destination is always a register.The
source operands may both be registers or one of them may be an immediate
data
Logical Instructions
2.6b)Port 1
Port 1 is a 32-bit bi-directional I/O port with individual direction controls for
each bit.
The operation of Port 1 pins depends upon the pin function selected via the
corresponding pin connect block.
Pins 0 through 15 are not available.
pins from 16 to 31, the pins 16 to 25 are ‘reserved’.
In effect, only very few pins of Port 1 are available and they can be used for
GPIO only, because other pin functions are used for JTAG.
2.6c)Pin Connect Block(PCB)
The purpose of PCB is to
configure the pins to the
desired functions.
Each pin of the chip has a
maximum of four functions.
To select one specific
function for a pin, a
multiplexer with two select
pins, is necessary.
The select pins function is
provided by the bits of the
PINSEL registers.
2.6d)GPIO Pins
These pins can be used for driving
an LCD display, relays, motor
controls, ON/OFF functions and so
on.
i) IODIR (IO Direction register):
register decides whether a pin is to
be an input(0) or output(1).
ii) IOSET (IO Set register): It is
used to set the output pins of the
chip.
iii) IOCLR (IO Clear register): To
make an output pin to have a ‘0’
value, i.e., to clear it.
iv) IOPIN (IO Pin register): From
this register, the value of the
corresponding pin can be read,
irrespective of whether the pin is
an input or output pin.
2.6.1)The Timer Unit
A timer and a counter are functionally
equivalent, except that a timer uses the
PCLK for its timing, while a counter uses an
external source.
Timer Operation
i) Load a number in a match register.
ii) Start the timer by enabling the ‘E’ bit in
T0TCR.
iii) The timer count register (T0TC) starts
incrementing for every tick of the peripheral
clock PCLK (no pre-scaling is done).
iv) When the content of the T0TC equals the
value in the match register, timing is said to
have occurred.
v) One of many possibilities can be made to
occur when this happens.
vi) The possibilities are to reset the timer
count register, stop the timer, or generate an
interrupt. This ‘setting’ is done in the T0MCR
Timer Count Register–T0TC
This is a 32-bit register, which gives it a range of counting from 0 to 0xFFFF
FFFF and then wraps back to the value 0x0000 0000.
This register is incremented on every tick of the clock (i.e. PCLK), if the
prescale counter is made 0
Timer Control Register–TOTCR
This is an 8-bit register in which only the lowest two bits need be used.
Bit 0–E→ When this Enable bit is ‘1’, the counter is enabled and starts.
Bit 1–R→When Reset bit ‘1’, the counter is reset on the next positiveedge of
PCLK.
Pre-scaler
To generate a lower frequency output
prescale counter increments for every PCLK, and when it counts up to
the value in the prescale counter (T0PR), it allows the timer counter
(T0TC) to increment its value by 1.
Timer 0 in the Interupt Mode
i)Vectored Interrupt Controller (VIC)
Manages all the interrupts of the
ARM core (IRQs and FIQs.
Receive interrupt requests from
the peripherals and generate IRQ
signal to the ARM processor.
Features of VIC
32 interrupt request inputs
16 vectored IRQ interrupts
16 priority levels dynamically
assigned to interrupt requests
Software interrupt generation
ii)Interrupt Enable Register (VIC Interrupt Enable)
This is a read/write accessible register.
This register controls the decision of which of the 32 interrupt requests and
software interrupts are allowed to contribute to the generation of an interrupt.
iii)Vector Control Register (VIC Vect Cntl0-15)
Only 6 bits of this register are to be used. They are lower 6 ones
iv)Vector Address Registers (VIC Vect Add)
These are read/write accessible registers.
These registers hold the addresses of the interrupt service routines (ISRs) for
the vectored IRQ slots
v)Timer 0 in the Interrupt Mode
T0MCR is to be programmed to generate an interrupt on match
vi)Timer 0 Interrupt Register (TOIR)
This register has bits for each of the matching states of MR0 to MR3.
When a timer operates in the interrupt mode and a match occurs, an
interrupt is generated, and the corresponding flag bit in T0IR is set.
To ‘clear’ it, a ‘1’ must be written into this same register. Then only will the
interrupt fl ag be ‘reset’.
2.6.2)Pulse Width Modulation Unit
Pulse width modulation which it is possible to control the period and duty cycle of a
square wave.
Single Edge Controlled PWM
i) All single edge controlled PWM outputs go high at the beginning of a PWM cycle.
ii) Each PWM output will go low when its match value (in MR1 to MR6) is reached. If no
match occurs the PWM output remains continuously high.
iii) When a match occurs, actions can be triggered automatically. The possible actions
are to generate an interrupt, reset the PWM timer counter, or stop the timer.
The duty cycle is the ratio of ON period (P) to the total period T.
Corresponding to the six match registers, there are six PWM output pins, and they
are called the PWM channels
Control Registers of the PWM Unit
PWMTCR(PWM Timer Control Register)
It is is an 8-bit register. Only the lower 4 bits of this register need to be used.
Bit 0–CE→ COUNTER ENABLE When ‘1’, the PWM timer counter and Prescale
counter are enabled.
Bit 1–CR→ COUNTER RESET ‘When ‘1’, the above mentioned PWM timer
count register and Prescale counter are reset on the next positive going edge of
PCLK.
Bit 2→R-Reserved
Bit 3→ PE-PWM ENABLE. When ‘1’, the PWM mode is enabled. Otherwise the
PWM unit acts as just a timer.
A basic block in C
An extended data flow graph for our sample basic block
while (a < b) {
a5proc1(a,b);
b5proc2(a,b);
}
CDFG for a while loop
while (a < b) {
a5proc1(a,b);
b5proc2(a,b);
}
3.3)ASSEMBLY, LINKING AND LOADING
•Assembly and linking last steps in the compilation process
•They convert list of instructions into an image of the program’s bits in
memory.
•Loading puts the program in memory so that it can be executed.
Compilers used to create the instruction-level program in to
assembly language code.
Assembler’s used to translate symbolic assembly language
statements into bit-level representations of instructions known as
object code and also translating labels into addresses.
Linker determining the addresses of instructions.
Loader load the program into memory for execution.
Absolute addresses Assembler assumes that the starting address of
the ALP has been specified by the programmer.
Relative addresses specifying at the start of the file address is to be
computed later.
3.3.1)Assemblers
Assembler Translating assembly code into object code also assembler must
translate opcodes and format the bits in each instruction, and translate labels
into addresses.
Labels it is an abstraction provided by the assembler.
Labelsknow the locations of instructions and data.
Label processing requires making two passes
1. first pass scans the code to determine the address of each label.
2. second pass assembles the instructions using the label values computed
in the first pass.
EXAMPLE
CODE SYMBOL TABLE
3.3.2)LINKING
A linker allows a program to be stitched together out of several smaller pieces.
The linker operates on the object files and links between files.
Some labels will be both defined and used in the same file.
Other labels will be defined in a single file but used elsewhere .
The place in the file where a label is defined is known as an entry point.
The place in the file where the label is used is called an external reference.
Phases of linker
First Phaseit determines the address of the start of each object file
Second Phasethe loader merges all symbol tables from the object files into a
single,large table.
3.4)BASIC COMPILATION TECHNIQUES
•Compilation=Translation+optimization
•Compilation begins with high-level language code
(C) and produces assembly code.
•The loop bound computation is performed on every iteration during the loop
test, even though the result never changes.
•We can avoid N X M- 1 unnecessary executions of this statement by moving it
before the loop.
Induction variable elimination
It is a variable whose value is derived from the loop iteration variable’s value.
The compiler often introduces induction variables to help it implement the
loop.
Properly transformed able to eliminate some variables and apply strength
reduction to others.
A nested loop is a good example of the use of induction variables.
for (i = 0; i < N; i++)
for (j = 0; j < M; j++)
z[i][j] = b[i][j];
The compiler uses induction variables to help it address the arrays. Let us
rewrite the loop in C using induction variables and pointers
for (i = 0; i < N; i++)
for (j = 0; j < M; j++) {
zbinduct = i*M + j;
*(zptr + zbinduct) = *(bptr + zbinduct);
}
Strength reduction
It reduce the cost of a loop iteration.
Consider the following assignment
y = x * 2;
In integer arithmetic, we can use a left shift rather than a multiplication by 2
If the shift is faster than the multiply, then perform the substitution.
This optimization can often be used with induction variables because loops are
often indexed with simple expressions.
3.6.2) Cache Optimizations
A loop nest is a set of loops, one inside the other.
Loop nests occur when we process arrays.
A large body of techniques has been developed for optimizing loop nests.
Rewriting a loop nest changes the order in which array elements are accessed.
This can expose new parallelism opportunities that can be exploited by later
stages of the compiler, and it can also improve cache performance.
3.7)PROGRAM-LEVEL ENERGY AND POWER
ANALYSIS AND OPTIMIZATION
Power consumption is a important design metric for battery-powered systems.
It is increasingly important in systems that run off the power grid.
Fast chips run hot, and controlling power consumption is an important
element of increasing reliability and reducing system cost.
Power consumption reduction techniques.
To replace the algorithms with others that consume less power.
By optimizing memory accesses ,able to significantly reduce power.
To turn off the subsystems of CPU, chips in the system, in order to save power.
Measuring energy consumption for a piece of code
Program’s energy consumption how
much energy the program consumes.
To measure power consumption for an
instruction or a small code fragment.
It is used to executes the code under test
over and over in a loop.
By measuring the current flowing into the
CPU,we are measuring the power
consumption of the complete loop,
including both the body and other code.
By separately measuring the power
consumption of a loop with no body.
we can calculate the power consumption
of the loop body code as the difference b/w
the full loop and the bare loop energy cost of
an instruction.
List of the factors contribution for energy consumption of the program.
Energy consumption varies somewhat from instruction to instruction.
The sequence of instructions has some influence.
The opcode and the locations of the operands also matter.
Steps to Improve Energy Consumption
Try to use registers efficiently(r4)
Analyze cache behavior to find major cache conflicts.
Make use of page mode accesses in the memory system whenever possible.
Moderate loop unrolling eliminates some loop control overhead. when the loop
is unrolled too much, power increases.
Software pipelining reducing the average energy per instruction.
Eliminating recursive procedure calls where possible saves power by getting rid
of function call overhead.
Tail recursion can often be eliminated, some compilers do this automatically.
3.8) ANALYSIS AND OPTIMIZATION OF PROGRAM SIZE
Memory size of a program is determined by the size of its data and instructions.
Both must be considered to minimize program size.
Data provide an opportunity to minimizing the size of program.
Data buffers can be reused at several different points in program, which reduces
program size.
Some times inefficient programs keep several copies of data, identifying and
eliminating duplications can lead to significant memory savings.
Minimizing the size of the instruction text and reducing the number of
instructions in a program which reduces program size
Proper instruction selection may reduce code size.
Special compilation modes produce the program in terms of the dense
instruction set.
Program size of course varies with the type of program, but programs using the
dense instruction set are often 70 to 80% of the size of the standard instruction
set equivalents.
3.9)PROGRAM VALIDATION AND TESTING
Complex systems need testing to ensure the working behavior of the
systems.
Software Testingused to generate a comprehensive set of tests to ensure
that our system works properly.
The testing problem is divided into sub-problems and analyze each sub
problem.
Types of testing strategies
1. White/Clear-box Testing generate tests ,based on the program
structure.
2. Black-box Testing generate tests ,without looking at the internal
structure of the program.
3.9.1)Clear box testing
Testingrequires the control/data flow graph of a program’s source code.
To test the program exercise both its control and data operations.
To execute and evaluate the tests control the variables in the program and
observe the results .
The following three things to be followed during a test
1. Provide the program with inputs for the test.
2. Execute the program to perform the test.
3. Examine the outputs to determine whether the test was successful.
Execution PathTo test the program by forcing the program to execute along
chosen paths. ( giving it inputs that it to take the appropriate branches)
Graph Theory
•It help us get a quantitative handle on the different paths required.
•Undirected graph-form any path through the graph from combinations of basis
paths.
•Incidence matrix contains each row and column represents a node.
•1 is entered for each node pair connected by an edge.
Cyclomatic Complexity
It is a software metric tool.
Used to measure the control complexity of a program.
M = e – n + 2p.
e number of edges in the flow graph
n number of nodes in the flow graph
p number of components in the graph
Types of Clear Box test strategy
1. Branch testing
2. Domain testing
3. Data flow testing
3.9.1.1)Branch testing
This strategy requires the true and false branches of a conditional.
Every simple condition in the conditional’s expression to be tested at
least once.
if ((x == good_pointer) && (x->field1 == 3))
{ printf("got the value\n"); }
The bad code we actually wrote
if ((x = good_pointer) && (x->field1 == 3))
{ printf("got the value\n"); }
3.9.1.2)Domain testing
It concentrates on linear-inequalities.
The program should use for the test is j <= i + 1
We test the inequality with three test points
Two on the boundary of the valid region
Third outside the region but between the i values of the other two points.
3.9.1.3)Data flow testing
It use of def-use analysis (definition-use analysis).
It selects paths that have some relationship to the program’s function.
Compilers which use def-use analysis for Optimization.
A variable’s value is defined when an assignment is made to the variable.
It is used when it appears on the right side of an assignment.
3.9.2)Block Box Testing
Black-box tests are generated without knowledge of the code being tested.
It have a low probability of finding all the bugs in a program.
We can’t test every possible input combination, but some rules help us select
reasonable sets of inputs.
1. Random Tests
Random values are generated with a given inputs.
The expected values are computed first, and then the test inputs are
applied.
2. Regression Tests
When tests are created during earlier or previous versions of the
system.
Those tests should be saved apply to the later versions of the system.
It simply exercise current version of the code and possibly exercise
different bugs.
In digital signal processing systems Signal processing algorithms are
implemented to save hardware costs.
Data sets can be generated for the numerical accuracy of the system.
These tests can often be generated from the original formulas without
reference to the source code.
1. Marilyn Wolf, “Computers as Components – Principles of
Embedded Computing System Design”, Third Edition “Morgan
Kaufmann Publisher (An imprint from Elsevier), 2012.
(UNIT I, II, III, V)
2.Jane W.S.Liu,‖ Real Time Systems‖, Pearson Education, Third
Indian Reprint, 2003.(UNIT IV)
UNIT IV REAL TIME SYSTEMS
Types:
1. Hard Real-Time Systems
Missing a deadline can cause a significant loss to the application.
Examples: Flight control, Nuclear Power plant, Manufacturing control
2. Soft Real-Time Systems
Missing a deadline causes the quality of service to degrade, but nothing terrible
happens.
Examples: Video-on-demand, web site service, satellite based applications,
teleconferencing
Characteristics of a RTS
Large and complex
Vary from a few hundred lines of assembler or C
Concurrent control of separate system components
Devices operate in parallel in the real-world
Facilities to interact with special purpose hardware
Need to be able to program devices in a reliable and
abstract way
Mixture of Hardware/Software
Some modules implemented in hardware, even whole
systems
Deterministic
Able to predict with confidence the worst case response
times for systems
Challenges in RT System
Predictability
Able to predict the future consequences of current actions
Testability
Easy to test if the system can meet all the deadlines
Cost optimality
e.g. Energy consumption, memory blocks etc
Maintainability
Modular structure to ease system modification
Fault tolerance
Hardware and software failures should not cause the system
4.1)Structure of a Real Time System
Trigger generator used to trigger the execution of individual jobs. It is
not really a separate hardware unit, typically it is part of the executive
software.
The schedule for these jobs can be obtained offline and loaded as a
lookup table to be used by the scheduler.
Jobs can also be initiated depending on the state of the controlled
process or on the operating environment.
The output of the computer is fed to the actuators and the displays.
Fault tolerant techniques ensure the erroneous outputs from the
computer.
The actuators typically have a mechanical or a hydraulic component,
and so their time constants are quite high.
A control computer exhibits a dichotomy in terms of the data rates.
The sensors and actuators run at relatively low data rates.
The computer itself must be fast enough to execute the control
algorithms, and these can require throughputs in excess of 50 million
instructions per second(MIPS).
System separates into three areas
An outer low rate area consisting of the sensors, actuators, displays and
input panels.
A middle or peripheral area consisting of the processing that is
necessary to format the data from and to this layer properly.
The central cluster of processors where the control algorithms are
executed.
4.2)Estimating program run times
Real-time systems should meet deadlines; it is important to be able to
accurately estimate program run times.
Estimating the execution time of any given program is a very difficult
task and it depends on the following factors
a)Source code
Source code that is carefully tuned and optimized takes less time to
execute.
b)Compiler
The compiler maps the source-level code into a machine-level
program.
The actual mapping will depend on the actual implementation of the
particular compiler that is being used.
c)Operating system
The operating system determines such issues as task scheduling and
memory management, and also it determines the interrupt handling
overhead
Machine architecture
Executing a program may require much interaction between the
processors and the memory and I/O devices.
The interaction can take place over an interconnection network (e.g., a
bus) that can be shared by other processors.
The number of registers per processor affects how many variables can
be held in the CPU.
The greater the number of registers and the cleverer the compiler is in
managing these registers.
This results in reducing the memory-access time, and hence the
instruction-execution time.
The size and organization of the cache (if any) will also affect the
memory-access time, as will the clock rate.
To keep the contents of these memories, we need to periodically
refresh them
This is done by periodically reading the contents of each memory
location and writing them
1. First, assume that the variables b and c are not already in
the CPU registers and have to be fetched from the cache or
the main memory.
2. Second, the execution times of individual instructions
could be loose because they are data dependent.
4.2.2)Timing Estimation system
Preprocessor
The pre-processor produces compiled assembly language code and
marks off blocks of code to be analyzed.
Parser
The parser analyzes the input source program.
Procedure timer
It maintains a table of procedures and their execution time
Loop bounds
It obtains number of iterations for the various loops in the system.
Time schema
It computes the execution times of each block using the execution time
estimates computed by the code prediction module.
Code prediction
The code prediction module does this by using the code generated by
the pre-processor and using the architecture analyzer to include the
influence of the architecture.
4.2.3) ACCOUNTING FOR PIPELINING
The first stage pipeline stage instructions
from the main memory and writes them to a
prefetch buffer.
The second stage handles the operand
read/write operations.
Both the first and second stages will thus
have occasion to access the memory.
if the second stage needs to read one or more
operands from main memory, there is a one
cycle delay in handshaking with the first
stage.
Similarly, if it needs to write some operands,
there is a one cycle handshaking delay.
if the second stage wishes to access the
memory it will wait for any ongoing opcode
fetches to finish before accessing the
memory.
4.2.3) CACHES
The time taken by access depends on whether or not the word being
accessed is in the cache.
If it is not, it is the time to access the main memory, which is much
larger.
It is difficult to predict whether a given access will result in a cache
miss, since the cache contents are not easy to predict.
To determine accurately the presence or absence of a data block thus
requires that we know the sequence of accesses.
Conditional branches-Determine the actual execution path of the
program.
Preemptions-When task A is preempted by task B, the blocks that were
brought into the cache by task A may have to be removed to make
room for B's accesses.
Then A resumes execution it will encounter a flurry of cache misses.
This can be avoided by giving each task its own portion of the cache so
that during its lifetime, each task "owns" its portion and no other task
is allowed access to it.
4.3)Task Assignment and Scheduling
Each task has resource requirements.
All tasks require some execution time on a processor.
Also, a task may require a certain amount of memory or access to a bus
Release Time
It is the time at which all the data that are required to begin executing
the task are available.
Deadline
It is the time by which the task must complete its execution.
It may be hard or soft, depending on the nature of the corresponding
task.
Classification of Task
i)Periodic
A task Ti is periodic if it is released every period Pi seconds.
It requires the task to run exactly once every period
ii)Sporadic
The task is sporadic if it is not periodic.(may be invoked at
irregular intervals)
These tasks are characterized by an upper bound on the
rate at which they may be invoked.
The successive invocations of a sporadic task T, be
separated in time by atleast t(i) seconds.
iii)Aperiodic
These tasks which are not periodic and which also have no
upper bound on their invocation rate.
Task Assignment/Schedule
It is said to be feasible if all the tasks start after their release times and complete
before their deadlines.
The schedule can be defined as follows S: Set of processors xTimeSet of Tasks
(i) Precomputed (offline scheduling)
Involves scheduling in advance of the operation, with specifications of when the
periodic tasks will be run and slots for the sporadic/aperiodic tasks in the event that
they are involved.
(ii) Dynamically (online Scheduling)
The tasks are scheduled as they arrive in the system.
The algorithms used in online scheduling must be fast and it takes to meet their
deadlines is clearly useless.
Algorithms
(1) Static priority algorithm-The task priority does not change within a mode.
Ex: Rate-Monotonic (RM) algorithm
(ii) Dynamic priority algorithm-The task priority can change with time.
Ex: Earliest Deadline First (EDF) algorithm.
4.3.1. Classical Uniprocessor Scheduling Algorithms
Uniprocessor scheduling is part of
the process of developing
multiprocessor schedule.
The goal of these algorithms is to
meet all task deadlines.
The following assumptions are made
for both the RM and EDF algorithms.
1. No task has any non-preemptive
section and the cost of preemption is
negligible.
2. Only processing requirements are
significant; memory, I/O and other
resource requirements are negligible,
3. All tasks are independent; there are
no precedence constraints.
4.3.1.a)Rate-Monotonic Scheduling
Algorithm(RMS)
It is a uniprocessor static-priority preemptive scheme.
The following assumptions are required for algorithm.
All tasks in the task set are periodic.
The relative deadline of a task is equal to its period.
The priority of a task is inversely related to its period.(If task Ti has a
smaller period than task Tj also Ti has higher priority than Tj. Higher
priority tasks can preempt lower-priority tasks)
Example
There are three tasks, with P, = 2, P₂ = 6, P, 10. The execution times are
e₁=0.5, e₂ = 2.0, e,= 1.75 and I1 = 0, I2=1, I3=3. Since P₁ <P₂ <P3, task T1
has highest priority. Every time it is released, it preempts whatever is
running on the processor. Similarly, task T3, cannot execute when
either task T₁ or T2, unfinished
Utilization Bound
Allocate tasks one by one to the appropriate processor class until all the
tasks have been scheduled, adding processors to classes if that is needed
for RM schedulability
4.3.3c) Bin-packing Assignment Algorithm for EDF
4.3.3d)Myopic Offline Scheduling (MOS) Algorithm
This algorithm suitable for non-preemptive tasks.It is an offline algorithm in
that takes in advance the entire set of tasks, their arrival times, execution times
and deadlines.
MOS proceeds by building up a schedule tree.
Each node in this tree represents an assignment and scheduling of a subset of
the tasks.
The root of the schedule tree is an empty schedule.
Each child of a node consists of a schedule of its parent node, extended by one
task.
A leaf of this tree consists of a schedule of the entire task set.
Algorithm steps
1. start at the root node, which is an empty schedule
2. Proceed to build the tree from that point by developing nodes.
A node n is developed as follows.
1. Given a node n, try to extend the schedule represented by that node by one
more task.
2.Pick up one of the as yet unscheduled tasks and try to add it to the schedule
represented by node n.
3. The augumented schedule is a child node of n.
4.3.3e) Focused Addressing and Bidding (FAB) Algorithm
It is used for task sets consisting of both critical and non-critical real
time tasks.
Critical tasks must have sufficient time reserved for them so that they
continue execute successfully.
The Non-critical tasks are either processed or not, depending on the
system's ability do so.
Each processor maintains a status table that indicates which
tasks(critical tasks and any additional noncritical tasks) it has already
committed to run.
It maintains a table of the surplus computational capacity at every
other processor in the system.
The time axis is divided into windows, which are intervals of fixed
duration and each processor regularly sends to its colleagues the
fraction of the next window that is currently free.
Since the system is distributed, this information may never be
completely up to date.
It also computes the latest time at which the focussed processor can
offload the task onto a bidder without the task deadline being missed.
Offload time is given by the expression.
toffload =Task deadline - (current time + time to move the task+ task-
execution time)
When processor P, receives an RFB, it checks to see if it can meet the
task requirements and still execute its already-scheduled tasks
successfully.
First, estimates when the new task will arrive and how long it will take
to be either guaranteed or rejected.
Arrive time is given by
tarr = Current time +time for bid to be received by Ps+ time taken by Ps
to make a decision+ time taken to transfer the task+ time taken by P, to
either guarantee or reject the task
computational time
tcomp = time allotted to critical tasks in [tarr ,D]+ time needed in [tarr,D]
to run already-accepted noncritical tasks+ fraction of recently accepted
bidsx time needed in [tarr, DJ to honor pending bids
4.4)Fault Tolerance Techniques
It is the ability of a system to maintain its functionality,even in the
presence of faults.
FaultIt is a defect or flow that occurs in some hardware or software
component.
ErrorIt is a manifestation of a fault.
FailureIt is a departure of a system from the service required.
Types of Faults
Hardware fault
It is some physical defect that can cause a component to malfunction.
A broken wire or the output of a logic gate that is perpetually stuck
some logic value (0 or 1) are hardware faults.
Software Faults
A software fault is a "bug" that can cause the program to fail for a given
set of inputs.
Faults latency
It is the duration between the onset of
a fault and its manifestation as an error.
Faults themselves are invisible to the
outside world, only showing themselves
when they cause errors such latency
can impact the reliability of the overall
system.
Error Recovery
It is the process by which the system
attempts to recover from the effects of an
error.
Forward error recovery- the error is masked
without any computations having to be
redone.
Backward error recovery- the system is
rolled back to a moment in time before the
error is believed to have occurred and the
computation is carried out again.
Failures Causes
(i) Errors in the specifications or design
(ii) Defects in the components and
(iii) Environmental effects
Fault Types
Faults are classified according to their temporal behavior and outpat
behavior.
Temporal Behaviour Classification
1.Permanent- does not die away with time but remains until it is repaired or
the affected unit is replaced
2. Intermittent- faults cycles between the fault active and fault benignstates.
3.TransientPermanent- It is hard to catch. Since quite often by the time the
system has recognized that such a failure has occurred it has disappeared,
leaving behind no permanent defect that can .be located
4.4.1)Fault detection
(i) Online detection
Goes on in parallel with normal system operation.
Fetching an opcode from a location containing data.
Writing into a portion of memory to which the process has no write access.
Fetching an illegal opcode.
Inactive for more than a prescribed period.
A monitor (watch dog processor) is associated with each processor, looking for signs
that the processor is faulty.
(ii) Offline detection
When a processor is running such a test, it obviously cannot be executing the
applications software.
Diagnostic tests can be scheduled just like ordinary tasks.
4.4.3) Fault and Error Containment
Fault containment
When a fault-free processor can put out erroneous result
of using erroneous input from a faulty unit.
i) Fault-containment zones (FCZ)
It is a subset of the system that operates correctly despite
arbitrary logical or electrical faults outside the subset.
ii) Error-containment zones (ECZ)
Used to prevent errors from propagating across zone
boundaries.
4.4.3)Redundancy
4.4.3.1)Hardware Redundancy
It is an additional hardware to compensate for failures.
It can be used in two ways.
1. First in use for fault detection, correction and masking.
2. The second is use of hardware redundancy is to replace the
malfunctioning units.
Multiple hardware units may be assigned to do the same task in parallel
and their results compared.
If only a minority of the units are faulty and a majority of the units we can
produce the same output, we can use this majority result .
If more than a minority of the units disagree, repeating the computation
on other processors, to correct for the faults.
Voting and Consensus
Multiple units execute the same task and compare their outputs.
If atleast three units are involved, this comparison can choose
the majority value a process called voting and thus mask the
effects of some failures.
If two units are used, the comparison can detect (but not correct)
an error.
The designer must decide whether exact or approximate
agreement is expected between functioning units.
Formalized majority voter- Assume that if d(x₁,x₂)≤ε then x1 and
x2 are sufficiently equal for all practical purposes
Generalized K-plurality voter- chooses any output from the
largest partition Pi,so long as Pi, contains atleast K elements
Generalized median voter-The generalized median voter works
by selecting the middle value.
Static pairing
The pair runs identical software using identical inputs and compares
the output of each task.
If the outputs are identical, the pair is functional.
If either processor the pair detects nonidentical outputs, that is an
indication that at least one of the processors in the pair is faulty.
The processor that detects this discrepancy switches off the interface
to the rest of the system, thus isolating this pair
N-Modular Redundancy(NMR)
It is a scheme for forward error recovery.
It works by using N processors instead of one and voting on their
output.
N is usually odd.
For the moment assume that the signal propagation times are zero consider a three-
clock system, where ti, is the Real time when clock Ci sends its signal.
The middle clock is chosen as the correct clock, and the other two t align themselves
with this clock.
It is tempting to do this by having each clock correct as soon as it can by moving
clock C1, back by t2-t₁ at real time t2 and clock C3, forward t3-t2 at Real time t3
However, this is not acceptable, since a process which was using clock C3, would see
time moving moving backwards.
For example, suppose this process time stamped event X at Real time tx
and event Y at real time ty .
Y occurs after X, but due to the
clock adjustment, its time stamp
will make it appear as if occured
before X.
This illustrates why we should
never turn a clock back in the
process of synchronization. It is also
a bad idea to introduce a jump in
the clock.
Instead of making such immediate,
and inadvisable, adjustments, we
amortize the adjustments (i.e) we
adjust the clocks so that at the next
comparison point, they try to be
aligned.
Clock C₁ will slow itself down and
clock C3, will speed itself up so that
their next clock ticks will align as
closely as possible with the next
clock tick of clock C₂.
An interval of nominal duration TC- units may actually be anything in the
range [1-ρ) T, (1 + ρ) T] r- units. Hence C1 can deliver its next clock tick in the r-
interval.
I₁=[(1- ρ) T+t₂+μ₂,1- x, (1 + ρ)T + t₂ + μ₂,1-x]
By a similar reasoning, C3, delivering its next clock tick in the r-interval
I2=[(1- ρ) T+t₂+μ₂,3- x, (1 + ρ)T + t₂ + μ₂,3-x]
Clock C₂ delivers its next clock tick in the r-interval
I2=[(1- ρ) T+t₂, (1 + ρ)T + t₂ ]
In the worst case, if μ₂,1 = μmin and clock C1 is running as fast as is legally
allowed, the next C1, tick will occur at r-time (1- ρ)T+t₂+ μmin –x and also
C3, is running as slow as is legally allowed, the next C3, tick will occur r time
(1+ρ)T+t₂+ μmin –x
The clock skew will then be
[(1+ρ)T+t₂+ μmax –x]-[(1- ρ) T+t₂+ μmin –x ]=2 Ρt+ μmax –μmin
FAULT-TOLERANT SYNCHRONIZATION IN HARDWARE
To synchronize in hardware, we can use phase-locked loops.
The objective is to align, as closely as possible, the output of the
oscillator with an oscillatory signal input.
The comparator puts out a signal that is proportional to the difference
between the phase of the input and that of the oscillator.
This is passed through a filter, and the resultant signal is used to
modify the frequency of a voltage-controlled oscillator (VCO).
Let us carry out a simple analysis of phase-locked loops.
The output voltage of the comparator at any time is proportional to the
difference between the phase of the signal input, ϕr(t), and that of the
VCO , ϕr(t)
Vc(t)= Kc{(ϕi(t)-ϕr(t)}
SYNCHRONIZATION IN SOFTWARE
When the extremely tight synchronization is provided by phase-
locking is not needed, synchronization can be carried out in software.
In software based synchronization, we have an underlying hardware
clock, and a software based correction. The clock time is the sum of the
hardware time and the correction.
A new correction is calculated at regular resynchronization intervals. It
is sometimes helpful to think of the process as starting a new clock at
every resynchronization interval, defined by the new correction value.
For example, consider the following equation
y≥α+β+ αβ
If α and β are very small quantities, then αβ is even smaller, and so
above equation can be rewritten
y≥α+β
Interactive convergence Averaging Algorithm CA1
Interactive Convergence Averaging Algorithm- CA2
Algorithm CA2 differs from CA1 in which clock signals are ignored.
In CA1, a clock ignores those time messages that differ from its own by
specified amount Δ.
In CA2, a clock ignores the first m and the last messages.
The clock is aligned with a reference equal to the averaging of the clad signals
that are not ignored.
The CA2 algorithm is as follows.
Every time its clock reads a multiple of the resynchronization interval a clock
transmits its timing message to all the clocks in the system.
Message-transmission delays range from μmin to μmax
Define the average delay μavg =(μmin + μmax )/2
N is the total number of clocks and m is the maximum number of malicious
clocks that this system is designed to tolerate.
Clock Ci, receives a time message from Cj, at real time t(i,j)
It computes the quantities a (i,j) =t (i,j)- μavg and sorts them ascending order
Convergence Nonaveraging Algorithm-CAN
The CAN algorithm ensures the synchronization of nonfaulty clocks,
regardless of the number of faulty clocks in the system.
To do this, it uses encoding to authenticate messages.
That is a clock sends out an encoded timing signal that cannot be altered by
any other clock.
CAN algorithm, does not require that there be a direct link between two
communicating clocks.
It is sufficient that there be either a one-hop path or a multi-hop path.
If we define a graph with the clocks as the nodes and the clock-to-clock
connections as directed edges, it is sufficient for the graph to be connected.
A clock labels or signs each message that it sends out, so that the recipient
knows who the sender is.
This signature is encoded so that no other clock can alter it.
A message is said to be authentic when neither the message nor the signature
has been altered; the encoding is assumed to allow clocks to detect any
alternations.
As with convergence averaging algorithms, resynchronization happens regular
intervals. Each node starts a new logical clock resynchronization.
The algorithm consists of each clock adjusting itself suitably based the
messages it receives from the other clocks.
Resynchronization happens at least once every interval of length Unless it has
been preempted each nonfaulty clock C, waits un value equals some
prespecified waiting point w.
At that time, it sends out an encoded signed message saying, "the time W", to
all its neighbouring processors.
It then defines a new resynchronization point bound by incrementing by R. W
is a local variable, held at each clock.
A message that has passed through S clocks is sufficiently close if t arrives
within SD of clock C, 's waiting point, where D is a prespecified constant.
If this message is authentic, clock C, moves itself forward to W increments W
by R, and forwards the message to all its neighbours after adding its own
signature to it.
UNIT V
PROCESSES AND OPERATING SYSTEMS
Introduction – Multiple tasks and multiple processes – Multirate systems-
Preemptive real-time operating systems- Priority based scheduling-
Interprocess communication mechanisms – Evaluating operating
system performance- power optimization strategies for processes –
Example Real time operating systems-POSIX-Windows CE-Distributed
embedded systems – MPSoCs and shared memory multiprocessors. –
Design Example - Audio player, Engine control unit – Video accelerator.
5.1)INTRODUCTION
Simple applications can be programmed on a microprocessor by writing a single
piece of code.
But for a complex application, multiple operations must be performed at widely
varying times.
Two fundamental abstractions that allow us to build complex applications on
microprocessors.
1. Process→ defines the state of an executing program
2. operating system (OS)→provides the mechanism for switching execution
between the processes.
5.2)MULTIPLE TASKS AND MULTIPLE
PROCESSES
Systems which are capable of performing multiprocessing known as multiple
processor system.
Multiprocessor system can execute multiple processes simultaneously with the
help of multiple CPU.
Multi-tasking→ The ability of an operating system to hold multiple processes
in memory and switch the processor for executing one process.
3.2.1)Tasks and Processes
Task is nothing but different parts of functionality in a single system.
Eg-Mobile Phones
When designing a telephone answering machine, we can define recording a
phone call ,answering a call and operating the user’s control panel as distinct
tasks, at different rates.
Each application in a system is called a task.
5.2.2)Process
A process is a single execution of a program.
If we run the same program two different times, we have created two
different processes.
Each process has its own state that includes not only its registers but all
of its memory.
In some OSs, the memory management unit is used to keep each
process in a separate address space.
In others, particularly lightweight RTOSs, the processes run in the
same address space.
Processes that share the same address space are often called threads.
This device is connected to serial ports on both ends.
The input to the box is an uncompressed stream of bytes.
The box emits a compressed string of bits, based on a compression table.
•In this case, the initiation interval is equal to one fourth of the period.
•It is possible for a process to have an initiation rate less than the period even in
single-CPU systems.
•If the process execution time is less than the period, it may be possible to initiate
multiple copies of a program at slightly offset times.
Data dependencies among processes
•The system decoder process demultiplexes the audio and video data and
distributes it to the appropriate processes.
•Missing Deadline
•Missing deadline in a multimedia system may cause an audio or video glitch.
•The system can be designed to take a variety of actions when a deadline is
missed.
5.3.2)CPU Metrics
CPU metrics are described by initiation time and completion time.
Initiation time→It is the time at which a process actually starts executing on
the CPU.
Completion time→It is the time at which the process finishes its work.
The CPU time of process i is called Ci .
The CPU time is not equal to the completion time minus initiation time.
The total CPU time consumed by a set of processes is
A process goes into the waiting state when it needs data that it has finished all its work for
the current period.
A process goes into the ready state when it receives its required data, when it enters
a new period.
Finally a process can go into the executing state only when it has all its data, is ready to
run, and the scheduler selects the process as the next process to run.
5.3.4)Scheduling Policies
A scheduling policy defines how processes are selected for promotion from the
ready state to the running state.
Scheduling→Allocate time for execution of the processes in a system .
For periodic processes, the length of time that must be considered is the hyper period,
which is the least-common multiple of the periods of all the processes.
Unrolled schedule →The complete schedule for the least-common multiple of the
periods.
Types of scheduling
1. Cyclostatic scheduling or Time Division Multiple Access scheduling
Schedule is divided into equal-sized time slots over an interval equal to the length of the
hyperperiod H. (run in the same time slot)
•When the system begins execution,P2 is the only ready process, so it is selected for execution.
•At T=15, P1 becomes ready; it preempts P2 because p1 has a higher priority, so it execute
immediately
•P3’s data arrive at time 18, it has lowest priority.
•P2 is still ready and has higher priority than P3.
•Only after both P1 and P2 finish can P3 execute
5.4.4) Context Switching
To understand the basics of a context switch, let’s assume that the set of tasks is
in steady state.
Everything has been initialized, the OS is running, and we are ready for a timer
interrupt.
This diagram shows the application tasks, the hardware timer, and all the
functions in the kernel that are involved in the context switch.
vPreemptiveTick() → it is called when the timer ticks.
portSAVE_CONTEXT()→ swaps out the current task context.
vTaskSwitchContext ( ) →chooses a new task.
portRESTORE_CONTEXT()→ swaps in the new context
5.5) PRIORITY-BASED SCHEDULING
Operating system is to allocate resources in the computing system based on
the priority.
After assigning priorities, the OS takes care of the rest by choosing the highest-
priority ready process.
There are two major ways to assign priorities.
Static priorities→ that do not change during execution
Dynamic priorities→ that do change during execution
Types of scheduling process
1. Rate-Monotonic Scheduling
2. Earliest-Deadline-First Scheduling
5.5.1)Rate-Monotonic Scheduling(RMS)
Rate-monotonic scheduling (RMS)→ is one of the first scheduling policies
developed for real-time systems.
RMS is a static scheduling policy.
It assigns fixed priorities are sufficient to efficiently schedule the processes in
many situations.
RMS is known as rate-monotonic analysis (RMA), as summarized below.
All processes run periodically on a single CPU.
Context switching time is ignored.
There are no data dependencies between processes.
The execution time for a process is constant.
All deadlines are at the ends of their periods.
The highest-priority ready process is always selected for execution.
Priorities are assigned by rank order of period, with the process with the
shortest period being assigned the highest priority.
Example-Rate-monotonic scheduling
set of processes and their characteristics
In this case, Even though each process alone has an execution time significantly less than
its period, combinations of processes can require more than 100% of the available CPU
cycles.
During one 12 time-unit interval, we must execute P1 -3 times, requiring 6 units of CPU
time; P2 twice, costing 6 units and P3 one time, costing 3 units.
The total of 6 + 6 + 3 = 15 units of CPU time is more than the 12 time units available,
clearly exceeding the available CPU capacity(12units).
RMA priority assignment analysis
Response time→ The time at which the process finishes.
Critical instant→The instant during execution at which the task has the largest response
time.
Let the periods and computation times of two processes P1 and P2 be τ1, τ2 and T1, T2,
with τ 1 < τ 2.
let P1 have the higher priority. In the worst case we then execute P2 once during its period
and as many iterations of P1 as fit in the same interval.
Since there are τ2/ τ1 iterations of P1 during a single period of P2.
The required constraint on CPU time, ignoring context switching overhead, is
we give higher priority to P2, then execute all of P2 and all of P1 in one of P1’s periods in
the worst case.
Hyper-period is 60
Dead line Table
There is one time slot left at t= 30, giving a CPU utilization of 59/60.
EDF can achieve 100% utilization
RMS vs. EDF
Ex:Priority inversion
Low-priority process blocks execution of a higher priority process by keeping hold
of its resource.
Consider a system with two processes
Higher-priority P1 and the lower-priority P2.
Each uses the microprocessor bus to communicate to peripherals.
When P2 executes, it requests the bus from the operating system and receives it.
If P1 becomes ready while P2 is using the bus, the OS will preempt P2 for P1,
leaving P2 with control of the bus.
When P1 requests the bus, it will be denied the bus, since P2 already owns it.
Unless P1 has a way to take the bus from P2, the two processes may deadlock.
Eg:Data dependencies and scheduling
Data dependencies imply that certain combinations of processes can never occur. Consider the
simple example.
We know that P1 and P2 cannot execute at the same time, since P1 must finish before P2 can
begin.
P3 has a higher priority, it will not preempt both P1 and P2 in a single iteration.
If P3 preempts P1, then P3 will complete before P2 begins.
if P3 preempts P2, then it will not interfere with P1 in that iteration.
Because we know that some combinations of processes cannot be ready at the same time,
worst-case CPU requirements are less than would be required if all processes could be ready
simultaneously.
5.5)Inter-process communication mechanisms
It is provided by the operating system as part of the process abstraction.
Blocking Communication→ The process goes into the waiting state until it receives a
response
Non-blocking Communication→It allows a process to continue execution after
sending the communication.
Types of inter-process communication
1. Shared Memory Communication
2. Message Passing
3. Signals
5.5.1) Shared Memory Communication
The communication between inter-process is used by bus-based system.
CPU and an I/O device, communicate through a shared memory location.
The software on the CPU has been designed to know the address of the shared location.
The shared location has also been loaded into the proper register of the I/O device.
If CPU wants to send data to the device, it writes to the shared location.
The I/O device then reads the data from that location.
The read and write operations are standard and can be encapsulated in a procedural
interface.
CPU and the I/O device want to communicate through a shared memory block.
There must be a flag that tells the CPU when the data from the I/O device is ready.
The flag value of 0 when the data are not ready and 1 when the data are ready.
If the flag is used only by the CPU, then the flag can be implemented using a standard
memory write operation.
If the same flag is used for bidirectional signaling between the CPU and the I/O device,
care must be taken.
Consider the following scenario to call flag
1. CPU reads the flag location and sees that it is 0.
2. I/O device reads the flag location and sees that it is 0.
3. CPU sets the flag location to 1 and writes data to the shared location.
4. I/O device erroneously sets the flag to 1 and overwrites the data left by the CPU.
Ex: Elastic buffers as shared memory
The text compressor is a good example of a shared memory.
The text compressor uses the CPU to compress incoming text, which is then sent on a
serial line by a UART.
The input data arrive at a constant rate and are easy to manage.
But the output data are consumed at a variable rate, these data require an elastic buffer.
The CPU and output UART share a memory area—the CPU writes compressed characters
into the buffer and the UART removes them as necessary to fill the serial line.
Because the number of bits in the buffer changes constantly, the compression and
transmission processes need additional size information.
CPU writes at one end of the buffer and the UART reads at the other end.
The only challenge is to make sure that the UART does not overrun the buffer.
5.5.2) Message Passing
Here each communicating entity has its own message send/receive unit.
The message is not stored on the communications link, but rather at the senders/ receivers
at the end points.
Ex:Home control system
It has one microcontroller per household device—lamp, thermostat, faucet, appliance.
The devices must communicate relatively infrequently.
Their physical separation is large enough that we would not naturally think of them as
sharing a central pool of memory.
Passing communication packets among the devices is a natural way to describe
coordination between these devices.
5.5.3) Signals
Generally signal communication used in Unix .
A signal is analogous to an interrupt, but it is entirely a software creation.
A signal is generated by a process and transmitted to another process by the OS.
A UML signal is actually a generalization of the Unix signal.
Unix signal carries no parameters other than a condition code.
UML signal is an object, carry parameters as object attributes.
The sigbehavior( ) →behavior of the class is responsible for throwing the signal,
as indicated by<<send>>.
The signal object is indicated by the <<signal>>
5.6)Evaluating operating system performance
Analysis of scheduling policies is made by the following 4 assumptions
Assumed that context switches require zero time. Although it is often
reasonable to neglect context switch time when it is much smaller than the
process execution time, context switching can add significant delay in some
cases.
We have largely ignored interrupts. The latency from when an interrupt is
requested to when the device’s service is complete is a critical parameter of real
time performance.
We have assumed that we know the execution time of the processes.
We probably determined worst-case or best-case times for the processes in
isolation.
5.6.1)Context switching time
It depends on following factors
The amount of CPU context that must be saved.
Scheduler execution time.
5.6.2)Interrupt latency
Interrupt latency →It is the duration of time from the assertion of a device interrupt to
the completion of the device’s requested operation.
Interrupt latency is critical because data may be lost when an interrupt is not serviced in
a timely fashion.
let us try to find a schedule assuming that context switching time is zero
Now let us assume that the total time to initiate a process, including context switching
and scheduling policy evaluation, is one time unit.
•It is easy to see that there is no feasible schedule for the above release time sequence, since
we require a total of 2TP1 + TP2= 2 x (1+ 3) + (1 +3) = 11 time units to execute one period of P2
and two periods of P1.
Overhead was a large fraction of the process execution time and of the periods.
In most real-time operating systems, a context switch requires only a few hundred
instructions, with only slightly more overhead for a simple real-time
scheduler like RMS.
When the overhead time is very small relative to the task periods,
then the zero-time context switch assumption is often a reasonable approximation
assuming an average number of context switches per process and computing CPU
utilization can provide at least an estimate of how close the system is to CPU
capacity
Ex:Effects of scheduling on the cache
Consider a system containing the following three processes.
Each process uses half the cache, so only two processes can be in the cache at the same
time.
Appearing below is a first schedule that uses a least-recently-used cache replacement
policy on a process-by-process basis.
In the first iteration, we must fill up the cache, but even in subsequent iterations,
competition
among all three processes ensures that a process is never in the cache when it starts to
execute. As a result, we must always use the worst-case execution time.
Another schedule in which we have reserved half the cache for P1 is shown below. This
leaves P2 and P3 to fight over the other half of the cache.
In this case, P2 and P3 still compete, but P1 is always ready. After the first iteration, we
can use the average-case execution time for P1, which gives us some spare CPU time that
could be used for additional operations.
5.7)Power optimization strategies for processes
A power management policy is a strategy for determining when to perform
certain power management operations.
The system can be designed based on the static and dynamic power
management mechanisms.
Power saving straegies
Avoiding a power-down mode can cost unnecessary power.
Powering down too soon can cause severe performance penalties.
Re-entering run mode typically costs a considerable amount of time.
A straightforward method is to power up the system when a request is received.
Predictive shutdown
The goal is to predict when the next request will be made and to start the
system just before that time, saving the requestor the start-up time.
Make guesses about activity patterns based on a probabilistic model of
expected behavior.
This can cause two types of problems
The requestor may have to wait for an activity period.
In the worst case,the requestor may not make a deadline due to the delay
incurred by system
An L-shaped usage distribution
A very simple technique is to use fixed times.
If the system does not receive inputs during an interval of length Ton, it shuts down.
Powered-down system waits for a period Toff before returning to the power-on mode.
In this distribution, the idle period after a long active period is usually very short, and the
length of the idle period after a short active period is uniformly distributed.
Based on this distribution, shutdown when the active period length was below a threshold,
putting the system in the vertical portion of the L distribution.
Advanced Configuration and Power Interface (ACPI)
It is an open industry standard for power management services.
It is designed to be compatible with a wide variety of OSs.
A decision module →determines power management actions.
ACPI supports the following five basic global power states.
1. G3, the mechanical off state, in which the system consumes no power.
2. G2, the soft off state, which requires a full OS reboot to restore the machine to
working condition. This state has four sub-states:
S1, a low wake-up latency state with no loss of system context
S2, a low wake-up latency state with a loss of CPU and system cache state
S3, a low wake-up latency state in which all system state except for main
memory is lost.
S4, the lowest-power sleeping state, in which all devices are turned off.
3. G1, the sleeping state, in which the system appears to be off.
4. G0, the working state, in which the system is fully usable.
5. The legacy state, in which the system does not comply with ACPI.
5.8)Example Real time operating systems
5.8.1)POSIX
POSIX is a Unix operating system created by a standards organization.
POSIX-compliant operating systems are source-code compatible.
Application can be compiled and run without modification on a new POSIX
platform.
It has been extended to support real time requirements.
Many RTOSs are POSIX-compliant and it serves as a good model for basic
RTOS techniques.
The Linux operating system has a platform for embedded computing.
Linux is a POSIX-compliant operating system that is available as open source.
Linux was not originally designed for real-time operation .
Some versions of Linux may exhibit long interrupt latencies,
To improve interrupt latency,A dual-kernel approach uses a specialized kernel,
the co-kernel, for real-time processes and the standard kernel for non-real-
time processes.
Process in POSIX
A new process is created by making a copy of an existing process.
The copying process creates two different processes both running the same code.
The complex task is to ensuring that one process runs the code intended for the new process
while the other process continues the work of the old process .
Scheduling in POSIX
A process makes a copy of itself by calling the fork() function.
That function causes the operating system to create a new process (the child process) which is
a nearly exact copy of the process that called fork() (the parent process).
They both share the same code and the same data values with one exception, the return value
of fork().
The parent process is returned the process ID number of the child process, while the child
process gets a return value of 0.
We can therefore test the return value of fork() to determine which process is the child
childid = fork();
if (childid == 0) { /* must be the child */
/* do child process here */
}
execv() function takes as argument the name of the file that holds the child’s
code and the array of arguments.
It overlays the process with the new code and starts executing it from the
main() function.
In the absence of an error, execv() should never return.
The code that follows the call to perror() and exit(), take care of the case where
execv() fails and returns to the parent process.
The exit() function is a C function that is used to leave a process
childid = fork();
if (childid == 0) { /* must be the child */
execv(“mychild”,childargs);
perror(“execv”);
exit(1);
}
The wait functions not only return the child process’s status, in many
implementations of POSIX they make sure that the child’s resources .
The parent stuff() function performs the work of the parent function.
childid = fork();
if (childid == 0) { /* must be the child */
execv(“mychild”,childargs);
perror(“execl”);
exit(1);
}
else { /* is the parent */
parent_stuff(); /* execute parent functionality */
wait(&cstatus);
exit(0);
}
The POSIX process model
Each POSIX process runs in its own address space and cannot directly access the
data or code.
Real-time scheduling in POSIX
POSIX supports real-time scheduling in the POSIX_PRIORITY_SCHEDULING
resource.
POSIX supports Rate-monotonic scheduling in the SCHED_FIFO scheduling
policy.
It is a strict priority-based scheduling scheme in which a process runs until it is
preempted or terminates.
The term FIFO simply refers→ processes run in first-come first-served order.
POSIX semaphores
POSIX supports semaphores and also supports a direct shared memory mechanism.
POSIX supports counting semaphores in the _POSIX_SEMAPHORES option.
A counting semaphore allows more than one process access to a resource at a time.
If the semaphore allows up to N resources, then it will not block until N processes have
simultaneously passed the semaphore;
The blocked process can resume only after one of the processes has given up its
semaphore.
When the semaphore value is 0, the process must wait until another process gives up the
semaphore and increments the count.
POSIX pipes
Parent process uses the pipe() function to create a pipe to talk to a child.
Each end of a pipe appears to the programs as a file.
The pipe() function returns an array of file descriptors, the first for the write end and the
second for the read end.
POSIX also supports message queues under the _POSIX_MESSAGE_PASSING facility..
5.8.2)Windows CE
Windows CE is designed to run on multiple hardware platforms and
instruction set architectures.
It supports devices such as smart phones, electronic instruments etc..,
Applications run under the shell and its user interface.
The Win32 APIs manage access to the operating system.
OEM Adaption Layer (OAL)→ provides an interface to the hardware and software
architecture.
OAL → provides services such as a real-time clock, power management, interrupts, and a
debugging interface.
A Board Support Package (BSP) for a particular hardware platform includes the OAL and
drivers.
Memory Space
It support for virtual memory with a flat 32-bit virtual address space.
A virtual address can be statically mapped into main memory for key kernel-mode code.
An address can also be dynamically mapped, which is used for all user-mode and some
kernel-mode code.
Flash as well as magnetic disk can be used as a backing store
The top 1 GB is reserved for system elements such as DLLs, memory mapped files, and
shared system heap.
The bottom 1 GB holds user elements such as code, data, stack, and heap.
User address space in windows CE
Threads are defined by executable files while drivers are defined by
dynamically-linked libraries (DLLs).
A process can run multiple threads.
Threads in different processes run in different execution
environments.
Threads are scheduled directly by the operating system.
Threads may be launched by a process or a device driver.
A driver may be loaded into the operating system or a process.
Drivers can create threads to handle interrupts
Each thread is assigned an integer priority.
0 is the highest priority and 255 is the lowest priority.
Priorities 248 through 255 are used for non-real-time threads .
The operating system maintains a queue of ready processes at each
priority level.
Execution of a thread can also be blocked by a higher-priority thread.
Tasks may be scheduled using either of two policies: a thread runs until the end
of its quantum; or a thread runs until a higher-priority thread is ready to run.
Within each priority level, round-robin scheduling is used.
WinCE supports priority inheritance.
When priorities become inverted, the kernel temporarily boosts the priority of
the lower-priority thread to ensure that it can complete and release its
resources.
Kernel will apply priority inheritance to only one level.
If a thread that suffers from priority inversion in turn causes priority inversion
for another thread, the kernel will not apply priority inheritance to solve the
nested priority inversion.
Sequence diagram for an interrupt
Interrupt handling is divided among three entities
The interrupt service handler (ISH)→ is a kernel service that provides the first
response to the interrupt.
The ISH selects an interrupt service routine (ISR) to handle the interrupt.
The ISR in turn calls an interrupt service thread (IST) which performs most of
the work required to handle the interrupt.
The IST runs in the OAL and so can be interrupted by a higher-priority
interrupt.
ISR→determines which IST to use to handle the interrupt and requests the
kernel to schedule that thread.
The ISH then performs its work and signals the application about the updated
device status as appropriate.
kernel-mode and user-mode drivers use the same API.
5.9) Distributed Embedded Systems (DES)
It is a collection of hardware and software and its communication.
It also has many control system performance.
Processing Element (PE)is a basic unit of DES.
It allows the network to communicate.
PE is an instruction set processor such as DSP,CPU and Microcontroller.
Network abstractions
Networks are complex systems.
It provide high-level services such as data transmission from the other
components in the system.
ISO has developed a seven-layer model for networks known as Open Systems
Interconnection (OSI) models.
5.9.1)OSI model layers
Physical layer→ defines the basic properties of the
interface between systems, including the physical
connections, electrical properties & basic procedures
for exchanging bits.
Data link layer→ used for error detection and control
across a single link.
Network layer→ defines the basic end-to-end data
transmission service.
Transport layer→ defines connection-oriented
services that ensure that data are delivered in the
proper order .
Session layer→ provides mechanisms for controlling
the interaction of end-user services across a network,
such as data grouping and checkpointing.
Presentation layer→ layer defines data exchange
formats
Application layer→ provides the application interface
between the network and end-user programs.
5.9.2)Controller Area Network(CAN)Bus
It was designed for automotive electronics
and was first used in production cars in 1991.
It uses bit-serial transmission.
CAN can run at rates of 1 Mbps over a twisted
pair connection of 40 meters.
An optical link can also be used.
5.9.2.1)Physical-electrical organization of a CAN
bus
Each node in the CAN bus has its own
electrical drivers and receivers that connect
the node to the bus in wired-AND fashion.
When all nodes are transmitting 1s, the bus is
said to be in the recessive state.
when a node transmits a 0s, the bus is in the
dominant state.
5.9.2.2)Data Frame
Arbitration field→ The first field in the packet contains the packet’s destination address 11 bits
Remote Transmission Request (RTR) bit is set to 0 if the data frame is used to request data
from the destination identifier.
When RTR = 1, the packet is used to write data to the destination identifier.
Control field→ 4-bit length for the data field with a 1 in between.
Data field→0 to 64 bytes, depending on the value given in the control field.
CRC→ It is sent after the data field for error detection.
Acknowledge field →identifier signal whether the frame was correctly received.( sender puts a
bit (1) in the ACK slot , if the receiver detected an error, it put (0) value)
Arbitration
It uses a technique known as Carrier Sense Multiple Access with Arbitration on Message
Priority (CSMA/AMP).
When a node hears a dominant bit in the identifier when it tries to send a recessive bit, it
stops transmitting.
By the end of the arbitration field, only one transmitter will be left.
The identifier field acts as a priority identifier, with the all-0 having the highest priority
Error handling
An error frame can be generated by any node that detects an error on the bus.
Upon detecting an error, a node interrupts the current transmission.
Error flag field followed by an error delimiter field of 8 recessive bits.
Error delimiter field allows the bus to return to the quiescent state so that data frame
transmission can resume.
Overload frame signals that a node is overloaded and will not be able to handle the next
message. Hence the node can delay the transmission of the next frame .
5.9.2.3)Architecture of a CAN controller
When a master wants to write a slave, it transmits the slave’s address followed by the data.
When a master send a read request with the slave’s address and the slave transmit the data.
Transmission address has 7-bit and 1 bit for data direction.( 0 for writing from the master to
the slave and 1 for reading from the slave to the master)
A bus transaction is initiated by a start signal and completed with an end signal.
A start is signaled by leaving the SCL high and sending a 1 to 0 transition on SDL.
A stop is signaled by setting the SCL high and sending a 0 to 1 transition on SDL.
5.9.3.4)State transition graph for an I2C bus master
Starts and stops must be paired.
A master can write and then read by sending a start after the data transmission, followed
by another address transmission and then more data.
5.9.3.5)Transmitting a byte on the I2C bus
The transmission starts when SDL is pulled low while SCL remains high.
The clock is pulled low to initiate the data transfer.
At each bit, the clock goes high while the data line assumes its proper value of 0 or 1.
An acknowledgment is sent at the end of every 8-bit transmission, whether it is an
address or data.
After acknowledgment, the SDL goes from low to high while the SCL is high, signaling
the stop condition.
5.9.3.6)I2C interface in a microcontroller
System has a 1-bit hardware interface with routines for byte-level functions.
I2C device used to generates the clock and data.
Application code calls routines to send an address, data byte, and also generates the SCL
,SDL and acknowledges.
Timers is used to control the length of bits on the bus.
When Interrupts used in master mode, polled I/O may be acceptable.
If no other pending tasks can be performed, because masters initiate their own transfers.
5.9.4)ETHERNET
It is widely used as a local area network for general-purpose computing.
It is also used as a network for embedded computing.
It is particularly useful when PCs are used as platforms, making it possible to use
standard components, and when the network does not have to meet real-time
requirements.
It is a bus with a single signal path.
It supports both twisted pair and coaxial cable.
Ethernet nodes are not synchronized, if two nodes decide to transmit at the same
time,the message will be ruined.
5.9.4.1)Ethernet CSMA/CD algorithm
A node that has a message waits for the
bus to become silent and then starts
transmitting.
It simultaneously listens, and if it hears
another transmission that interferes with
its transmission, it stops transmitting and
waits to retransmit.
The waiting time is random, but weighted
by an exponential function of the number
of times the message has been aborted
5.9.4.2)Ethernet-Packet format
We have labeled the data transmissions on each arc ,We want to execute the task on the
platform below.
The platform has two processing elements and a single bus connecting both PEs. Here
are the process speeds:
As an initial design, let us allocate P1 and P2 to M1 and P3 to M2This schedule shows
what happens on all the processing elements and the network.
The schedule has length 19. The d1 message is sent between the processes internal to
P1 and does not appear on the bus.
Let’s try a different allocation. P1 on M1 and P2 and P3 on M2. This makes P2 run more
slowly. Here is the new schedule:.
The length of this schedule is 18, or one time unit less than the other schedule. The
increased computation time of P2 is more than made up for by being able to transmit a
shorter message on the bus. If we had not taken communication into account when
analyzing total execution time, we could have made the wrong choice of which processes
to put on the same processing element.
5.11) Audio player/MP3 Player
5.11.1)Operation and requirements
MP3 players use either flash memory or disk drives to store music.
It performs the following functions such as audio storage, audio decompression, and
user interface.
Audio compression→ It is a lossy process. The coder eliminates certain features of the audio
stream so that the result can be encoded in fewer bits.
Audio decompression→ The incoming bit stream has been encoded using a Huffman style
code, which must be decoded.
Masking→ One tone can be masked by another if the tones are sufficiently close in frequency.
Audio compression standards
Layer 1 (MP1) →uses a lossless compression of sub bands and simple masking model.
Layer 2 (MP2) →uses a more advanced masking model.
Layer 3 (MP3)→ performs additional processing to provide lower bit rates.
5.11.2)MPEG Layer 1 encoder
Filter bank→ splits the signal into a set of 32 sub-
bands that are equally spaced in the frequency
domain and together cover the entire frequency
range of the audio.
Encoder→It reduce the bit rate for the audio
signals.
Quantizer →scales each sub-band( fits within 6
bits ), then quantizes based upon the current scale
factor for that sub-band.
Masking model → It is driven by a separate Fast
Fourier transform (FFT), the filter bank could be
used for masking, a separate FFT provides better
results.
The masking model chooses the scale factors for
the sub-bands, which can change along with the
audio stream.
Multiplexer→ output of the encoder passes along
all the required data.
MPEG Layer 1 data frame format
A frame carries the basic MPEG data, error correction codes, and additional information.
After disassembling the data frame, the data are un-scaled and inverse quantized to
produce sample streams for the sub-band.
Video compression
•MPEG-2 forms the basis for U.S. HDTV
broadcasting.
• This compression uses several
component algorithms together in a
feedback loop.
•Discrete cosine transform (DCT) used in
JPEG and MPEG-2.
•DCT used a block of pixels which is
quantized for lossy compression.
•Variable-length coder→assign number of
bits required to represent the block.
5.13.1)Block motion Estimation
MPEG uses motion to encode one frame in
terms of another.
Block motion estimation→some frames are
sent as modified forms of other frames
During encoding, the frame is divided into
macro blocks.
Encoder uses the encoding information to
recreate the lossily-encoded picture, compares
it to the original frame, and generates an error
signal.
Decoder keep recently decoded frames in
memory so that it can retrieve the pixel values
of macro-blocks.
5.13.2).Concept of Block motion estimation
To find the best match between regions in the two frames.
Divide the current frame into 16 x 16 macro blocks.
For every macro block in the frame, to find the region in the previous frame that most
closely matches the macro block.
Measure similarity using the following sum-of-differences measure