You are on page 1of 28

Real Time Operating Systems (JNTU-Kakinada) (Unit-5) 85

UNIT
UNIT--5: Design Examples and Case Studies of Program Modeling with RTOS-2
Important Questions

Q1. Discuss about the evolution of Qrio with a necessary diagram.

Answer :

For answer refer Unit-V, Q1.

Q2. Write short notes on the following with reference to specific tasks,

(i) Class

(ii) Objects

(iii) State diagram.

Answer :

For answer refer Unit-V, Q6.

Q3. Briefly explain the communication hardware and software architecture of a robot orchestra MIDI.

Answer :

For answer refer Unit-V, Q7.

Q4. List the requirements for an Adaptive Cruise Control (ACC) system.

Answer :

For answer refer Unit-V, Q10.

Q5. List the requirements of ‘SMS create and send application’ for a mobile phone. Explain the actions
of each.

Answer :

For answer refer Unit-V, Q18.

Q6. Draw the state diagram for task_sms_createtext send. Also, explain the synchronization model for
sms create and application tasks ISR and orchestrator task using message and event boxes.

Answer :

For answer refer Unit-V, Q21.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
86 (Unit-5) Real Time Operating Systems (JNTU-Kakinada)

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
Real Time Operating Systems (JNTU-Kakinada) (Unit-5) 87

Design Examples and Case Studies of Program


Unit-5 Modeling with RTOS-2
Solutions
5.1 Case Study of Communication between Orchestra Robots
Q1. Discuss about the evolution of Qrio with a necessary diagram.
Answer : Model Paper-I, Q5(a)
Qrio is an innovation of sony in the year 2003. It was the first faster and smoother humanoid (human in appearance)
robot designed which weighted about 7.3 kg and was nearly 58 cm in its height. It had about an hour of battery along with 7
microphones.
Qrio was a bipedal robot designed with 3 CCD cameras, One in each eye and one at the centre in order to recognize upto
10 different faces and view the location of objects. The various actions performed by this robot were,
(a) It used to wave Hello and was capable of singing.
(b) It performed complicated dances.
(c) Qrio was capable of recognizing a particular voice.
(d) It could even kick and walk uptill.
(e) Qrio robot used to interact with humans along with the physical movements.
(f) It was capable of speaking upto 1000 words and could learn new words easily.
The flash lights in eyes were used to express the emotions of Qrio robot.
The fourth generation of Qrios developed in the year 2006, consists of 10 Qrios robots which is about 38 fluid motion
flexible joints, embedded complex algorithms and three microcontrollers. The 38-fluid joints were used along with ASIPs in
each. These joints were controlled by the separate motors employed for each in the system. The three microcontrollers (of
memory 64 KB each) installed in the system were used for controlling the movements of the robot, speech and visual image
recognition purposes.
For complex mechanical operations like balancing while dancing or in step by step dancing routine is controlled by Qrio
embedded complex algorithm as shown in figure below,

Figure: Robot-Orchestra
These robots formed an orchestra to perform a dance number and provided a unique performance of Beethoven’s 5th
symphony (1808), which were played in the orchestra by using several new musical instruments and were managed by a
conductor.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
88 (Unit-5) Real Time Operating Systems (JNTU-Kakinada)
Q2. Draw and explain the block diagram of the embedded software of a robot orchestra. Also explain
the communication of commands and messages among the orchestrator.
Answer :
An orchestrator is a software employed in a robot orchestra.
The various functions performed by an orchestrator are,
(i) It sequences and synchronizes the inputs.
(ii) Orchestrators generates messages and
(iii) The generated messages are sent as outputs to the actuators, display and message boxes.
Figure (1) shows the embedded software module of a orchestrator with k sensor inputs to the module, q output to
actuator and p output to message boxes.
1
Message box

p 1
Message box Orchestrator Sensor
running at
1 a microcontroller
Actuator k
Sensor

q
Actuator

Figure (1): Embedded Software Module of Orchestrator at a Microcontroller


There are the sensor inputs to the ‘Orchestrator’ which generate ‘q’ output which are fed to the actuators and ‘p’
message boxes at the output. Message boxes are used to store notifications and after receiving a specific notification, the task
is initiated.
Figure (2) illustrates the communication model between ‘p’ messages and ‘3’ orchestrator namely orchestrator x,
orchestrator ‘y’ and orchestrator ‘z’

1 Orchestrator
Message box X Message box

Orchestrator
Y
P
Message box P
Orchestrator
Z

Figure (2): Communication of Commands and Messages between Orchestrator


Q3. How are MIDI messages used for conducting an orchestra and give specific example.
Answer :
MIDI (Musical Instrument Digital Interface) is a protocol used to communicate data between two or more musical
instruments. The majority of the musical instruments support MIDI protocol i.e., they are MIDI compatible. The two main
connections of MIDI namely MIDI IN and MIDI OUT have no optical connections with the hardware unit of musical-
instruments.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
Real Time Operating Systems (JNTU-Kakinada) (Unit-5) 89
MIDI Specifications
Robot player
The three major specifications of MIDI are, of musical P1
(i) It describes the physical connector. Instrument 1
instrument
P2
(ii) MIDI specifies the message format employed in a
connecting device in order to control them in a real Robot player
time. of musical C
(iii) MIDI also defines the standard of MIDI files. Instrument 2
instrument
Master
The message generated at the MIDI OUT connection conductor
P3
includes both command and its associated data. This
data is sent in the form of byte which ranges between Robot player
0-127 where as the command has a range of 128-255. of musical
The command message in MIDI files includes the Instrument 3
instrument
following messages,
(a) Musical note Player
of musical P4
(b) Program change
Instrument 4
instrument
(c) Pitch bend
(d) Control change and Figure: Communication Model of a Robot-Orchestra
(e) After touch message or poly-pressure message. The communication between the master and slaves is
A system employs a maximum of 16 channels. The carried over a wireless protocol namely bluetooth. The 4 robot
MIDI protocol describes three different messages
players are used to play the various musical instruments and
ranging from OXFO to OXFF. They are,
notes from different tracks of MIDI file available in the master
(i) System messages
conductor (c).
(ii) Manufacture’s system exclusive messages and
Requirements
(iii) Real time system exclusive messages.
For instance, the following example describes a real The various requirements of a communication system
time system message “the OXFA command initiates the MIDI in order to transfer MIDI files in a robot-orchestra are,
start and it always starts the play back at the initial stage of 1. Purpose
the song, known as MIDI beat 0. As soon as a slave player
identifies a MIDI start, the song position is automatically To transfer MIDI files between master conductor and
changed to ‘0’ i.e., it gets reset. slave-robot in a robot orchestra over bluetooth.
MIDI messages also specify the type and speed of a 2. Inputs
musical note pressed. This note is again fed as input to the MIDI file and orchestra choice for specified MIDI file
succeeding MIDI receiver which plays the same note with the
are the two major inputs fed to the robot orchestra
same speed. Hence, the MIDI protocol help in controlling the
complete robot-Orchestra and actuators are used to model.
synchronize the notes and speed. 3. Signals, Events and Notification
The various communication protocols used for the Data files including commands are used to indicate
transfer of MIDI files are speed serial, Bluetooth, Firewire or the various signals, events and notifications in the
USB. The specific communication protocols used in robot-
system.
orchestra are either bluetooth or WLAN 802.11.
Q4. Explain about the communication model and 4. Outputs
the requirements of communication system for The robot orchestra model outputs the following,
MIDI files in robot orchestra. (a) MIDI files over a communication channel.
Answer : (b) Message signals from robot orchestra are fed to
Figure shows the communication model of a robot- the actuators in order to perform the motor
orchestra with one conductor (c) and four slave robots P1, P2, movements according to the particular track
P3 and P4. messages and data.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
90 (Unit-5) Real Time Operating Systems (JNTU-Kakinada)
5. Functions of the Systems
The sequence of actions held after user signals an orchestra-choice are,
(a) The desired MIDI file is selected by the conductor C i.e., task_MIDI. The bytes from the message queue files are
then posted to the task_piconet_master.
The piconet is a network formed by the C, P1, P2, P3 and P4 as shown in figure.
(b) The posted messages from task PICONET_Master are accepted by the piconet devices task_PICONET_Slave P1,
task_PICONET_Slave P2, task_PICONET_Slave P3 and task_PICONET_Slave P4.
(c) These task_PICONET_Slave again transfers the MIDI messages to the task_MIDI_Slave which in turn sends the
message to a task_Orchestrator.
The motor movements and musical-note actuators are controlled by the task_Orchestrator.
6. Design Matrix
The design metrics used in the communication system of robot-orchestra are,
(a) Power Dissipation
It specifies the amount of power dissipated by the actuators and mechanical unit.
(b) Performance
The robot orchestra performs operations which clearly resembles to the human orchestra players.
(c) Engineering Cost
Engineering cost including mechanical actuators is approximated to be US $150000.
(d) Manufacturing Cost
The manufacturing cost of a robot orchestra is about US $50,000.
7. Test and Validation Condition
It tests the ability of all the MIDI commands such that the orchestral functions are executed correctly.
Q5. Explain the procedure involved in posting a MIDI file data over the piconet to the slaves with the
help of a class diagram.
Answer :
The class diagram of a particular task indicates the interactions among the classes and objects of a class. Figure shows
the class diagram of a Task_Conductor which indicates the posting of a MIDI file messages to the slave devices over bluetooth
piconet network.
ISR_Orchestra_Choice
task_MIDI
Task_Conductor
task_Piconet_Master

Task_Slave P1
Task_SlaveP1 Task_Slave P2
Task_SlaveP2

task_Piconet_Slave P1
task_Piconet_SlaveP1
task_MIDI_Slave P1
task_MIDI_SlaveP1

task_Orchestrator_Slave P1
task_Orchestrator_SlaveP1
task_Piconet_Slave P2
task_Piconet_SlaveP2
task_MIDI_Slave P2
task_MIDI_SlaveP2
Task_Slave 3
Task_SlaveP3 Task_Slave P4
Task_SlaveP4
task_Orchestrator_Slave P2
task_Orchestrator_SlaveP2

task_Piconet_Slave P3
task_Piconet_SlaveP3
task_MIDI_Slave P3
task_MIDI_SlaveP3

task_Orchestrator_Slave P3
task_Orchestrator_SlaveP3
task_Piconet_Slave P4
task_Piconet_SlaveP4
task_MIDI_Slave P4
task_MIDI_SlaveP4

task_Orchestrator_Slave P4
Figure: Class Diagram of Task_Conductor

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
Real Time Operating Systems (JNTU-Kakinada) (Unit-5) 91
It can be observed from figure that,
(i) Task_Conductor communicates with the ISR_Orchestra_Choice and provides data to Task_MIDI and Task_Piconetmater.
(ii) The abstract classes Task_Slave P1, Task_Slave P2, Task_Slave P3 and Task_Slave P4 are connected to the classes
Task_Piconet_Slave P1, Task_Piconet_Slave P2, Task_Piconet_Slave P3 and Task_Piconet_Slave 4, respectively.
(iii) Task_MIDI_Slave P1, Task_MIDI_Slave P2, Task_MIDI_Slave P3 and Task_MIDI_Slave P4 represent the classes in
slaves P1, P2, P3 and P4 respectively.
(iv) Task_Orchestrator_Slave P1, Task_Orchestrator_Slave P2, Task_Orchestrator_Slave P3 and Task_Orchestrator_Slave
P4 indicate the classes in P1, P2, P3 and P4 respectively.
Q6. Write short notes on the following with reference to specific tasks,
(i) Class
(ii) Objects
(iii) State diagram.
Answer : Model Paper-II, Q5(a)
(i) Class
A class is defined as a logical group employing both fields (attributes) and methods (operation) of a particular task. For
instance, a class task-MIDI along with its fields and operating system methods is as shown in figure (1).

Task_MIDI
Type 0: file Type;
MsgMusical Note, MsgPitchBend, MsgControlChange;
Other
fields of Msg After Touch, MsgSystem, MsgManulExcl, MsgProgramChange;
class MsgRealTime; String
NumMsg; unsigned int;
OSMsgQAccept( );
Operating
System methods OSMsgQPend( );
OSMsgQPost( );
Figure (1): Class MIDI
The field called “file type” indicates the type of a file. The two major types of “file type” are type 0 and type 1.
Type 0
The “file type” defines “type 0” file if it employs only single track consisting of all the MIDI messages (which describe
the complete performance of orchestra for the single track).
A track includes different musical parts in various MIDI channels, with one channel for every slave robot.
Type 1
Type 1 file represents all the musical parts in a separate track for each slave robot. All the other fields of a class are
illustrated in figure (1). For instance, msgMusical Note is a string object for musical note.
Similarly, all the other fields specify string objects for their respective tasks.
NumMsg represents the number of messages which are transmitted from master to slave in one cycle.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
92 (Unit-5) Real Time Operating Systems (JNTU-Kakinada)
The operating system methods and their respective functions are shown in table.
OS Method Action
OSMsg QAccept( ) Accepts the messages from orchestra choice and MIDI
OSMsg QPend( ) Waits for the orchestra choice and MIDI messages
OSMsg QPost( ) Posts the messages.
Table (1)
(ii) Object
An object is defined as an instance of a class.
The object ID for a task is designated by the characters beginning with lower case.
Example: task_MIDI
The respective classes of object ID are represented by characters starting with upper case
Example: Task_MIDI.
i.e., task_MIDI represent an object and
Task_MIDI represent a class.
The message queue objects which help in posting and accepting messages are,
MsgQMidi, MsgQbluetooth, MsgQbluetooth P2, MsgQbluetooth P3, Msg Qbluetooth P4, MsgQmidi P2, MSgQmidi
P3 MsgQmidi P4, Sigport P1, MsgQmidi P4 SigPort P2, SigPort P3 and SigPort P4.
Table (2) defines the posts of each of these objects.
Object Posts Number of Cycles
MsgQMIDI NumMsg messages to 1
task_piconet_master
MsgQbluetooth Bluetooth stack data 1
to port_bluetooth
SigPorts (i) These signal objects help –
in initiating the transfer
of bluetooth stack to the
ports.
(ii) The reception of bluetooth
stack is also initiated by the
sigport 1, 2, 3, and 4.
Table (2)
(iii) State Diagram
A state diagram is a pictorial representation of the states in an object along with their transitions.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
Real Time Operating Systems (JNTU-Kakinada) (Unit-5) 93
Figure (2) shows a state diagram for objects from classes of Task_Conductor.

Start
ISR_Orchestra_Choice

task_MIDI
NumMsg: MsgQMidi

Task_Piconet_Master
task_Piconet_Master Bluetooth stack

task_Piconet_slave P1
task_Piconet_SlaveP1 task_Piconet_Slave P4
task_Piconet_SlaveP4

True
True
False False
Wait Track P1 Track P4 Wait
Message Message
Task_MIDI_SlaveP1
P1 task_MIDI_Slave P4
task_MIDI_SlaveP4
NumMsg NumMsg

task_Orchestrator_slave P1
task_Orchestrator_SlaveP1 task_Orchestrator_Slave P4
task_Orchestrator_SlaveP4

True False End


More MIDI
Messages
Figure (2): State Diagram for task_MIDI
Figure (2) depicts that the state transitions takes place between the tasks labelled in rectangular boxes and the end for
the task_MIDI is represented by a dark rectangular mark within a circle.
Q7. Briefly explain the communication hardware and software architecture of a robot orchestra MIDI.
Answer : Model Paper-I, Q5(b)
Hardware Architecture
The hardware architecture of a robot orchestra MIDI represents the appropriate division of a hardware unit into its
corresponding components such as, (i) Processors (ii) ASIP’s (iii) Memory (iv) Ports (v) Devices (vi) Mechanical and
electromechanical units.
The hardware architecture also defines the interfacing and mapping of the various components present in the system.
Figure below illustrates the block diagram of a communication hardware architecture.
ASIP at each Power
motor joint supply

Microcontroller Bluetooth
Communication
ASIP
Ram Flash
Figure: Block Diagram of Communication Hardware Architecture
The specifications of hardware architecture are,
1. The orchestrator movements are controlled by microcontroller at master and each slave. The microcontroller consists
of 8 MB ROM, 64 kB flash memory, timer, SI and 8 hardware-interrupts.
2. An ASIP (application specific processor) is employed for each motor movement.
3. In order to provide a communication between master and slaves over a bluetooth piconet network, an ASIP is used in
the architecture.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
94 (Unit-5) Real Time Operating Systems (JNTU-Kakinada)
Software Architecture
The software architecture of a system indicates the proper decomposition of a software unit into the following entities,
(i) Modules
(ii) Components
(iii) Appropriate protection strategies and
(iv) Mapping of software.
The elements employed in the software of a system (at master and each slave) are,
1. Operating System (OS)
2. Interrupt Service Routines (ISR) is used for initiating an action on user inputs and Graphical User Interface (GUI)
notifications such as Orchester_Choice.
3. Task represents the objects of the classes.
4. Orchestrator tasks are employed at both master and slaves.
5. The three message queue functions used for system call to the OS are,
(i) OSMSgQAccept
(ii) OSMSgQPost
(iii) OSMSgPend.
These functions also help in synchronization and concurrent processing of tasks. For instance, consider the following
sequence of actions held in the communication model of a robot orchestra.
Step 1
For Orchestra_Choice, task_MIDI waits for message from ISR_Orchestra_Choice
Step 2
task_MIDI then posts the bytes in message queue for task_Piconet_Master.
6. task_MIDI: This object waits till a NumMsg MIDI messages are received from a MIDI file for a specific orchestra and
then posts the NumMsg MsgQMidi messages to task_Piconet_Master.
7. task_Piconet_Master: On first initiation the object determines the slaves and establishes a network of piconet bluetooth
device. After receiving the MsgQMidi messages, transfer of protocol stack output along a communication port takes
place.
8. A network with master as server is established when task_Piconet_Slave accepts a bluetooth stack for MIDI file
NumMsg messages. The messages from MIDI files are sorted in order to forward the message to any of the tracks from
P1 to P4. For instance, the messages from track P1 are posted to task_MIDI_Slave P1 from task_Piconet_Slave P1. And
then the posting of message to actuators and orchestrator task_Orchestrator P1 by task_MIDI_Slave P1 takes place.
9. Point 8 is repeated for all the slaves tracks in robot orchestra.
Q8. List out the cycle of actions held in a communication task synchronizing model using an example.
Answer :
A task synchronization model represents sequence of actions held in a communication system.
For instance, consider the synchronization model for masterslave robots communication tasks as shown in figure
below.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
Real Time Operating Systems (JNTU-Kakinada) (Unit-5) 95
1: Events 2: M sgQM idi 4: SigPort

Orchestra Choice
task_M IDI task_Piconet_master Port_Bluetooth

8:M oreData 3:M sgQBluetooth

task_Orchestrator P1 task_M IDI_SlaveP1 task_Piconet_SlaveP1 Port_BluetoothP1


Port_Bluetooth

7a: M sgQM idi P1 6a: M sgQBluethooth P1 5a: SigPortP1 Port_Bluetooth P2


Port_BluetoothP2

7b: M sgQM idiP2 6b: M sgQBluethooth P2 5b: SigPortP2


Port_Bluetooth P3
Port_BluetoothP3
7c: M sgQM idiP3 6c: M sgQBluethooth P3 5c: SigPortP3

task_Orchestrator P4
task_OrchestratorP4 Port_Bluetooth P4
Port_BluetoothP4

7d: M sgQM idiP4 6d: M sgQBluethooth P4 5d: SigPortP4

Figure: Synchronization Model for Master-Slave Robots Communication Tasks


The sequence of operations that take place in the communication task synchronizing model are,
Step 1
task_MIDI indicates the start of the cycle. It accepts events such as Orchestra_Choice and posts MIDI messages
(present in the Orchestra_Choice MIDI messages stored at master) into MsgQMidi.
Step 2
The functions performed by a task, task_Piconet_Master are (a) It identifies the piconet slaves (b) It helps in establishing
a bluetooth communication with the slaves P1 to P4 and (c) task_Piconet_Master accepts MIDI messages from MsgQMidi (d)
It also posts bluetooth stack into MsgQBluetooth and then signals sigport to port_Bluetooth.
Step 3
The task, task_Piconet_SlaveP1 at the slave gets executed after signaling sigport P1 from port_Bluetooth P1. In the
same way, the tasks task_Piconet_SlaveP2, P3 and P4 are performed after signalling sigport P2, P3 and P4 from Port_Bluetooth
P2, P3 and P4 respectively.
Step 4
task_Piconet_Slave P1, P2, P3 and P4 accepts bluetooth stack of the master then these objects make a selection of track
messages for the four tracks of four slaves. It posts these messages into four message queues which are in MIDI format
task_MIDI_Slave P1, P2, P3 and P4 for track P1, P2, P3 and P4 respectively.
Step 5
The MIDI messages are again posted into the track P1, P2, P3 and P4 orchestrators by the task_MIDI_Slave P1,
task_MIDI_Slave P2, task_MIDI_Slave P3 and task_MIDI_Slave P4. The orchestrators then direct these messages to the
actuators of the music track and the robots movements.

5.2 Embedded Systems in Automobile, Case Study of an Embedded System for


an Adaptive Cruise Control (ACC) System in a Car
Q9. List and explain the various devices embedded in a car.
Answer :
An automobile consists of number of embedded systems with atleast one microcontroller and software. A car employs
nine different types of embedded systems. They are,
1. Engine control
2. Speed control and brake
3. Safety systems
4. Seat and pedal controls
5. Car environment controls
6. Route and traffic monitors
7. Automobile status monitoring
8. System interfaces for commands voice activation and interfacing
9. Infotainment system.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
96 (Unit-5) Real Time Operating Systems (JNTU-Kakinada)
Figure shows a diagramatic representation of type of applications of the embedded systems in the car.

Embedded System Applications

1 2 3 4 5
Engine Speed Personal and Seat and
ACHVWLT
Control Control and Car safety Pedal
controllers
systems Brake systems systems controls

RKE SRC MHSAPM


Fuel
ACC Airbag
Injection Immobilizer unit
control
6
Vicinity Alert Route and traffic monitors

Automobile status monitoring and 7


Anti-lock braking automatic braking
CMB, regenerative brake systems data logging

8
Voice activation and commands

Infortainment system and text-to- 9


speed converter
Figure: Applications of the Embedded Systems in the Car
1. Engine Control
This system is controlled by the automatic control of fuel-injection.
2. Speed Control and Brake
The embedded speed control and brake system is employed for Automatic Cruise Control (ACC), antilock braking,
automatic braking and regenerative braking.
3. Safety Systems
Safety systems are designed for both personal and car safety.
(i) Personal Safety
Multiple and variable speed airbags employed in the system are used to provide personal safety. These airbags
are also used for cushioning i.e., for automatic rapid inflation of the bag whenever a deflation takes place as a
result of collision.
(ii) Car Safety
The two systems namely RKE (Remote Key Entry) and immobilizer unit are used to provide the safety of the car.
RKE is used to control door locks whereas immobilizer unit is used to prevent moving of car, whenever an
unauthorized user makes an attempt to drive the car.
The security systems in a car comprises of alarms, lane departure alert, vicinity alert and Collision Mitigation
Brake (CMB) system.
4. Seat and Pedal Control
The Seat Restrain Controller (SRC) and Memory Heated Seat Adjustable Pedal Module (MHSAPM) are used for
controlling seat and pedals in the system.
5. Car Environment Control
The environment of a car which includes the air-conditioning, ventilation, heater, light, temperature and windows are
controlled by the ACHVWLT controller.
6. Route and Traffic Monitor
This system control and monitor the route and traffic by using GPS (Global Positioning System) mapping, GPS guided
route programming and route planners.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
Real Time Operating Systems (JNTU-Kakinada) (Unit-5) 97
7. Automobile Status Monitoring 5. Control Panel
The automobile status monitoring is used to monitor, A control panel is provided with number of switches
(i) Data loggers cum display units.
(ii) Steerable head lights (i) The ON/OFF switch is used to activate or deactivate
(iii) Driving assisting device management the ACC system.
(iv) Windshield IR camera (ii) The coast/resume switch is used to handover or
(v) Windscreen head up display and resume the charge of an ACC system
(vi) Night vision assistance. (iii) The set/accelerate switch is used to set the speed of
8. System Interface for Commands, Voice Activation and the cruise. A red light or green light which indicates
Interfacing the status of an ACC system. Alarms and message
The various system interfaces are the soft flashing units are also employed for issuing alarms
programmable buttons, voice commands, bluetooth interfacing and message flashing pictograms.
for handfree telephony in automobiles and wireless personal
6. Functions of the System
area connectivity in the automobile, GSM/CDMA and WI-FI
internet for mobile connectivity. (i) A cruise control system takes the charge from the
9. Infotainment System driver and controls the throttle position thus enabling
The infotainment systems employed in a car are, the cruising of a vehicle at a predetermined constant
speed. The radar system is employed in order to
1. Displayed text to speech converters
maintain inter-car distance and provide notifications
2. Cassette, audio CD and VCD/DVD players, LCD
in emergency situations.
screen, touch screen panel.
3. Handsfree telephony using bluetooth and GSM/ (ii) Alignment circuits are used to align the radar emitters
CDMA and (especially when driving in hilly areas). By using
4. GPS based car locations, route maps and traffic task_Align object, the stepper motor aligns the radar
reports. emitter such that the transmitted beam of radar emits
with the beam alignment as desired by the driving lane
Q10. List the requirements for an Adaptive Cruise
and divergence. Thus maintaining the in-lane line of
Control (ACC) system.
sight of the front-end car.
Answer : Model Paper-II, Q5(b)
The various requirements of an Adaptive Cruise (iii) Using task_Signal transmit pulses emitted at periodic
Control (ACC) system are, intervals and the delay period for the reflection of pulse
1. Purpose from front-end of car is calculated. The pulses received
are modulated properly such that the system attains
The main purpose of an ACC system is to control
immunity to the noise and avoids the interference of
cruising of car by making use of adaptive control for the car
multiple sources.
speed and inter-car distance.
2. Inputs (iv) Using task_ReadRange object, the distance of the
The inputs required for an ACC system are, front-end car is calculated by using the expression.
Range now, d = delay × 1.5 × 108 m/s.
Current alignment of radar (or laser) beam emitter, delay
interval in the reflected pulse to transmitted pulse, throttle (v) By using task_Range rate object, the differences of ‘d’
position from a stepper motor position sensor, speed from inaccordance distance to ‘dsafe’ and ‘dset’ is evaluated
speedometer, brake status from brake switch and pedal. periodically.
3. Signal Events and Notifications (vi) By using task_Speed object, the speed and error in
These include signals that are received as user preset speed is computed cyclically and is named as
command from switches or buttons, user control inputs (such measured speed.
as ACC ON, OFF, coast, resume, set/accelerate buttons). (vii) All the differences that are calculated periodically are
Events such as ‘brake event’ and distance notifications such given as input to an adaptive algorithm. This algorithm
as safe/unsafe. adapts the control parameters and provides the
4. Outputs calculated output to a vacuum actuator of throttle valve.
The various outputs provided by an ACC system are, All these computations are performed by using
Pulses transmitted at regular intervals, alarms, flashed task_Algorithm object whereas task_Throttle object
messages, range and speed messages for other cars, brake is used to initiate the control output functions. The
control and pedal system outputs (such as applying emergency critical throttle control function is performed by an
brakes). Interrupt Service Routine called ISR_Throttle control.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
98 (Unit-5) Real Time Operating Systems (JNTU-Kakinada)
(viii) Depending on the throttle valve orifice, the car either Model for Adaptive Control Algorithm
accelerates or decelerates if a safe distance is not Adaptive control algorithm computes the output
maintained, the warning message flashes on the screen values to control signals. In an ACC system, output control
and provides a brake control. In order to initiate the signal is produced by adjustable-system subunit for throttle
functions of brake control. The task_Brake is used value.
and the interrupt service routine, ISR_Brake control is
used to perform the functions of brake control. Figure represents the model for an adaptive control
algorithm adaptation and functions.
(ix) In case of low battery the ACC system gets deactivated
Essential components of adaptive control
after issuing notifications in the form of alarm or flash
messages.
Unknown Known perturbations
7. Design Metrics perturbations
The parameters considered while designing an ACC Control
Inputs Adjustable 2 3 signals (s)
system are, system
IP
(i) Power source and power dissipation depends on car A 1 measurement
battery operation. Adaptive D B
(ii) Required resolution is about 2 m inter-car distance. mechanism
Set of given indices
(iii) Desired performance can be maintained by employing of
a safe distance setting of 75 to 200 m. performance Comparison
and
(iv) Process deadlines are set for less than 1S on detection decision
C C and D adapt PID parameters
of unsafe distance. to the continuously measured IP
(v) Graphics such as LCD or touch screen and commands IP-Index of performance measurement
are used as user interfaces.
Figure: Adaptive Control Algorithm Model
(vi) Extendibility to maintain string stability of multiple cars.
The inputs to the index-of-performance measurement
(vii) The ACC system requires an engineering cost of US $ unit are the desired preset cruise velocity (Vt) desired preset
50000 and manufacturing cost of about US $ 600. distance (dset) safe preset distance (dsafe) measured cruise-
8. Test and Validation Conditions velocity (v), measured cruise distance (d). The set performance
The system must be capable of operating in dense and parameters and observed performance parameters are the
light traffic conditions, plains, hills and on valley roads. The inputs to the comparison and decision subunit. The output of
commands provided by the users must function correctly. this unit is fed as inputs to the adaptive mechanism subunit.
The outputs of the adaptive mechanism subunit are inturn
Q11. What is Adaptive Cruise Control (ACC) system?
fed as inputs to the adjustable system.
Explain the model for adaptation and
functions of an adaptive control algorithm. Q12. Explain the port devices and their functions
Answer : in an ACC system along with the ACC software
tasks synchronization model.
Adaptive Cruise Control (ACC) System
Answer :
Adaptive Cruise Control (ACC) system is a speed
control system used for regulating the speed of a car The various port devices of an ACC system are,
automatically. It is also known as autonomous cruise control, (i) Port_Align
active cruise control or Intelligent Cruise Control (ICC) system.
A car equipped with an ACC system moves in cruise mode at (ii) Port_ReadRange
a pre-determined speed (by the driver). A radar or laser or UV (iii) Port_Speed
is used for emitting signals at regular intervals of time. These (iv) Port_Brake.
signals are reflected back by the vehicles present in front of
the core. (i) Port_Align
If the reflected signals are received earlier to the The port_Align port device is a stepper motor port
minimum safe distance, the ACC system detects it and task_Align helps in the movement of motor in either
decelerates the speed of car. When conditions turn to be clockwise or anti-clockwise direction. The stepper
suitable, the system accelerates to the preset speed ACC motor arranges the radar or Ultra Very High Frequency
systems are generally used in aviation electronics and defense (UVHF) transmitting device in the lane of front-end
aircrafts and in modern automotives. car.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
Real Time Operating Systems (JNTU-Kakinada) (Unit-5) 9 9
(ii) Port _ReadRange
The Port_Read Range port is a front-end car range measuring port. The time difference known as ‘deltaT’ is measured
between task_Signal and port device on a signal. The sensor antenna accepts the radar signal emitted by the port
device from the front-end car. The delay time elapsed between the transmission and reception of signals is computed by
‘task_ReadRange’. The distance ‘range now’ (d) measured in km of the front-end car is accomplished by multiplying the
delay time in the control signals by a factor 1.5 × 105 m the range now. task_ReadRange also transmits message for d-
distance to the task_Range rate and all other streaming cars.
(iii) Port_Speed
The port control function routine is enabled when a free running counter overflow interrupts and is disabled when free
running counter overflows. After accepting a signal from task_Speed (on first single-bit input from the wheel), the free
running counter is set to count 0 and a parameter N_rotation to ‘0’. The memory buffer employed in the port data are
used to store the number of counts in the free running counter. After every successive rotation, the counts are stored
in the memory (i.e., count N for Nth rotation) and N_Rotation is incremented by ‘1’. As soon as a counter overflow
occurs, the difference between the last count and count 0 is calculated and is stored in the memory. The expression used
for computing current speed v or speed now is,

N − Rotation× Wheel circumference in metre


V= km/s
Tclock × [(clock N = count0) ×1000
The task_Range Rate accepts a message from task_Speed in order to display controller at speedometer i.e., for speed
now. The task_Algorithm then receives messages from task_Range Rate for (rangeNow_dset) (Speed Now_vset)
purposes.
(iv) Port_Brake
As soon as an interrupt signal is encountered, the port device, port_Brake provides either brakes or emergency brakes
on it. The interrupts are disabled at the initial stages by a service routine, ISR_Brake control are activated on exiting the
critical section.
Task Synchronization Model of ACC Software
2: Events

task_Align ISR_Align ISR_Ranging task_ReadRange


1: Event
3: Events 4: SigRange
9: SigReset
10: Event
ISR_Brake

task_Speed task_Range task_Algorithm ISR_Throttle


Rate

5: Event 6: Sigspeed 7: SigACC 8: Events


Figure: ACC Tasks Synchronization Model
Figure represents the synchronization model for ACC tasks. The sequence of tasks held in the ACC system model
are,
Task 1
The task, task_Align indicates the beginning of the cycle. After occurrence of an event, namely ISR call, it transmits the
signal to the ports, Port_Align and Port_Ranging of a stepper motor. The motor rotates by a single step in either clock
wise or anticlockwise direction, as per the requirements.
Task 2
In order to calculate range of the front-end car, the task named task_ReadRange is employed. The task while entering
into a critical sections deactivates all the interrupts and demands for the real-time measurements in the system. The port
device, Port_ReadRange is used to compute the distance (d).

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
1 0 0 (Unit-5) Real Time Operating Systems (JNTU-Kakinada)
Task 3
The task, task_Speed receives the port reading at a Port_Speed. The task trasmits a current velocity (v) using count N
and count0 interval between the initial and Nth rotation.
Task 4
The tasks task_RangeRate transmits the rangeNow which helps in estimating,
(i) Final error and
(ii) Error.
(a) The final error is estimated inorder to maintain the stability of the string from the output of task_ReadRange.
(b) The error is estimated in order to maintain the car speed from the output of task_Speed.
The output of both error values is used by control system adaptive algorithm.
The port, Port_Speed is connected to the speedometer system of DAS for displaying speednow which is transmitted to
other streaming cars through Port_RangeRate.
Finally, the task calculates range and rate errors and transmits both range now and speed now.
Task 5
The adaptive algorithm from task 4 is run by task_Algorithm which receives input from task_RangeRate and transmits
the output as events to Port_Throttle and brake. The Port_Throtle attaches to the vacuum actuator stepper motor.
After a certain amount of delay, the entire cycle begins again from task_Align which reads the status of both Port_Brake
and other streaming cars.
Q13. Give an account of hardware and software architecture of an ACC system.
Answer :
Hardware Architecture of ACC
The hardware unit employed in an automotive electronics is used to provide functional safety of the system. Some of
the important standards and guidance of hardware are,
(i) Time Triggered Protocol (TTP)
(ii) Controller Area Network (CAN)
(iii) Media Oriented System Transport (MOST) and
(iv) Institute of Electrical Engineers (IEE) for Electromagnetic Control (EMC) and functional safety guidance.
ACC hardware subunit uses both microcontroller and a separate microprocessor as shown in figure below.
To align unit

Flash Port
Port_Align Port_Speed To Speedometer
Memory/ROM

Micro_Controller
CPU RAM Port_ReadRange CAN port To Network bus
Bus

Hold/Start
ROM and RAM Micro
Micro_Processor Transceiver To antenna
To LCD dot matrix
For task To throttle display controller or
Algorithm To brake display panel
interrupts
Figure: ACC Hardware

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
Real Time Operating Systems (JNTU-Kakinada) (Unit-5) 1 0 1
Hardware units of ACC are as follows,
(a) Micro-controller
A micro-controller employs internal ROM, RAM and a CAN port in order to run service routines and tasks. ROM
enables the storage of application codes and RTOS codes which are used for scheduling tasks. RAM helps in storing
temporary variables and stack. CAN port is used to interface with CAN bus of car. It also provides interfacing of ACC
system with the other embedded systems of car. The interrupts occured in the system are controlled by the interrupt
controller.
(b) Micro-Processor
It consists of a separate ROM and RAM for the task, Task_Algorithm in order to execute adaptive control algorithm.
(c) Transceiver
It is used to transmit pulses through antenna.
(d) The ACC system also includes speedometer. Stepper motor-based alignment and throttle control unit, LCD dot matrix
display controller, display panel with buttons.
(e) Port Device
There are five types of ports devices employed in a ACC hardware inorder to perform five different actions. Five port
devices along with their actions are,
1. Port_Align
For aligning transmitted beam towards the lane.
2. Port_Speed
To compute speed (v) at the ACC.
3. Port_ReadRange
To determine range (d) at the ACC.
4. Port_Throttle
For positioning throttle as per task_Algorithm control message.
5. Port_Brake
It is used to provide braking action as per ISR-brake control message.
Software Architecture of ACC
The software architecture consists of task, functions and IPCs, which are required to provide balanced process in a
system.
Among the four available tasks classified per OSEK (viz. BCC1, ECC1, BCC2, ECC2), the ACC system uses BCC1 i.e.,
Basic Conformance Class1. It is a basic with one task (of each priority) and provides only one activation to a programmer.
OSEK task consists of three types of objects such as,
(a) Event (semaphore)
(b) Resources (statements and functions) and
(c) Devices along with port devices.
The purpose of using semaphores is to define the sequence of tasks running and periodically running ACC tasks. It
also helps in running the string stability controller algorithm at task_Algorithm.
Q14. Discuss the important rules and coding standards in MISRA-C.
Answer :
The Automotive Cruise Control (ACC) system employs OSEK OS software. The software uses only the Vx works or
MUCOS functions that satisfy OSEK standards. The software codings such as IEC 61503 part 3 and MISRA-C version 2 (2004)
are used along with coding language specifications, MISRA-C defines a set of rules to be used while coding C.
MISRA (Motor Industry Software Reliability Association) a ‘C’ language standard provides guidelines for automotive
systems. It was initially setup to combine vehicle manufactures, component suppliers, engineering consultancies and to
support language requirements in order to enhance the practice in developing safety related electronic systems in road
vehicles and other systems. MISRA-C-version 2 specifies 141 rules for coding and provided a new structure to ‘c’ language.
The important rules coding and standards in MISRA-C are as shown in figure below.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
1 0 2 (Unit-5) Real Time Operating Systems (JNTU-Kakinada)
MISRA-C version 2 (2004)

1 50 101 118
ISO 9899 standard No inequality or No allocation of
141 rules No pointer
C and no equality tests for memory dynamically
New structure arithmetic
extensions of it floating point variables to a heap

Conformance to IEC 61503 part 3

Coding standards Coding practices Removal of


standard undefined unsafe
language features
Source documentation standards
Figure: Important Rules and Coding Standards of MISRA-C Version 2 (2004)
Some of the important rules of MISRA-C version 2 (2004) are,
(i) Rule 1
All the C codes used in automobiles must be certified from ISO 9899 standard and it should not allow any extension to
the standard .
(ii) Rule 43
Implicit cast is not allowed as it results in loss of information.
(iii) Rule 50
This rule do not allow floating points variables since these experience rounding-off errors.
(iv) Rule 65
The rule 65 do not allow floating-point numbers as loop counters.
(v) Rule 101
Pointer arithmetic are not allowed in MISRA-C standard.
(vi) Rule 118
Dynamic allocation of memory to a head is not allowed. Since it involves the risk of using additional memory available
in the system and also results in memory leaks.

5.3 Case Study of an Embedded System for a Smart Card


Q15. Write down the requirements and functioning of a smart card communication system.
Answer :
The requirements and functioning of a smart card communication system are,
1. Purpose
The smart card should be authenticated and both the card and the card holder must be verified by the host machine. The
Graphic User Interface (GUI) at host machine must be capable of interacting with the card holder for carrying out the
desired transactions. For instance, financial transactions with a bank or credit card or ATM card transactions.
2. System Functioning
(i) When a card is inserted into a host machine, the radiations from the host enables a charge pump at the card. This
charge pump supplies power to the SOC circuit, which employs a card processor, timer, memory, interrupt handler
and Port_IO for its operation.
(ii) The system_Reset after receiving a certain amount of power signals the resetTask in order to start the operation.
The resetTask transmits the two messages namely requestHeader, requestStart to the waiting task, task_Read
port.
(iii) task_ReadPort is used to perform the following,
(a) Send requests for identification of host
(b) Reading the host identification message through Port_IO and
(c) It also requests from the host for card identification purpose.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
Real Time Operating Systems (JNTU-Kakinada) (Unit-5) 1 0 3
(iv) task_PW sends the requested card identification (i) Power Source and Power Dissipation
through Port_IO only after receiving the host The source of power is radiation and a contactless
identity through the same port. operation is carriedout while communicating with a
host.
(v) task_Appl is used for running required
Application Programming Interface (API). After (ii) Code Size
accomplishing a specific task, ‘requestApplClose’ The codesize generated must be optimum, i.e., the card
message is used to close the application. memory should not exceed 64 kB. This can be
accomplished by employing limited datatypes such as
(vi) Finally, the card is withdrawn and all the required multidimensional arrays, long 64-bit integer and
transactions takes place between the user and floating points.
host through GUI’s present on the host control
(iii) File System
panel such as touch screen or LCD display.
A three-layered file system, consisting of master file,
3. Inputs dedicated file and elementary file must be used. The
masterfile holds all the headers, dedicated file stores a
The IO port, Port_IO receives the header and message
file grouping and headers of successor elementary files
inputs which are sent over an antenna from the host
of the group and elementary file stores both file header
machine. and file data.
4. Signals, Events and Notifications (iv) File Management
The various signals, events and notifications File management can be of either fixed length type or
employed in the smart card communication system are, variable length type with a predefined offset at each
file.
(i) On powerup, a signal sent to start the system (v) Micro-Controller Hardware
boots the program at resetTask.
A microcontroller generates distinct coded physical
(ii) In order to start the use of card message, addresses for program and data logical addresses is
requestHeader sent from resetTask to taskRead used.
Port. (vi) Validity
(iii) Host authentication request ‘requestStart’ After the expiry of card validity date, the card
message sent from resetTask to task_Readport authorization through the host gets disabled.
so as to enable the request for Port_IO. (vii) Extendibility
The expiry date of the system can be extended by
(iv) The verification message or notification, user PW
transactions and authorization of master control unit
sent by host through Port_IO.
such as bank serve.
(v) The ‘requestApplClose’ message sent to Port_IO (viii) Performance
in order to close the card application. It takes less than 1sec for transferring control from
5. Outputs card to the host machine.
(ix) Process Deadlines
Outputs in the form of transmitted headers and
messages are received at Port_IO through antenna. The smart card communication system with host does
not hold any predefined process deadlines.
6. Control Panel (x) User Interfaces
These are not employed in any of the smart cards GUIs such as LCD or touch screen display on LCD are
instead the control panel and GUIs are present at host used at the host machine and commands are used for
machine only. the card holder transactions.
(xi) Cost
Example: ATM or Credit card reader.
The estimated engineering cost is about US $ 50000
7. Design Metrics and manufacturing cost is approximated to be US $ 1.
The various design metrics used in the smart card 8. Test and Validation Conditions
communication system in order to analyze its It is tested on different versions of host machines for
performance are, fail proof card-host communication purposes.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
1 0 4 (Unit-5) Real Time Operating Systems (JNTU-Kakinada)
Q16. Draw and explain the class diagram of Task_Cardcommunication. Also explain the software and
hardware architecture of a smart card.
Answer :
The class diagram of Task_Cardcommunication is as shown in figure (1).

Task_card-communication

Task_Reset ISR1_Port_IO

Task_ReadPort ISR2_Port_IO

Task_PW ISR3_Port_IO

Task_appl

Figure (1): Class Diagram of Task_CardCommunication


Figure (1) depicts that the task_Cardcommunication is an abstract class and a cycle of actions and card_host
synchronization in the card leads to a implementation of Task_card communication model for system tasks. Card system
communicates with the host for both verification and authenticaton of itself to host. The interrupt service routines of IO ports
such as ISR1_Port_IO, ISR2_port_IO and ISR3_Port_IO are used as interfaces to the tasks. The implementation of these
interfacing routines are specified by a class. The task_Appl, task_PW, task_Read port and resetTask represent the objects of
the classes Task_Appl, Task_PW, task_Read port and Task_Reset respectively. These three classes are the extended classes
of abstract class Task_Card communication.
The various interfaces used by the different classes for communication purposes are,
Task_Readport used for interfacing of ISR1_Port_IO.
(i) Task_Readport interfaces ISR1_Port_IO similarly, Task_PW interfaces ISR2_Port_IO and Task_Appl interfaces
ISR3_Port_IO.
(ii) task_PW interfaces ISR2_Port_IO.
(iii) Task_Appl interfaces ISR3_Port_IO.
Hardware Architecture of a Smart Card
Hardware architecture of a smart card is as shown in figure (2).

Flash memory/ROM
Micro-controller
Transceiver To surface
antenna
and from
CPU RAM Port_IO
host machine
antenna
D0-D7
A0-A15
VCC Charge pump

Figure (2): Smart Card Hardware Architecture


The smart card is a plastic card with ISO standard dimension of 85.60 × 53.98 × 0.80 mm. The embedded hardware
components employed in smart card are, flash memory or ROM, microcontroller, CPU, RAM, interfacing circuits, Vcc charge
pump etc.
1. Microcontroller
A microcontroller with different specifications such as MC68HC11DO PIC16C84 smart card processor phillips smart XA
or similar asip processors is used in the smart card.
2. RAM
Random Access Memory (RAM) is used for the storage of temporary variables and stack during the execution of card
operations.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
Real Time Operating Systems (JNTU-Kakinada) (Unit-5) 1 0 5
3. ROM
Read Only Memory (ROM) stores unique secret key (fabrication key), personalization key, application and RTOS
codes. It prevents the access of a particular memory segment.
4. Charge Pump
It extracts an appropriate amount of power and then supplies it the card chip, memory and IO system.
5. Transceiver
It is used for both transmitting and receiving the signals from the circuit components.
6. Power Supply (Vcc)
It is used for supplying suitable amount of power to the charge pump.
7. CPU
CPU in the smart card has special features such as security lock, blocking of particular data from accessing.
Software Architecture of Smart Card
The software employed in the smart card is Java. It consists of inbuilt thread scheduler in Java Virtual Machine (JVM)
which eliminates the use of separate multitasking operating system. Since, all the Java byte codes run in jvm environment.
The two important functions supported by Java are,
1. Security using class java.lang.Security Manager and
2. Cryptographic requirements using the package java.security*.
It also offers the functions such as connections, datagrams, IO streams and network sockets.
The enhance version of Java, Java mix runs the cards native applications using C or C++ and downloadable applications
are executed using Java or Java card. The smart system consists of both OS and JVM. In the smart card application, the smart
OS is considered as a hypothetical OS. The two major functions of the smart OS are,
1. Unsigned Char[ ] Smart OS Encrypt (Unsigned char* ApplStr, Entype Type)
This function encrypts depending on the encryption method employed. A selection between Entype = “RSA” or “DES”
is made and the control then returns an encrypted string.
2. Unsigned Char[ ] Smart OS Decrypt (Unsigned char* str, Detype type)
It encrypts the data based on deciphering method, where detype = “RSA” or “DES” algorithm is selected and it return
deciphered strings to the function.
These two functions, SmartOSEncrypt and SmartOSDecrypt are executed only after the verification of access conditions
from the data files which stores the password, keys and pins.
Q17. List out the steps involved in the task synchronization model in smart card.
Answer :
The actions involved in the task synchronization model when the smart card and host machine antenna are brought in
contact with each other are,
1. In the first step, as soon as the card is inserted into the machine, the carrier frequency radiations or clock signals are
received from the host machine. These extracted charges are used to supply power for processor, modem, memories and
port-IO devices.
2. In 2nd step, after supplying power to system the codes are run for bootup task on reset resetTask. The execution of
codes starts from main function which creates and initiates the reset Task and starts the smart OS. The task which gets
executed first is the resetTask.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
1 0 6 (Unit-5) Real Time Operating Systems (JNTU-Kakinada)
The task synchronization model in smart is as shown in figure.

Reset Task Task_Read port Task_PW Task_App1

Sem PW
Sem Reset
Request Time
Request Header
Password
Request Start

Msg QPW

Sem Appl
Request App1
MsgQ Appl

MsgQ Appl close


Request_Appl close

Figure: Task and the Synchronization Model


The steps involved in task synchronization model are,
1. resetTask
The resetTask is the task with highest priority i.e. it is used for initiating executed first. It permanently suspends the
execution after the following operations,
(i) It starts the timer to count the system ticks which are generally reset at 1 ms.
(ii) It also creates three tasks namely task_ReadPort, task_PW and task_Appl.
The resetTask transfers initial messages to start the execution of task and then automatically suspend itself after
accomplishing the task.
2. task_ReadPort
This task waits for the suspension of resettask to start its execution. The task-Readport helps in transfers of queue
messages and receiving of the messages. After termination of program application, it sends close request messages to
message queue in order to obtain the “Closure Permission” for closing the application.
3. task_PW
This task is used to send the request for password to message queue, in order to verify the host. (i.e., sempw = 1).
4. task_APPl
task_Appl is used for the execution of application program. Only after the verification of password applications
programs (when sempw = 1).

5.4 Case Study of Embedded System of Mobile Phone Software for Key Inputs
Q18. List the requirements of ‘SMS create and send application’ for a mobile phone. Explain the actions
of each.
Answer :
The various requirements of SMS create and send applications for a mobile phone are,
1. Purpose
‘SMS create and send application’ is used for creating a message using a T9 format keypad. The three tasks employed
in this application are ‘inserting a desire mobile number into a list’, ‘editing a message’ and ‘sending the message’.
2. Functions of the System
The sequence of actions carried out in order to perform ‘SMS create and send application’ function for a mobile phone
are,

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
Real Time Operating Systems (JNTU-Kakinada) (Unit-5) 1 0 7
Step 1 (ii) When a set of four notifications: MsgMessages,
A mobile phone which is in inactive state is brought MsgTextMessages, MsgCreate and Msgtext are
back to wake-up state by using key2 row2 interrupt. posted then an event ESMS is created which starts
Now screen is displayed. SMS_Create_Text application.
Step 2 (iii) Notifications such as ‘Message sent’ after sending of
In order to start the application, ‘SMS creating text’ a message, ‘Sending message’ before completing the
key1 row1 key is pressed which selects the command transmission of SMS are displayed on mobile screen.
‘Messages’. This displays a set of options on the 6. Outputs
mobile screen.
(i) When editing an SMS, the SMS_Create_Text string
Step 3 gets displayed on the screen and is automatically saved
From the displayed options, a command option ‘Text in both scratchpad memory as well as in sent folder
messages’ is selected . A menu then shows another after sending the SMS.
set of options such as create message, inbox, sent
(ii) Menu text lines are required on screen for displaying
items.
options, text of menu, marked text or character to carry
Step 4 out selection by a single click.
From the displayed set of options, the application (iii) Help menu text display is also used which displays
‘Create message’ is selected. For executing SMS actions that take place on selecting an option (the one
creation application. A menu then shows for selecting at which cursor points) after a Tout_Help_Option
type of message to be created such as text and numeric interrupt.
page.
7. Scratchpad Memory
Step 5
The ‘Text’ option is selected so as to create a text SMS. This memory is used to save a maximum of 160 character
This generates an event E_SMS which directs a task in an SMS.
to run the text message create application in alpha- 8. Persistence Memory
numeric format.
Persistence memory stores SMS in Inbox, Sent, Archive
Step 6 and Template.
After creating a message next step involved is either
9. Design Metrics
to Add number of the receiver Edit message or send
message. (i) It requires battery power for its operation.
Step 7 (ii) It takes about 3 minutes for 1 SMS message
The option ‘Send message’ is selected in order to send creation and send application.
the created message to the specified number. (iii) The engineering cost for hardware is approximately
3. GUI (Graphical User Interface) US $ 20000 and no manufacturing cost is imposed
Graphical user interface makes use of display of screen once the codes are tested.
menu, text and cursor, command_Select and cursor_Position- 10. Test and Validation Conditions
change keys. The cursor position can be changed up, down,
left, right as per user requirement by using C1,C2, C3 and C4. All the commands and functioning of options are
tested.
4. Inputs
Q19. Explain the hardware required for SMS keying.
The various inputs provided using a T9 keypad as
interface in the form of unit (key1, ... key9) are mode keys such Answer :
as key M1 and M2 designated by * and #, 0 key for [spaces, The hardware units employed for SMS keying
new-line etc.], command from any of the four command keys applications are,
[key1 row1, key2 row1, key1 row2, key2 row2] and cursor
movement using C1 key, C2 key, C3 key or C4 key. 1. Cursor key
5. Signals, Events and Notifications 2. Command keys
(i) When a command or any other key is pressed by the 3. T9 keys
user, an event E-Newstate gets generated and posted
4. Mode keys
onto an interrupt for an ISR that initiates the required
action. 5. Display screen

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
1 0 8 (Unit-5) Real Time Operating Systems (JNTU-Kakinada)
1. Cursor Key
A four-way cursor key is used to edit the SMS when it is being created. These keys enable a cursor to move up, down,
right and left as per the requirement. The actions of a cursor key are similar to those performed by ↑ , ↓ , ← , → keys on a
keyboard. As soon as a cursor-key interrupt is encountered by a single click, notifications are sent for the states C1 key, C2 key,
C3key and C4 key and also for current cursor display position.
2. Command Keys
The four command keys available in the application are key1 row1, key2 row1, key1 row2 and key2 row2. The operation
of keys, key1 row1 and key2 row1 is same as that of left and right clicks in a computer mouse for graphical user interfaces. And
key1 row2 and key2 row2 are similar to ‘start’ menu item and ‘turn-off or ‘restart’ menu item in a computer start up window.
Whenever a command-key is pressed, the command-key interrupt routine sends notifications for both commands and
their options. The different uses of these keys are,
(i) Right-corner-second row command key (i.e. key2 row2 interrupt) is used to activate the idle device and to show start-
up display. It is represented by a red with phone head down sign. This key is also used to switch off an active operation
(eg: a phone call).
(ii) Left-corner-second row command key (for key1 row2 interrupt) is used to dial the selected number on screen. It is
marked green with phone head lifted sign. This key can also be used to receive an incoming call.
(iii) Left-corner-first row command key (for key1 row1 interrupt) is used for the activation of all the available options, menus
and submenus required for beginning of an application. This keys performs the actions similar to that of left click of a
mouse button.
(iv) Right-corner-first row key (for key2 row1 interrupt) is used to activate menu commands like ‘to select’, to clear’, to go
back’. The action of this key is similar to that of right click of computer-mouse button.
3. T9 Keys
T9 keypad is used for SMS keying-in. The T9 keypad consists on nine keys (1 to 9) with an additional key 0. T9 key
inputs (key1, ....key9) are used for dialling numbers and also for editing the text inputs during an ‘SMS create application.
4. Mode Keys
Two mode keys * and # are used in the application. These keys enable the modification of key M1 and key M2 states.
For instance, consider key1 row1 and M1 are pressed simultaneously. This protects the accidental use of keys when kept in a
pocket. The pad undergoes a transition to lock state if it was in the unlock state and vice versa. Another example is of bilingual
or multilingual text SMS editing. M2 can be used to convert the English text mode to any other language text mode.
5. Display Screen
Display screen is used for displaying the Graphical User Interfaces (GUIs) for startup display, menus, options, text
being edited or current operations.
Q20. With neat block diagram explain the architecture for SMS create and send application software.
Answer :
The software architecture for SMS create and send application includes the following modules,
(i) Operating Systems (OS)
Operating system is employed to control the message queue functions (such as OSMsgQAccept, OSMQPost and
OSmsgQPend) at message boxes and event functions at the event boxes. It also enables the synchronization of tasks and helps
in simultaneous processing of SMS application on mobile.
(ii) key system layer using orchestrator and interrupt service routines on interrupts from the keys i.e., ISR_KINTS.
The layer which is used for key system in software architecture is referred as “key system layer”. Figure below shows
a key system layer.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
Real Time Operating Systems (JNTU-Kakinada) (Unit-5) 1 0 9
p
1
Message box 2
3 Command key
q 4 interrupt
Message box 5
6 Cursor key
7
Event box interrupt
8
E_sms
9
Event box 10
E_new state 11
12
Orchestrator 13 T9 key
14 interrupt
15
16
17

18
Key interrupt

19
20 Key 0key
Mode interrupts
interrupt

Cursor message box

Timer Message box

Figure: Key_System Layer with ISR_KINT and Orchestrator in Software Architecture of Mobile
Whenever a key is pressed an interrupt and a service routine ISR_KINT are generated, which runs an orchestrator. The
interrupt service routine i.e. ISR_KINT is used to read the status bits of port to identify the key pressed, reading the timer
status, timer counts, cursor positions and text messages. After reading the port status ISR_KINT directs the orchestrator to
initiate, generate the notifications and events to post them into the message and event boxes.
For instance, the messages posted by orchestrator on initialization of IST_KINT are,
1. MsgMessages
This message is posted when a cursor on display screen indicates a command_Msg Messages.
2. MsgText Message
This message gets posted when cursor on display screen indicates a command_Option_Msg TextMessages.
3. MsgCreate
This message is posted, when cursor on display screen indicates an application_option_Msg point to create a mes-
sage.
4. MsgTextType
This message is posted, when cursor on display screen indicates a type_Option_Msg Text.
5. S_key0, S_key1, S_key2 --- or S_key9 state depending on the status of timer and counts if any new state of key0, key1,
key2 --- key9 is made available.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
1 1 0 (Unit-5) Real Time Operating Systems (JNTU-Kakinada)
6. When any of the 4 available cursor (i.e. C1 or C2 or C3 or C4) is pressed then, S_C1, S_C2, S_C3 or S_C4 states get
posted.

7. If M1 or M2 is pressed the S_M1 or S_M2 states are posted.

8. S_Key1 Row1, S_Key1 Row2, S_Key1 Row2 or S_Key2 Row2 S_Key1Row1 if a command key pressed is clicked.

9. E_SMS if command, command option, application option and type options MsgMessages, MsgText Messages Msg
create and MsgTextType get posted [i.e. MsgMessages,MsgTextMessages, Msgcreate and MsgTextType begin the
event object E_SMS].

10. E_New state

Any change in the states from change i.e. step 5 or 6 or 7 or 8. posts the E_New state message.

11. Application Layer

Application layer consists of both tasks and ISRs. It is a layer defined in a software architecture.

(i) An application task is object of class which runs on posting of a message object MsgTextMessage or
MsgMessages or MsgTextMessages, MsgCreate or MsgTextType into a message box by an ISR-KINT on the
occurrence of a new state i.e., E_New State.

(ii) The other application task in application layer is Task_SMS_CreateTextSend for sms create and send application
which runs the E_sms event.

Q21. Draw the state diagram for task_sms_createtext send. Also, explain the synchronization model for
sms create and application tasks ISR and orchestrator task using message and event boxes.

Answer :

The state diagram for task_SMs_CreatetextSend is as shown in figure (1),

Start

E_SMS

Orchestrator task_SMS_CreateTextSend

True False False

True MsgSend
MsgAdd True
False
Number
MsgText`
task_EditMessage task_AddNumber task_Send
StateKey1Row1 StateKey1Row1
MsgListRecipient MsgAddList MsgAddEmail
Task_ListRecipient Task_AddList Task_AddEmail

StateKey1Row1 = (1, options) or (1, select) End

Figure (1): State diagram for task_SMS_createTextSend

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
Real Time Operating Systems (JNTU-Kakinada) (Unit-5) 1 1 1
The synchronization model for sms create and application tasks, ISRS and orchestrator tasks using message and event
boxes is as shown in figure (2),

Signal

ISR_KINT Orchestrator Message boxe and Event Boxes

0:S_Key1Row 1 task_TextMessages task_CreateMessage


3:MsgTextMessages 4:MsgCreate
task_Messages

1: KINT 2:MsgMessages 5:MsgTextType


Orchestrator task_Text
9:MsgEditMessage 7:MsgAddNumber
11:SMS_Create_Text string task_SMS_CreateTextSend
task_Send task_EditMessage 6:E_SMS
task_AddNumber
12:MsgSend 10:State of a Key 8:State of a Key task_AddEmail
task_ListRecipient
13:MsgCommunication Communication Port
task_Addlist
Interface ISR_WirelessPort SMS
14:SMS_Create_Text string

Figure (2): Synchronization Model for SMS Create and Application Tasks, ISRS and Orchestrator Tasks (tasks-Addlist, Task-List
Recipient and task-Add E mail Synchronization Not Shown
It can be observed from figure (2) that the SMS communication system involves cycle of actions and tasks synchronizing
model.
A cycle begins at orchestrator, which posts notifications to different objects i.e. task_Message, task_Text Messages,
task-create messages and task_Text on user selection.
1. task_Messages
The task, task_Messages receives a notification by message s_key1 row1 command and then posts a MsgMessages,
message.
2. task_TextMessages
A task, task_TextMessage is one of the command option. Depending on the selection made by the user, the Msg Text
Message message gets posted.
3. task_Create Message
A task, task-createMessage accepts the MsgtextMessags obtained from its preceding task and posts Msgcreate to
next task as per the choice made by the user.
4. Task_Text
A task, task_text accepts the message Msgcreate and posts MsgText to the next task on user choice.
5. The orchestrator now posts the E_sms to the Task_sms_createTextSend which signals to display the menu items for
initiating different task, such as task_AddNumber, task_EditMessage, task_Send, task-AddEmail and task_listRecipient.
6. Task_AddNumber
The task, task_AddNumber is used for adding the mobile number from the available list in order to send the sms and
posts message, msgAddNumber on user selection.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
1 1 2 (Unit-5) Real Time Operating Systems (JNTU-Kakinada)
7. Orchestrator posts message depending on user choice, which signals task_Edit Message to start its execution. The
message is used for creating and editing the message by inputting the characters. The orchestrator receives the key
states on each click and posts state in the message box of the clicked_key while editing. The task, task_Editmessage
then accepts the state message of the key and results in the generation of and Sms_create_Textstring.
8. Again depending on the command choice of the user, the orchestrator posts message, which signals other task
task_Send to send the message, MsgSend.
9. The message which is posted by task_Send is accepted by orchestrator and it then posts another message msg
communication for communication port interface. A wireless network is used for the reception of MsgCommunication
and posting of Sms_create_Textstring.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.

You might also like