EE8691 Embedded Systems
EE8691 Embedded Systems
in
www.Vidyarthiplus.in
UNIT I
INTRODUCTION TO EMBEDDED SYSTEMS
.in
part of a larger system.
ng
An embedded system is one thathas dedicated purpose softwareembedded in
computerhardware.
eri
It is a dedicated computerbased system for anapplication(s) or product. It maybe an
ine
independent system or apart of large system. Itssoftware usually embeds into aROM (Read Only
Memory) orflash.
g
En
―It is any device that includes aprogrammable computer but isnot itself intended to be
ageneral purpose computer.‖ –Wayne Wolf, Ref: 61
arn
D. Morton,Ref: 38
w.
.in
ng
eri
ine
Fig: Typical Embedded System Hardware Unit.
Program Flow and data path ControlUnit (CU) —includes a fetch unit forfetching
g
(b) DSP orTypically a Texas Instruments- C28xSeries, C54xx or C64xx orAnalog Devices
SHARC orTigerSHARC, Motorola 5600xx
.in
(f) A domain specific processor
ng
3. GPP or ASIP core (s)
GPP or ASIP integrated into either anApplication Specific Integrated Circuit
eri
(ASIC), or a Very Large ScaleIntegrated Circuit (VLSI) circuit or aFPGA core integrated with
processorunit(s) in a VLSI (ASIC) chip
ine
4. Application Specific SystemProcessor (ASSP)
g
• Speech processor
• Adaptive filtering processorEncryption engine
ww
• Decryption engine
• Communication protocol stackprocessor
• Java acceleratorExamples Java Accelerator NazoninCommunications Java codes run 15
to60 Times fast,Video Accelerator for fast VideoProcessing
6. Multi core processors ormultiprocessor system usingGPPs
Examples
• Multiprocessor system for Real timeperformance in a video-conferencesystem,
• Embedded firewall cum router, High-end cell phone.
.in
mouse or contact-lesssmart card.
Power Dissipation Management
ng
1. Clever real-time programming byWait and Stop instructions
2. Clever reduction of the clock rateduring specific set of instructions
3. Optimizing the codes and
eri
4. Clever enabling and disabling of useof caches or cache blocks
ine
(ii) Clock Oscillator Circuit and ClockingUnits
1. Appropriate clock oscillatorcircuit
g
2. Storing codes for system booting,initializing, Initial input data and Strings.
3. Storing Codes for RTOS.
ww
Interrupt Handling element for the externalport interrupts, IO interrupts, timer and
RTC interrupts, software interrupts andExceptions
(vi)Linking Embedded System Hardware
.in
• Linking and interfacing circuitfor theBuses by using the appropriatemultiplexers, and
ng
decoders,demultiplexers Interface the varioussystem units
eri
3. IO Communication Unit ine
a. Communication Driver(s):Network Ethernet or serial driverto communicate with
hostembedded system ExpansionFacility …
Serial Bus(es): For example, UART(512 kbaud/s), 1-wire CAN (33 kbps),
g
Industrial I2C (100kbps), SM I2C Bus(100 kbps), SPI (100 kbps), Faulttolerant CAN (110 kbps),
En
Serial Port(230 kbps), MicroWire (300 kbps), SCSI parallel (40 Mbps), Fast SCSI
(8M to 80 Mbps) , Ultra SCSI-3 (8Mto 160 Mbps), FireWire/IEEE 1394(400 Mbps, 72 meter),
arn
f. DAC
g. GPIB Interface Element
h. Pulse Dialling Element
i. Modem
j. Bluetooth, 802.11, IrDA,
1. ROM Image
• Final stage software also called ROMimage
(Just as an image is a unique sequence andarrangement of pixels, embedded softwareis also a
unique placement and arrangementat each ROM address of bytes forinstructions and data.)
.in
ng
eri
g ine
En
arn
Le
.in
A program or a small specific partcoded in the assembly language usingan Assembler (software
used fordeveloping codes in assembly).
ng
Three steps when using assemblylanguage
' Assembler',
'Linker' and eri
ine
'Locator'before finally burned at the ROM
g
En
arn
Le
w.
ww
C++ or Java
.in
ng
eri
g ine
main function,
task functions and
Le
library functions,
interrupt service routines
w.
the targeted hardware. C++ and Java are other languages used for software coding.
.in
ng
eri
g ine
En
Program Models
Sequential Programming Model
Object Oriented Programming Model
arn
.in
Device controls and functions by :
1. Calling an ISR (also called InterruptHandler Routine) on hardware orsoftware interrupt
ng
2. Placing appropriate bits at the controlregister or word.
3. Setting status flag(s) in the statusregister for interrupting, thereforerunning (driving) the
eri
ISR, Resettingthe status flag after interrupt service.
Device Manager for the devices and drivers
ine
Device Management software (usually a part of the OS) provide codes fordetecting the
presence of devices, forinitializing (configuring) these and fortesting the devices that are present.
g
Also includes software for allocatingand registering port(s) or device codesand data at
En
system (OS) and Real time operating system (RTOS), Concurrent Processes, tasks
or threads
w.
Performing multiple actions andcontrolling multiple devices and their ISRswith defined
real time constraints and with deadlines for these Task and ISRs priority allocations, their
preemptive scheduling, OS for providing deterministic performance during concurrent processing
and execution with hard(stringent) or soft timing requirements with priority allocation and pre-
emption. RTOS is needed when the tasks for thesystem have real time constraints anddeadlines for
finishing the tasks
Important RTOSes
.in
OS μCOS-II
ng
VxWorks
Windows CE
eri
OSEK
Linux 2.6.24 or RTLinux
ine
QNX
1. Editor,
2. Interpreter,
arn
3. Compiler,
4. Assembler and Cross Assembler, IDE,
Le
5. Prototyper
w.
Project Manager
To manage the files that associateswith a design stage project and keepseveral versions of
the source file(s) inan orderly fashion.
.in
o Missiles and Satellites,
o Computer Networking,
ng
o Digital Consumer Electronics, and
o Automotive
Applications
o Mobile phone eri
ine
o Digital camera
o Robots
g
o Multitasking Toys
o Microcontroller- based single or multi-displaydigital panel meter for voltage,
Le
.in
Computer networking systems, - forexamples, router, front-end processor in aserver, switch,
bridge, hub, and gateway
ng
For Internet appliances, there are numerous application systems
(i) Intelligentoperation, administration and maintenancerouter (IOAMR) in a distributed
(ii)
network,and
eri
Mail Client card to store e-mail andpersonal addresses and to smartly connectto a modem
ine
or server
g
Signal Tracking Systems - for examples, anautomatic signal tracker and a target tracker.
arn
graphic accelerator. Image Filtering, Image Processing, PatternRecognizer, Speech Processing and
Video Processing.
w.
A system that connects a pocket PC to theautomobile driver mobile phone and awireless
receiver. The system then connectsto a remote server for Internet or e-mail orto remote computer
at an ASP (applicationService Provider).A personal information manager usingframe buffers in
hand- held devices.
Thin Client to provide the disk-less nodeswith the remote boot capability.[Application of
thin- clients is accesses to adata center from a number of nodes; or in an Internet Laboratory
accesses to the Internetleased line through a remote Server]. Embedded Firewall / Router using
ARM7/multi-processor with twoEthernet interfaces and interfacessupport to for PPP, TCP/IP and
UDPprotocols.
Sophisticated Applications
Mobile Smart Phones and Computingsystems
Mobile computer
Embedded systems for wireless LAN andconvergent technology devices
Embedded systems for Video, Interactivevideo, broadband IPv6 (Internet Protocolversion
.in
6) Internet and other products, realtime video and speech or multimediaprocessing systems
ng
Embedded Interface and Networking systems using high speed (400 MHz plus), and
ultra high speed (10 Gbps) and largebandwidth: Routers, LANs, switches andgateways,
eri
SANs (Storage Area Networks), WANs (Wide Area Networks),Security products and
High-speed Networksecurity, Gigabit rate encryption rateproducts
ine
SYSTEM-ON-CHIP (SoC) AND USE OF VLSI CIRCUIT DESIGN TECHNOLOGY
g
En
VLSI chip
arn
SoC is a system on a VLSI chip that has all needed analog as well as digitalcircuits,
ww
.in
ng
eri
ine
SYSTEM-ON-CHIP
Embeds:
g
• Multiple processors,
En
• memories,
• multiple standard source solutions (IPCores),
arn
Embedding an ASIP
Processor with instruction set designedfor specific application on a VLSI chipfor example,
w.
68HC11xx,
HC12xx,
HC16xx8051,
80251 PIC 16F84 or
16C76, 16F876 and PIC18Microcontroller
Enhancements of ARM9/ARM7 ARM
Cortex M3 from Philips, Samsung and ST Microelectronics
.in
Signal decoding and decompression
Embedding an Accelerator
ng
Accelerate the execution of codes, forexample, a floating point coprocessoraccelerates the
mathematicaloperations and Java acceleratoraccelerates the Java code execution.
Embedding Single purpose processors
eri
For Dialling, Modulating, Transmitting. Demodulating and Receiving.
ine
Keypad interface and display interfacehandling.
Touch screen
g
SoC
Embedded processor GPP or ASIP core,
Le
Memories
Programmable logic device and FPGA (Field Programmable Gate Array) cores
Other logic and analog units.
IPs in SoC
IP –a standard source solution forsynthesizing a higher-level component byconfiguring a
core of VLSI circuit orFPGA core available as an IntellectualProperty, called (IP).
High Level Components with gate levelsophistication circuit much above level ofcounters
and registers.
IPs
Designer or designing company holdsthe copyright for the synthesizeddesign of a higher-
.in
level component forgate-level implementation of an IP.
One might have to pay royalty forevery chip shipped. An embeddedsystem may
ng
incorporate several IPs.
An IP may provide a design for adaptive filtering of a signal.
eri
full design for implementing HypertextTransfer Protocol (HTTP) or File Transfer
Protocol (FTP) to transmit a web page orfile on Internet.
ine
USB port controller, Bluetooth, GPSinterface, Wireless 802.11or 802.16interfaces
An FPGA consists of a large numberof programmable gates on a VLSIchip. There is a set
g
multiple processors.
Use of Xilinx Spartan-3 90 nm based FPGAs with Power PCs(2003 )
w.
UNIT II
A port is a device to receive the bytes from external peripheral(s) [or device(s) or
processor(s) or controllers] for reading them later using instructions executed on the processor to
.in
send the bytes to external peripheral or device or processor using instructions executed on
processor.
ng
A Port connects to the processor using address decoder and system buses. The processor
uses the addresses of the port-registers for programming the port functions or modes, reading port
eri
status and for writing or reading bytes. ine
Example
SI serial interface in 8051
SPI serial peripheral interface in 68HC11
g
IO Port Types
Types of Serial ports
Le
Types of parallel ports
Parallel port one bit Input
Parallel one bit output
Parallel Port multi-bit Input
Parallel Port multi-bit Output
Inter-processor data transfer, reading from CD or hard disk, audio input, video input, dial
tone, network input, transceiver input, scanner input, remote controller input, serial I/O bus input,
writing to flash memory using SDIO (Secure Data Association IO based card).
.in
ng
eri
g ine
En
arn
receiver port pin. The port synchronizes the serial data input bits with clock bits. Each bit
in each byte as well as each byte in synchronization
w.
The bytes are received at constant rates. Each byte at input port separates by 8T and data
transfer rate or the serial line bits is (1/T) bps. [1bps = 1 bit per s]
Serial data and clock pulse-inputs
On same input line − when clock pulses either encode or modulate serial data input bits
suitably. Receiver detects the clock pulses and receives data bits after decoding or
demodulating.
On separate input line − When a separate SCLK input is sent, the receiver detects at the
middle or+ ve edge or –ve edge of the clock pulses that whether the data-input is 1 or 0 and
saves the bits in an 8-bit shift register. The processing element at the port (peripheral) saves
the byte at a port register from where the microprocessor reads the byte.
Master output slave input (MOSI) and Master input slave output (MISO)
MOSI when the SCLK is sent from the sender to the receiver and slave is forced to
synchronize sent inputs from the master as per the inputs from master clock.
MISO when the SCLK is sent to the sender (slave)from the receiver (master) and slave is
forced to synchronize for sending the inputs to master as per the master clock outputs.
.in
Synchronous serial input is used for interprocessor transfers, audio inputs and streaming
data inputs.
ng
eri
g ine
En
arn
Le
audio Input/output, video Input/output,dialer output, network device output, remote TV Control,
transceiver output, and serial I/O bus output or writing to flash memory using SDIO
ww
.in
ng
eri
g ine
En
Each bit in each byte is in synchronization at input and each bit in each byte is in
Le
when input/output clock pulses either suitably modulate or encode the serial input/output,
respectively. If clock period = T, then data transfer rate is (1/T)bps.
ww
The processing element at the port (peripheral)sends and receives the byte at a port register
to or from where the microprocessor writes or reads the byte
.in
ng
eri
ine
Asynchronous Serial port line RxD (receive data).
g
Does not receive the clock pulses or clock information along with the bits.
En
Each bit is received in each byte at fixed intervals but each received byte is not in
synchronization.
arn
protocol
w.
Asynchronous serial input is used for keypad inputs and modem inputs in computers
Keypad controller serial data-in, mice, keyboard controller, modem input, character send
inputs on serial line [also called UART (universal receiver and transmitter) input when
according to UART mode]
.in
ng
UART protocol serial line format eri
ine
Starting point of receiving the bits for each byte is indicated by a line transition from 1to 0
for a period = T. [T−1 called baud rate.]
g
If sender‘s shift-clock period = T, then a byte at the port is received at input in period=
En
10.T or 11.T due to use of additional bits at start and end of each byte. Receiver detects n
bits at the intervals of T from the middle of the start indicating bit. The n = 0, 1, …, 10 or
arn
11 and finds whether the data-input is 1 or 0 and saves the bits in an 8-bit shift register.
Processing element at the port (peripheral)saves the byte at a port register from where the
microprocessor reads the byte.
Le
Each bit in each byte transmit at fixed intervals but each output byte is not in
synchronization (separates by a variable interval or phase difference). Minimum separation
ww
Synchronous serial output is also called UART output if serial output is according to
UART protocol
Example Serial Asynchronous Output
_ Output from modem, output for printer, the output on a serial line [also called UART output
when according to UART]
Half Duplex
Half duplex means as follows: at an instant communication can only be one way (input or
output) on a bi-directional line.
.in
An example of half-duplex mode─ telephone communication. On one telephone line, the
talk can only in the half duplex way mode.
ng
Full Duplex
Full duplex means that at an instant,the communication can be both ways.
eri
An example of the full duplexasynchronous mode of communicationis the communication between
themodem and the computer though TxDand RxD lines or communication using
ine
SI in modes 1, 2 and 3 in 8051
Parallel Port single bit input
g
Presence of a magnetic piece in the vicinityof or within reach of a robot arm to its endpoint
and Filling of a liquid up to a fixed level.
Parallel Port Output- single bit
Le
PWM output for a DAC, which controlsliquid level, or temperature, or pressure, orspeed or
angular position of a rotating shaftor a linear displacement of an object or ad.c. motor
w.
control
Pulses to an external circuit
ww
.in
Touch screen in mobile phone
Ports or DevicesCommunication and communicationprotocols
ng
Two Modes of communication between the devices and computer system
Full Duplex – Both devices or device and computer system simultaneously communicate each
other.
eri
Half Duplex – Only one device can communicate with another at an instance
ine
Three ways of communication betweenthe ports or devices
1. Synchronous
g
2. Iso-synchronous
En
3. Asynchronous
1. Synchronous and Iso-synchronous Communication in Serial Ports or Devices Synchronous
arn
Communication.
When a byte (character) or a frame (acollection of bytes) in of the data isreceived or
transmitted at the constanttime intervals with uniform phasedifferences, the communication
Le
Synchronous Communication
Clock information is transmittedexplicitly or implicitly insynchronous communication.
Thereceiver clock continuously maintainsconstant phase difference with thetransmitter clock. Bits
of a data framemaintain uniform phase differenceand are sent within a fixed maximumtime
interval.
.in
Code bits precede the data bits.
May be inversion of code bits after each frame incertain protocols.
ng
Flag bits at start and end are also used in certainprotocols. Always present
Synchronous device portdata bits
eri
Reciprocal of T is the bit per second(bps).
Data bits─ m frame bits or 8 bitstransmit such that each bit is at the linefor time ΔT
ine
or, each frame is at the linefor time (m. T)m may be 8 or a large number. Itdepends
on the protocolSynchronous device clock bits
g
Clock bits ─ Either on a separate clockline or on data line such that the
En
.in
ng
eri
ine
First characteristics of synchronouscommunication
g
1. Bytes (or frames) maintain a constant phasedifference, which means they are
En
allthe bytes (or frames) serially. Mostly, theclock is not always implicit to thesynchronous data
receiver. The transmittergenerally transmits the clock rate information
w.
unsynchronized, but ofsame frequency and variable phasedifferences between bytes or bits of
twodata frames, which may not be sentwithin any prefixed time interval.
Example of asynchronous communication
• UART Serial, Telephone or modemcommunication.
• RS232C communication between the UARTdevices
• Each successive byte can have variabletime-gap but have a minimum in-betweeninterval
and no maximum limit for fullframe of many bytes
1. Bytes (or frames) need not maintain a constantphase difference and are asynchronous,
i.e., notin synchronization. There is permission to sendeither bytes or frames at variable
timeintervals─ Thisfacilitates in-betweenhandshaking between the serial transmitter portand serial
receiver port
2. Though the clock must ticking at a certain ratealways has to be there to transmit the bits
.in
of asingle byte (or frame) serially, it is alwaysimplicit to the asynchronous data receiver and
isindependent of the transmitter
ng
Clock Features
_ The transmitter does not transmit (neitherseparately nor by encoding using
eri
modulation)along with the serial stream of bits any clockrate information in the
asynchronouscommunication and receiver clock thus is notable to maintain identical frequency
ine
andconstant phase difference with transmitter clock
Example: IBM personal computer has two COMports (communication ports)
g
ready(DTR) signal.
After DTR, request to send (RTS) signal is sent at aninstance t3
ww
_ Receiving end responds by clear to send (CTS) signalat an instance t4. After the
response CTS, the data bitsare transmitted by modem from an instance t5 to
thereceiver terminal.
_ Between two sets of bytes sent in asynchronous mode,the handshaking signals
RTS and CTS can again beexchanged. This explains why the bytes do not
remainsynchronized during asynchronous transmission.
.in
ng
eri
ine
3. Communication Protocols
1. Protocol
A protocol is a standard adopted,which tells the way in which the bits ofa frame must be
g
[Even in personal communication wefollow a protocol – we say Hello! Thentalk and then say good
bye!]
arn
.in
ADSL
_ For networking the physical devices intelecommunication and computer networks −
ng
Ethernet and token ring protocols used in LANNetworks
Protocols in embedded network devices
o _ For Bridges and routers
eri
o _ Internet appliances application protocolsand Web protocols ─HTTP (hyper
ine
texttransfer protocol), HTTPS (hyper texttransfer protocol Secure Socket
Layer),SMTP (Simple Mail Transfer Protocol),POP3 (Post office Protocol version
g
.in
• A device, which counts the input dueto the events at irregular or regularintervals.
• The counts gives the number of inputevents or pulses since it was last read.
ng
• Has a register to enable read of presentcounts
• Functions as timer when countingregular interval clock pulses
eri
_ Has an input pin (or a control bit incontrol register) for resetting it for allcount bits = 0s.
_ Has an output pin (or a status bit instatus register) for output when allcount bits = 0s after
ine
reaching themaximum value, which also meansafter timeout or overflow.
g
En
.in
ng
eri
ine
Free running Counter (Blind runningCounter)
g
fixed intervals
• A pre-scalar for the clock input pulses to fixthe intervals
arn
instance
_ comparing of counts on the events for futureActions
ww
.in
ng
eri
Free running (blind counting) device ManyApplications Based on
ine
_ comparing the count (instance) withthe one preloaded in a compare register[an additional
register for defining aninstance for an action]
_ capturing counts (instance) in anadditional register on an input event.
g
[An addition input pin for sensing anevent and saving the counts at theinstance of event and taking
En
action.]
Free running (Blind Counts) input OCenablepin (or a control bit in controlregister)
arn
• For enabling an output when all count bits atfree running count = preloaded counts in
thecompare register.
• At that instance a status bit or output pin alsosets in and an interrupt ‗OCINT‘ ofprocessor
Le
fromanother event
ww
Free running (Blind Counts) input capture -enable pin (or a control bit in controlregister)
for Instance of Event Capture
• A register for capturing the counts onan instance of an input (0 to 1 or 1 to 0or toggling)
transition
_ A status bit can also sets in andprocessor interrupt can occur for thecapture event
Free running (Blind Counts) Pre-scaling
• Prescalar can be programmed as p = 1, 2,4, 8, 16, 32, .. by programming a prescalerregister.
•Prescalar divides the input pulses as perthe programmed value of p.
.in
which, once the system starts, does notstop and can't be reset and its countvalue can't be
reloaded. Real timeendlessly flows and never returnsback!] Real Time Clock is set for
ng
ticksusing prescaling bits (or rate set bits) inappropriate control registers.
Initiating an event after a preset delaytime. Delay is as per count valueloaded.
eri
Initiating an event (or a pair of eventsor a chain of events) after acomparison(s) with
between the pre-settime(s) with counted value(s). [It issimilar to a preset alarm(s).].
ine
Apreset time is loaded in a CompareRegister. [It is similar to presetting analarm].
Capturing the count value at the timeron an event. The information of time(instance of the
g
Finding the time interval between twoevents. Counts are captured at eachevent in capture
register(s) and read.The intervals are thus found out.
arn
Wait for a message from a queue ormailbox or semaphore for a preset timewhen using
RTOS. There is aApredefined waiting period is donebefore RTOS lets a task run.
Watchdog timer.
Le
instead of the clockinputs. The timer acts as a counter if, inplace of clock inputs, the inputs
aregiven to the timer for each instance tobe counted.
_ Scheduling of various tasks. A chain ofsoftware-timers interrupt and RTOSuses these
interrupts to schedule thetasks.
_ Time slicing of various tasks. Amultitasking or multi-programmedoperating system
presents the illusion thatmultiple tasks or programs are runningsimultaneously by
switching betweenprograms very rapidly, for example, afterevery 16.6 ms.
.in
_ A software, which executes andincreases or decreases a count-variable(count value) on an
interrupt from on asystem timer output or from on a realtimeclock interrupt.
ng
_ The software timer also generateinterrupt on overflow of count-value oron finishing value of the
countvariable.
• This input is common to all the SWTs thatare in the list of activated SWTs.
• Any number of SWTs can be made active ina list.
ww
• Each SWT will set a status flag on itstimeout (count-value reaching 0).
.in
ng
eri
ine
• Actions are analogous to that of ahardware timer. While there is physicallimit (1, 2 or 3 or
4) for the number ofhardware timers in a system, SWTscan be limited by the number
g
SWTs
SERIAL BUSCOMMUNICATION PROTOCOLS– I2C
arn
Interconnecting number of device circuits, Assume flash memory, touch screen,ICs for
measuring temperatures andICs for measuring pressures at anumber of processes in a plant.
Le
_ ICs mutually network through acommon synchronous serial bus I2C An 'Inter Integrated Circuit'
(I2C) bus,a popular bus for these circuits.
w.
.in
ng
eri
ine
Originally developed at PhilipsSemiconductors
Synchronous Serial Communication 400kbps up to 2 m and 100 kbps forlonger distances
Three I2C standards
g
I2C Bus
_ The Bus has two lines that carry itssignals— one line is for the clock andone is for bi-
Le
directional data.
_ There is a standard protocol for the I2Cbus.
Device Addresses and Master in the I2C bus
w.
_ Each device has a 7-bit address usingwhich the data transfers take place.
ww
_ However, at an instance, master is one,which initiates a data transfer on SDA(serial data) line
and which transmits theSCL (serial clock) pulses. From master, adata frame has fields beginning
from startbit
.in
ng
eri
g ine
_ Fourth field of 1 control bit─ defineswhether is the present data is anacknowledgment (from
slave)
_ Fifth field of 8 bits─ I2C device data byte
w.
_ Sixth field of 1-bit─ bit NACK (negativeacknowledgement) from the receiver. Ifactive then
ww
acknowledgment after a transferis not needed from the slave, elseacknowledgement is expected
from theslave
_ Seventh field of 1 bit ─ stop bit like in anUART
Disadvantage of I2C bus
• Time taken by algorithm in thehardware that analyzes the bits throughI2C in case the slave
hardware does notprovide for the hardware that supportsit.
• Certain ICs support the protocol andcertain do not.
• Open collector drivers at the masterneed a pull-up resistance of 2.2 K oneach line
.in
ng
eri
g ine
En
arn
Le
Three standards:
w.
1. 33 kbps CAN,
2. 110 kbps Fault Tolerant CAN,
ww
.in
followed bysix fields of frame bitsData frame starts after first detecting thatdominant state is not
present at the CANline with logic 1 (R state) to 0 (D statetransition) for one serial bit interval
ng
• After start bit, six fields starting fromarbitration field and ends with seven logic0s end-field
• 3-bit minimum inter frame gap before nextstart bit (R→ D transition) occurs
eri
g ine
En
arn
Le
w.
ww
_ Destination device address specified in an11-bit sub-field and whether the data bytebeing sent is
a data for the device or arequest to the device in 1-bit sub-field.
_ Maximum 211 devices can connect a CANcontroller in case of 11-bit address fieldstandard11-bit
address standard CAN
_ Identifies the device to which data isbeing sent or request is being made.
_ When RTR bit is at '1', it means thispacket is for the device at destinationaddress. If this bit is at
'0' (dominantstate) it means, this packet is a requestfor the data from the device.
Protocol defined frame bits Second field
.in
_ Second field of 6 bits─ control field.
The first bit is for the identifier‘sextension.
ng
_ The second bit is always '1'.
_ The last 4 bits specify code for dataLength
eri
_ Third field of 0 to 64 bits─ Its lengthdepends on the data length code in thecontrol field.
• Fourth field (third if data field has nobit present) of 16 bits─ CRC (CyclicRedundancy Check)
ine
bits.
• The receiver node uses it to detect theerrors, if any, during the transmission
g
• ACK = '1' and receiver sends back '0' in this slotwhen the receiver detects an error in the
reception.
• Sender after sensing '0' in the ACK slot, generallyretransmits the data frame.
arn
• Second bit 'ACK delimiter' bit. It signals the endof ACK field.
• If the transmitting node does not receive anyacknowledgement of data frame within a
Le
.in
_ Maximum 127 devices can connect ahost.
ng
_ Three standards: USB 1.1 (a low speed1.5 Mbps 3 meter channel along with ahigh speed 12
Mbps 25 meter channel),USB 2.0 (high speed 480 Mbps 25meter channel), and wireless USB(high
speed 480 Mbps 3 m)
eri
ine
Host connection to the devices or nodes
_ Using USB port driving software andhost controller,
g
.in
ng
eri
g ine
_ Can be hot plugged (attached), configuredand used, reset, reconfigured and used
_ Bandwidth sharing with other devices: Hostschedules the sharing of bandwidth amongthe
arn
.in
• The token consists of fields for type,direction, USB device address and deviceend-point number.
• The device does the handshaking through ahandshake packet, indicating successful
ng
orunsuccessful transmission.
• A CRC field in a data packet permitserror detection
USB supported three types of pipes
eri
1. 'Stream' with no USB- defined protocol. Itis used when the connection is
ine
alreadyestablished and the data flow starts
2. 'Default Control' for providing access.
g
• Host configures each pipe with the databandwidth to be used, transfer service typeand buffer
sizes.
PARALLEL BUSDEVICE PROTOCOLS – PCI Bus
arn
graphic card
Computer system PCI
w.
• When the I/O devices in the distributedembedded subsystems are networked allcan communicate
through a commonparallel bus.
ww
• PCI connects at high speed to othersubsystems having a range of I/O devicesat very short
distances (<25 cm) using aparallel bus without having to implementa specific interface for each
I/O device.
PCI bus Applications
Connects
_ display monitor,
_ printer,
_ character devices,
_ network subsystems,
_ video card,
_ modem card,
_ hard disk controller,
PCI busconnects
_ thin client,
_ digital video capture card,
_ streaming displays,
.in
_ 10/100 Base T card,
_ Card with 16 MB Flash ROM with a routergateway for a LAN and
ng
_ Card using DEC 21040 PCI Ethernet LANcontroller.
• When the I/O devices in the distributedembedded subsystems are networked, allcan communicate
through a commonparallel bus.
eri
• PCI connects at high speed to othersubsystems having a range of I/O devicesat very short
ine
distances (<25 cm) using aparallel bus without having to implementa specific interface for each
I/O device.
g
addresses.
_ Automatically detects the interfacingsystems and assigns new addresses
w.
_ Each device may use a FIFO controllerwith a FIFO buffer for maximumthroughput.
Identification Numbers
_ A device identifies its address space bythree identification numbers, (i) I/Oport (ii) Memory
locations and (iii)Configuration registers of total 256Bwith a four 4-byte unique ID. Each
PCIdevice has address space allocation of256 bytes to access it by the host
Computer
PCI device identification
_ A sixteen16-bit register in a PCI deviceidentifies this number to let that deviceauto- detect it.
_ Another sixteen16-bit registeridentifies a device ID number. Thesetwo numbers let allow the
device tocarry out its auto-detection by its hostcomputer.
Peripheral Component Interconnect (PCI) Bus
_ Independent from the IBMarchitecture.
_ Number of embedded devices in acomputer system use PCI
_ Three standards for the devicesinterfacing with the PC
_ PCI 32bit/33 MHz, and 64bit/66 MHz
_ PCI Extended (PCI/X) 64 bit/100 MHz ,
.in
_ Compact PCI (cPCI) Bus
Two super speed versions
ng
_ PCI Super V2.3 264/528 MBps 3.3V (on64- bit bus), and 132/264 (on 32-bit bus)and
_ PCI-X Super V1.01a for 800MBps 64- bitbus 3.3Volt.
PCI bridge
eri
_ PCI bus interface switches a processorcommunication with the memory bus to PCIbus.
ine
_ In most systems, the processor has a singledata bus that connects to a switch module
_ Some processors integrate the switchmodule onto the same integrated circuit asthe processor to
g
reduce the number of chipsrequired to build a system and thus the system cost.
En
_ Communicates with the memorythrough a memory bus (a set ofaddress, control and data buses),
adedicated set of wires that transfer databetween these two systems.
arn
.in
_ A bus of appropriate specifications andprotocol interfaces these to the hostcomputer system or
compute
ng
Configuration address space
_ Unique feature of PCI bus uniquefeature is its configuration addressspace.
PCI controller Features
• Accesses one device at a time eri
ine
• All the devices within host device orsystem can share the I/O port andmemory addresses, but
cannot sharethe configuration registers
g
• Device cannot modify otherconfiguration registers but can accessother device resources or share
En
configurationtransactions.
PCI Device Initialization
A device can initialize at booting time
Le
configuration registersspace
ww
.in
Assembly codes sensitive to the processor,memory, ports and devices hardware
Gives a precise control of the processorinternal devices
Enables full use of processor specific featuresin its instruction set and its addressing modes
ng
Machine codes are compact, processor andmemory sensitive
System needs a smaller memory.
Memory needed does not depend on theprogrammer data type selection and
eri
ruledeclarations
Not the compiler specific and libraryfunctionsspecific
Device driver codes may need only a fewassembly instructions.
ine
Bottom-up-design approach
( ) functions
• Use of the modular building blocks
• Sub-modules are designed first forspecific and distinct set of actions,then the modules and
arn
.in
• List
• Tree
ng
Use of Objects
_ Objects bind the data fields andmethods to manipulate those fields
_ Objects reusability
eri
_ Provide inheritance, methodoverloading, overriding and interfacing
_ Many other features for ease inprogramming
ine
Advantage of using C for Programming
C
•Procedure oriented language (Noobjects)
• Provision of inserting the assemblylanguage codes in between (called inlineassembly) to obtain a
g
directhardware control.
• A large program in ‗C‘ splits into thedeclarations for variables, functions anddata structure,
En
C Program Elements
Preprocessor include Directive
w.
_ Header, configuration and otheravailable source files are madethe part of an embedded
systemprogram source file by thisdirective
Examples of Preprocessor includeDirectives
ww
Preprocessor Macros
• Macro - A named collection of codes that isdefined in a program as preprocessor directive.
• Differs from a function in the sense that oncea macro is defined by a name, the compilerputs the
corresponding codes at the macro atevery place where that macro-name appears.re used for short
codesonly.
Difference between Macro and Function
• The codes for a function compiledonce only
• On calling that function, theprocessor has to save the context,and on return restore the context.
• Macros are used for short codesonly.
• When a function call is used instead ofmacro, the overheads (context savingand return) will take
.in
a time, Toverheads that is the same order of magnitude asthe time, Texec for execution of
shortcodes within a function.
• Use the function when the Toverheads<<Texec and macro when Toverheads ~= or >
ng
Texec.
Use of Modifiers
auto
unsigned
static
const
eri
ine
register
interrupt
extern
g
volatile
En
volatile static
# define true 1
void main (void) {
ww
Use of typedef
_ Example─ A compiler version may notprocess the declaration as an unsigned byte
_ The 'unsigned character' can then be used asa data type.
_ Declared as follows: typedef unsignedcharacter portAdata
_ Used as follows: #define PbyteportAdata0xF1
Use of Pointers
Pointers are powerful tools whenused correctly and according tocertain basic principles.
# define COM ((structsio near*) 0x2F8);
This statement with a single masterstroke assigns the addresses to all 8variables
Byte at the sio Addresses
0x2F8: Byte at RBR/THR /DLATCH-LByte
.in
0x2F9: Byte at DLATCH-HByte
0x2FA: Byte at IER; 0x2FB: Byte at LCR;
0x2FC: Byte at MCR;
ng
0x2FD: Byte at LSR; 0x2FE: Byte at MSR
0x2FF: Byte Dummy Character
Example
eri
Free the memory spaces allotted to a datastructure.
#define NULL (void*) 0x0000
• Now statement & COM ((structsionear*) = NULL;assigns the COM to Null and make freethe
memory between 0x2F8 and 0x2FFfor other uses.
ine
Data structure
• Example─ structure sio
• Eight characters─ Seven for thebytes in BR/THR/DLATCHLByte,IER, IIR, LCR, MCR, LSR,
g
The values are copied into thearguments of the functions. Whenthe function is executed in
thisway, it does not change a variable'svalue at the function, which callsnew function.
(ii) Passing the References
ww
When an argument value to afunction passes through a pointer,the called function can change
thisvalue. On returning from thisfunction, the new value may beavailable in the calling program
oranother function called by thisfunction.
Use of Reentrant Function
• Reentrant function- A functionusable by the several tasks androutines synchronously (at thesame
time). This is because all thevalues of its argument areretrievable from the stack.
Three conditions for a function calledas reentrant function
1. All the arguments pass the valuesand none of the argument is apointer (address) whenever
acalling function calls that function.
2. When an operation is not atomic, thatfunction should not operate on anyvariable, which is
declared outside thefunction or which an interrupt serviceroutine uses or which is a globalvariable
but passed by reference andnot passed by value as an argumentinto the function. [The value of
such avariable or variables, which is notlocal, does not save on the stack whenthere is call to
another program.]
3. That function does not call any otherfunction that is not itself Reentrant.
.in
ng
eri
g ine
En
arn
unsignedintsalary [11];
salary[0] – 1st month salary.
salary[11] – 12th month salary
Each integer is of 32-bit (4 bytes);
w.
Multi-dimensional array
Example 4:
charpixel [143,175, 23];
pixel [0, 2, 5] – 1st horizontal line index x,3rd vertical line index y, 6th color c.pixel assigned
144*176*24 = 608256bytes address space in a coloredpicture of resolution 144x 176 and 24colors.
.in
_ Use of the queues of the function pointers built bythe ISRs.
It reduces significantly the ISR latencyperiods. Each device ISR is therefore able toexecute within
its stipulated deadline
ng
1.Multiple function calls
2. Multiple function calls in cyclic order
eri
Use
• One of the most commonmethods is the use of multiplefunction-calls in a cyclic order inan
infinite loop of the main ( ).
3. Use of function pointers
ine
* sign when placed before thefunction name then it refers to allthe compiled form of thestatements
in the memory that arespecified within the curly braceswhen declaring the function.
• A returning data type specification (forexample, void) followed by'(*functionName)
g
the function.
4. Queue of Function-pointers
Application
arn
_ Makes possible the designing ofISRs with short codes and byrunning the functions of the ISRsat
later stageso all pending ISRsfinishes
Multiple ISRs insertion of Function pointers into a Queue
• The ISRs insert the function pointers
Le
• The pointed functions in the queue execute at later stages by deleting from the queue
• These queued functions execute after the service to all pending ISRs finishes
Priority Function Queue of Multiple ISRs
w.
• When there are multiple ISRs, a high priority interrupt service routine is executed first
and the lowest priority.
• The ISRs insert the function pointers into a priority queue of function pointers[ISR can
ww
now be designed short enough sothat other source don‘t miss a deadline forservice]
.in
/********************************************************************/
Task 1
void task1 (....) {
ng
/* Declarations */
.
while (true) {
eri
/* Codes that repeatedly execute */
.
/* Codes that execute on an event */
ine
if (flag1) {....;}; flag1 =0;
/* Codes that execute for message to the kernel */
message1 ( );
}}
g
/*********************************************/
En
Task2 ( )
void task2 (....) {
arn
/* Declarations */
.
while (true) {
/* Codes that repeatedly execute */
Le
.
/* Codes that execute on an event */
if (flag2) {....;}; flag2 =0;
w.
/*********************************************/
TaskN_1 ( )
void taskN_1 (....) {
/* Declarations */
.
while (true) {
/* Codes that repeatedly execute */
.
/* Codes that execute on an event */
if (flagN_1) {....;}; flagN_1 =0;
/* Codes that execute for message to the kernel */
messageN_1 ( );
}}
/*********************************************/
TaskN
voidtaskN (....) {
/* Declarations */
.
while (true) {
/* Codes that repeatedly execute */
.
/* Codes that execute on an event */
.in
if (flagN) {....;}; flagN =0;
/* Codes that execute for message to the kernel */
messageN ( );
ng
}}
/*********************************************/
2. Polling for events and messages
eri
_ A Programming method is to facilitate execution of one of the multiple possible function calls
and the function executes after polling
ine
_ Polling example is polling for a screen state (or Window menu) j and for a message m from an
Mobile phone
En
_ Assume that screen state j is between 0 and K,among 0, 1, 2, ..or K – 1 possible states.(set
ofmenus).
_ An interrupt is triggered from a touch screen GUIand an ISR posts an event-message m = 0, 1, 2,
arn
…,or N – 1 as per the selected the menu choice 0, 1,2, …, N – 1 when there are N menu- choices
for amobile phone user to select from a screen in statej.
Polling for a menu selection from screen state
Le
voidpoll_menuK {/* Code for polling forchoice from menu m for screen state K*/
}
}
/*********************************/
w.
_ defining of the object or set of objects,which are common to similar objectswithin a program and
between the manyprograms,
_ defining the methods that manipulate theobjects without modifying theirdefinitions, and
_ Creation of multiple instances of thedefined object or set of objects or newobjects
Object-oriented language
_ Inheritance
_ overloading of functions
_ overriding of functions
.in
Object Oriented Language Characteristics
• A large program in objected orientedlanguage C++ or Java, splits into thelogical groups (also
known as classes).
ng
• Each class defines the data andfunctions (methods) of using data.
• Each class can inherit another classelement.
• A set of these groups (classes) then givesan application program of the EmbeddedSystem
eri
• Each group has internal user-level fieldsfor data and has methods of processingthat data at these
fields
• Each group can then create many objectsby copying the group and making itfunctional.
ine
• Each object is functional. Each objectcan interact with other objects toprocess the user's data.
• The language provides for formationof classes by the definition of a groupof objects having
similar attributesand common behavior. A classcreates the objects. An object is aninstance of a
class.
g
En
C++
Le
_ structthat binds all the member functionstogether in C. But a C++ class has objectfeatures. It can
be extended and childclasses can be derived from it. A number ofchild classes can be derived from
a commonclass. This feature is called polymorphism.
w.
A class can be declared as public or private.The data and methods access is restrictedwhen a class
is declared private. Structdoesnot have these features.
_ A class binds all the member functions togetherfor creating objects. The objects will have
ww
memoryallocation as well as default assignments to itsvariables that are not declared static.
_ A class can derive (inherit) from another classalso. Creating a child class from RTCSWT as
aparent class creates a new application of theRTCSWT.
_ Methods (C functions) can have same name in theinherited class. This is called method
overloading
_ Methods can have the same name as well asthe same number and type of arguments in
the inherited class. This is called methodoverriding. These are the two significantfeatures that are
extremely useful in a largeprogram.
_ Operators in C++ can be overloaded like inmethod overloading.
_ For example, operators ++ and! areoverloaded to perform a set of operations.
Some disadvantages
• Lengthier Code when using Template,Multiple Inheritance (Deriving a class frommany parents),
Exceptional handling, Virtualbase classes and classes for IO Streams.
.in
4) A special compiler for an embeddedsystem can facilitate the disabling ofspecific features
provided in C++.Embedded C++ is a version of C++ thatprovides for a selective disabling of
theabove features
ng
5) Use Embedded C++: It provides for lessruntime overhead and less runtimelibrary. The solutions
for the libraryfunctions are available and ported in Cdirectly.
6) The IO stream library functions in anembedded C++ compiler are alsoreentrant.
eri
7) Using embedded C++ compilers or thespecial compilers make the C++ morepowerful coding
language than C forembedded systems due to the OOP featuresof software re-usability,
extendibility,polymorphism, function overriding andoverloading along portability of C codes
andin-line assembly codes.
ine
UNIT IV REAL TIME OPERATING SYSTEMS – PART - 1 9
g
Process Concepts
En
block (PCB).
Runs when it is scheduled to run by the OS (kernel)
OS gives the control of the CPU on a process‘s request (system call).
Le
Runs by executing the instructions and the continuous changes of its state takes
Place as the program counter (PC) changes.
• Process is that executing unit of computation, which is controlled by some process (of
w.
the OS) for a scheduling mechanism that lets it execute on the CPU and by some
process at OS for a resource management mechanism that lets it use the system-
memory and other system resources such as network, file, display or printer.
ww
Modulating process,
Display process,
GUIs (graphic user interfaces), and
Key input process ─ for provisioning of the user interrupts
.in
ng
eri
ine
g
A data structure having the information using which the OS controls the
Process state.
Stores in protected memory area of the kernel.
arn
Process ID,
process priority,
parent process (if any),
w.
Context
Context loads into the CPU registers from memory when process starts running, and the
registers save at the addresses of register-save area on the context switch to another process
The present CPU registers, which include program counter and stack pointer are called
context
.in
When context saves on the PCB pointed process-stack and register-save area addresses,
then the running process stops.
Other process context now loads and that process runs─ This means that the context
ng
has switched.
eri
Thread Concepts
A thread consists of executable program (codes), state of which is
controlled by OS,
ine
The state information─ thread-status (running, blocked, or finished), threadstructure—its
data, objects and a subset of the process resources, and thread-stack. Considered a
lightweight process and a process level controlled entity.[Light weight means its running
g
Process… heavyweight
• Process considered as a heavyweight process and a kernel-level controlled entity.
• Process thus can have codes in secondary memory from which the pages can be
arn
swapped into the physical primary memory during running of the process. [Heavy
weight means its running may depend on system resources]
• May have process structure with the virtual memory map, file descriptors,
user–ID, etc.
Le
• Can have multiple threads, which share the process structure thread
• A process or sub-process within a process that has its own program counter, its own
stack pointer and stack, its own priority parameter for its scheduling by a thread
w.
scheduler
• Its‘ variables that load into the processor registers on context switching.
• Has own signal mask at the kernel. Thread‘s signal mask
ww
.in
ng
eri
Application program can be said to consist of number of threads or
ine
Processes:
Multiprocessing OS
g
Thread parameters
Le
• Each thread has independent parameters ID, priority, program counter, stack
pointer, CPU registers and its present status.
w.
Thread’s stack
ww
.in
another task to run.
• Multithreading needs a thread-scheduler. Multitasking also needs a task-scheduler.
• There may or may not be task groups and task libraries in a given OS
ng
Task and Task States
eri
Task Concepts
• An application program can also be said to be a program consisting of the tasks and
task behaviors in various states that are controlled by OS.
• A task is like a process or thread in an OS.
ine
• Task─ term used for the process in the RTOSes for the embedded systems.
For example, VxWorks and μCOS-II are the RTOSes, which use the term
task.
g
the OS scheduling mechanism, which lets it execute on the CPU and by some
process at OS for a resource-management mechanism that lets it use the system
memory and other system-resources such as network, file, display or printer.
w.
• The task─ can send signal (s) or message(s) that can let another task run.
• The OS can only block a running task and let another task gain access of CPU to
run the servicing codes
.in
ng
Task States eri
ine
(i) Idle state [Not attached or not
registered]
(ii) Ready State [Attached or registered]
(iii) Running state
g
Running state
• Executing the codes and getting the system resources at this instance. It will run till
it needs some IPC (input) or wait for an event or till it gets pre-empted by another
higher priority task than this one.
•
Blocked (waiting) state
• Execution of task codes suspends after saving the needed parameters into its
.in
Context. It needs some IPC (input) or it needs to wait for an event or wait for higher
priority task to block to enable running after blocking.
ng
Deleted (finished) state
• Deleted Task─ The created task has memory deallotted to its structure. It frees the
eri
memory. Task has to be re-created.
Function
ine
• Function is an entity used in any program, function, task or thread for performing
specific set of actions when called and on finishing the action the control returns to
the function calling entity (a calling function or task or process or thread).
g
• has its stack, which saves when it calls another function and the stack restores on
return to the caller.
• Functions can be nested. One function call another, that can call another, and so on
arn
Memory allocation
when a process is created, the memory manager allocates the memory addresses (blocks) to
it by mapping the process address space.
w.
Dynamic Page-Allocation
Dynamic Data memory Allocation
Dynamic address-relocation
Multiprocessor Memory Allocation
Memory Protection to OS functions
.in
latency of servicing the tasks and ISRs.
User functions are then can run in kernel space and run like kernel functions
RTOS may provide for disabling of the support to memory protection among the tasks as
ng
this increases the memory requirement for each task
eri
(i) use of memory address space by a process,
(ii) specific mechanisms to share the memory space and
(iii) specific mechanisms to restrict sharing of a given memory space
ine
(iv) optimization of the access periods of a memory by using an hierarchy of memory (caches,
primary and external secondary magnetic and optical memories).
Remember that the access periods are in the following increasing order: caches, primary and
external secondary magnetic and then or optical.
g
Problems
Fragmented not continuous memory addresses in two blocks of a process
Time is spent in first locating next free memory address before allocating that to the
arn
process.
A standard memory allocation scheme is to scan a linked list of indeterminate length to find
a suitable free memory block.
When one allotted block of memory is deallocated, the time is spent in first locating next
Le
RTOS COS-II
Memory partitioning
A task must create a memory partition or several memory partitions by using function
OSMemCreate ( )
Then the task is permitted to use the partition or partitions.
A partition has several memory blocks.
Task consists of several fixed size memory blocks.
The fixed size memory blocks allocation and de-allocation time takes fixed time
(deterministic).
OSMemGet ( )
─ to provide a task a memory block or blocks from the partition
OSMemPut ( )
─ to release a memory block or blocks to the partition
.in
• Task defined as an executing computational unit that processes on a CPU and state
of which is under the control of kernel of an operating system.
ng
Distinction Between Function, ISR and Task
Uses
• Function─ for running specific set of codes for performing a specific set of actions
as per the arguments passed to it
eri
• ISR─ for running on an event specific set of codes for performing a specific set of
ine
actions for servicing the interrupt call.
• Task ─ for running codes on context switching to it by OS and the codes can be in
endless loop for the event (s)
g
Calling Source
En
• Task ─ A call to run the task is from the system (RTOS). RTOS can let another
higher priority task execute after blocking the present one. It is the RTOS (kernel)
only that controls the task scheduling.
Le
Context Saving
On the top of which the program counter value (for the code left without running)
and other values (called functions‘ context) save.
• All function have a common stack in order to support the nesting
ww
• ISR─ Each ISR is an event-driven function code. The code run by change in
program counters instantaneous value. ISR has a stack for the program counter
instantaneous value and other values that must save.
• All ISRs can have common stack in case the OS supports nesting
• Task ─ Each task has a distinct task stack at distinct memory block for the context
(program counter instantaneous value and other CPU register values in task control
block) that must save .
• Each task has a distinct process structure (TCB) for it at distinct memory block
Structure
.in
• Function─ can be the subunit of a process or thread or task or ISR or subunit of
another function.
•
ng
ISR─ Can be considered as a function, which runs on an event at the interrupting
source.
• A pending interrupt is scheduled to run using an interrupt handling mechanism in
eri
the OS, the mechanism can be priority based scheduling.
• The system, during running of an ISR, can let another higher priority ISR run.
• Task ─ is independent and can be considered as a function, which is called to run
by the OS scheduler using a context switching and task scheduling mechanism of
ine
the OS.
• The system, during running of a task, can let another higher priority task run. The
kernel manages the tasks scheduling
g
• Function─ can change the global variables. The interrupts must be disabled and
after finishing use of global variable the interrupts are enabled.
arn
• ISR─ When using a global variable in it, the interrupts must be disabled and after
finishing use of global variable the interrupts are enabled (analogous to case of a
function).
• Task ─ When using a global variable, either the interrupts are disabled and after
Le
finishing use of global variable the interrupts are enabled or use of the semaphores
or lock functions in critical sections, which can use global variables and memory
buffers.
w.
• Function─ can get the parameters and messages through the arguments passed to it
or global variables the references to which are made by it. Function returns the
results of the Operations.
• ISR─ using IPC functions can send (post) the signals, tokens or messages. ISR
can‘t use the mutex protection of the critical sections by wait for the signals, tokens
or messages.
.in
OS Functions provide for the use of a semaphore for signalling or notifying of
certain action or notifying the acceptance of the notice or signal.
• Let a binary Boolean variable, s, represents the semaphore. The taken and post
ng
operations on s─ (i)signals or notifies operations for communicating the occurrence
of an event and (ii) for communicating taking note of the event.
• Notifying variable s is like a token ─ (i) acceptance of the token is taking note of
eri
that event (ii) Release of a token is the occurrence of an event
Binary Semaphore
• Let the token (flag for event occurrence) s initial value = 0
• Assume that the s increments from 0 to 1 for signalling or notifying occurrence of
ine
an event from a section of codes in a task or thread.
• When the event is taken note by section in another task waiting for that event, the s
decrements from 1 to 0 and the waiting task codes start another action.
g
• When s = 1─ assumed that it has been released (or sent or posted) and no task code
section has taken it yet.
En
• When s = 0 ─ assumed that it has been taken (or accepted) and other task code
• section has not taken it yet
Binary Semaphore use in ISR and Task
arn
Each device or device function having s a separate driver, which is as per its hardware
Software that manages the device drivers of each device
ww
Provides and executes the modules for managing the devices and their drivers ISRs.
effectively operates and adopts appropriate strategy for obtaining optimal performance for the
devices.
Coordinates between application-process, driver and device-controller.
Device manager
Process sends a request to the driver by an interrupt; and the driver provides the actions by
executing an ISR.
Device manager polls the requests at the devices and the actions occur as per their priorities.
.in
(iii) Device uses DMA operation used by the devices to access the memory.
Most common is the use of device driver ISRs
Device Manager Functions
ng
Device Detection and Addition
Device Deletion
eri
Device Allocation and
Registration
ine
Detaching and Deregistration
Restricting Device to a specific process
Device Sharing
g
Device control
En
Device Types
char devices and
w.
block devices
Set of Command Functions for the Device Management
ww
.in
Third Argument: Values needed by the defined function are at the third argument
Example
ng
Status = ioctl (fd, FIOBAUDRATE, 19200) is an instruction in RTOS VxWorks.
fd is the device descriptor (an integer returned when the device is opened)
eri
FIOBAUDRATE is the function that takes value = 19200 from the argument.
This at configures the device for operation at 19200-baud rate.
ine
Device Driver ISR functions
ISR functions
intlock ( ) to disable device-interrupts systems,
intUnlock ( ) to enable device-interrupts,
g
En
Unix OS functions
UNIX Device driver functions
Facilitates that for devices and files have an analogous implementation as far as possible.
Le
open ( ),
close ( ),
w.
read ( ),
write ( ) functions analogous to a file open,
ww
.in
Scheduling using 'Earliest Deadline First' (EDF) precedence.
Common scheduling models
Rate Monotonic Scheduling using ‗higher rate of events occurrence First‘ precedence
ng
Fixed Times Scheduling
Scheduling of Periodic, sporadic and aperiodic Tasks
Advanced scheduling algorithms using the probabilistic Timed Petri nets (Stochastic) or
eri
Multi Thread Graph for the multiprocessors and complex distributed systems.
Round Robin Time Slice Scheduling of Equal Priority Tasks
Equal Priority Tasks
ine
Round robin means that each ready task runs turn by in turn only in a cyclic queue for a
limited time slice.
Widely used model in traditional OS.
Round robin is a hybrid model of clock-driven
g
model (for example cyclic model) as well as event driven (for example, preemptive)
En
A real time system responds to the event within a bound time limit and within an explicit
time.
Tasks programs contexts at the five instances in the Time Scheduling Scheduler for C1 to C5
arn
Programming model for the Cooperative Time sliced scheduling of the tasks
Program counter assignments on the scheduler call to tasks at two consecutive time slices.
Each cycle takes time = N tslice
Le
is et
Number of tasks = N
Worst-case latency
Same for every task in the ready list
Tworst = {N (Tslice)} + tISR.
tISR is the sum of all execution times for the ISRs
i = 1, 2, …, N 1 , N
.in
Case 2: Alternative model strategy
Case 2: Certain tasks are executed more than once and do not finish in one cycle
Decomposition of a task that takes the abnormally long time to be executed.
ng
The decomposition is into two or four or more tasks.
Then one set of tasks (or the odd numbered tasks) can run in one time slice, t'slice and the
another set of tasks (or the even numbered tasks) in another time slice, t''slice.
eri
Decomposition of the long time taking task into a number of sequential states
ine
Decomposition of the long time taking task into a number of sequential states or a number
of node-places and transitions as in finite state machine. (FSM).
Then its one of its states or transitions runs in the first cycle, the next state in the second
g
state change.
arn
andVxWorks
w.
Kernel of an RTOS
• Used for real-time programmingfeatures to meet hard and soft real timeconstraints,
• Provides for preemption points atkernel, user controlled dynamic prioritychanges, fixed memory
ww
blocks,asynchronous IOs, user processes inkernel space and other functions for asystem.
.in
ng
eri
Complex multitasking embeddedsystem design requirements
ine
Integrated Development Environment,
Multiple task functions in Embedded C orEmbedded C++,
Real time clock─ hardware and softwaretimers,
Scheduler,
g
.in
and host target support tools
Device Imaging tool and device drivers
Clock, time and timer functions,
ng
Support to POSIX,
Asynchronous IOs,
Fixed memory blocks allocation anddeallocation system,
eri
Support to different file systems and flashmemory systems
TCP/IP protocols, network and busesprotocols,
Development environment with Java
ine
Componentization (reusable modules fordifferent functions), which leads to smallfootprint
(small of size of RTOS codes placedin ROM image)
Support to number of processor architectures,such as INTEL, ARM, Philips, …
g
Development Approaches
En
A host machine (Computer) for example, a PCuses a general purpose OS, for example,
Windowsor Unix for system development. The targetconnects by a network protocol for
exampleTCP/IP during the development phase. Thedeveloped codes and the target RTOS
functionsfirst connect a target. The target with downloadedcodes finally disconnects and
Le
contains a small sizefootprint of RTOS. For example, the target doesnot download host
machine resident compiler,cross compiler, editor for programs, simulationand debugging
programs, and MMU support.
w.
running. This also does not require crosscompilation. When application codes areready, the
required RTOS functions codesand application codes are downloaded intothe ROM of the
target board
Types of RTOSes
.in
kernel fortaking control─ compulsory to let OS kernelcontrol the nesting of the ISRs in
case ofoccurrences of multiple interrupts ofvarying priorities.
Function void OSIntExit (void)─ used just before the return from the runningISR─ For
ng
sending a message to RTOS kernel forquitting control of presently running ISR
OS_ENTER_CRITICAL
eri
Macro to disable interrupts before acritical section
ine
Used at the start of a ISR or task - for sending amessage to RTOS kernel and disabling
theinterrupts
Use compulsory when the OS kernel is to takenote of and disable the interrupts of the
g
system
OS_EXIT_CRITICAL─ Macro to enable interrupts. [ENTERand EXIT functions form a
En
Use is compulsory to OS kernel for taking noteof and enables the disabled interrupts.
.in
ms)
OSTimeDlyResume
• unsigned byte OSTimeDlyResume(unsigned byte taskPriority)
ng
When a task of priority = taskPriority is toresume before the preset delay, which was bya value
defined either by delayCount or (hr,mn and ms) and which is in blocked statenow.
eri
Macros to find status after execution ofOS Time Delay Functions
• OS_NO_ERR, when our arguments arevalid and resumption after delay succeeds.
• OS_TIME_INVALID_HOURS,
• OS_TIME_INVALID_MINUTES,
ine
• OS_TIME_INVALID_SECONDS and
• OS_TIME_INVALID_MILLI, returns true
• OS_TIME_ZERO_DLY, returns true ifall the arguments passed are 0.
g
• OS_NO_ERR returns trueif all the arguments passed or whenresumption after delay succeeds.
• OS_TASK_NOT_EXIST returns true,if task was not created earlier.
En
OSMemCreate
OSMemPut (*memCBPointer, *memErr)
OSMemGet (*memCBPointer, *memErr)
w.
Semaphore Functions
ww
Provides for using same semaphorefunctions as an event signaling flagor mutex or counting
semaphore.
OSSemCreate (semVal)
OSSemPend (*eventPointer, timeOut,*SemErrPointer)
OSSemAccept (*eventPointer)
OSSemPost (*eventPointer)
OSSemQuery (*eventPointer)
Mailbox Functions
.in
To check if mailbox message at the*MsgPointer, is available at *mboxMsg.
Unlike OSMboxPend function, it does notblock (suspend) the task if message is notavailable. If
available, it returns the pointer.
ng
OSMboxPost (*mboxMsg, *MsgPointer)
─ Sends a message of task at address MsgPointerby posting the address pointer to the mboxMsg.
─ If box is already full (*mboxMsg not Null),then the message is not placed and error statussent.
eri
OSMboxQuery (*mboxMsg, *mboxData)
─ To get mailbox error information
─ Pointer Null or Not Null,
ine
Queue Functions
• The message pointers post into a queueby the tasks either at the back as in aqueue or at the front
as in a stack.
g
• A task can thus insert a given messagefor deleting either in the first in firstout (FIFO) mode or in
En
Functions
OSQCreate (**QTop, qSize)
OSQPost (*QMsgPointer, *QMsg)
Le
IPC Objects
ww