You are on page 1of 5

S.

18 Real Time Operating Systems (April-2015, Set-4) JNTU-Kakinada


Code No.: R42049/R10
IV B.Tech II Semester Regular/Supplementary Examinations
April - 2015
Set-4
Solutions
REAL TIME OPERATING SYSTEMS
( Common to Electronics & Communication Engineering, Electronics & Instrumentation Engineering and
Electronics & Communication Engineering )
Time: 3 Hours Max. Marks: 75
Answer any FIVE Questions
All Questions carry equal marks
---
1. (a) Illustrate the role of interrupts their functioning in RTOS with suitable examples. [8] (Unit-I, Topic No.1.3)
(b) Discuss I/O subsystem in a typical I/O system in an OS. [7] (Unit-I, Topic No. 1.3)
2. (a) Write about the programming concepts of Mucos-II with relevant examples. [8] Unit-II, Topic No.2.2)
(b) Illustrate how the synchronization through binary semaphores done in Vx works. [7] (Unit-II, Topic No.2.3)
3. (a) Discuss the real time programming concepts of windows CE. [8] Unit-III, Topic No. 3.1)
(b) Bring out the difference in OSEK, RTOS Linux. [7] (Unit-III, Topic No. 3.3)
4. (a) Write the design and coding of an Automatic Chocolate Vending Machine using Mucos RTOS. [8]
(Unit-IV, Topic No.4.1)
(b) Draw and explain the digital camera hardware and software architecture. [7] (Unit-IV, Topic No.4.2)
5. (a) Write about the program development modelling of Robots with RTOS. [8] (Unit-V, Topic No.5.1)
(b) Explain the design issues in an Embedded system for an adaptive cruise control system in car. [7]
(Unit-V, Topic No.5.2)
6. (a) Discus about the off-the-shelf operating systems. [8] (Unit-VI, Topic No.6.1)
(b) Explain about the target Image creation for Window XP embedded. [7] (Unit-VI, Topic No.6.3)
7. (a) With the help of diagram explain the architecture of a generic Linux system. Explain the following,
(i) Write
(ii) Read
(iii) Exec
(vi) Fork. [8] (Unit-VII, Topic No. 7.1)
(b) Write about the concepts of shell programming. [7] (Unit-VII, Topic No. 7.2)
8. (a) Develop a program to display a message periodically using RT Linux. [8] (Unit-VIII, Topic No.8.3)
(b) Explain the semaphore management done in RT Linux. [7] (Unit-VIII, Topic No. 8.3)

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
Real Time Operating Systems (April-2015, Set-4) JNTU-Kakinada S.19

SOLUTIONS TO APRIL-2015, SET-4, QP


Q1. (a)
Illustrate the role of interrupts their The binary semaphore provides benefit over disabling
functioning in RTOS with suitable of interrupt, the mutex semaphore takes care of priority inversion
examples. problem. The queue in Vx works has some functions which are
Answer : April-15, Set-4, Q1(a) M[8] in a library, msg lib synchronization is to be carried for full
duplex communication between two tasks and each task is
For answer refer Unit-I, Q16.
provided with a queue.
(b)
Discuss I/O subsystem in a typical I/O 1. Create binary semaphore for IPC.
system in an OS.
Use ‘SEM_ID SemB create to create an ECB pointed by
Answer : April-15, Set-4, Q1(b) M[7] SEM-10
For answer refer Unit-I, Q15 The argument ‘initial state’ passes the initial state of binary
Q2. (a) Write about the programming concepts of semaphore. The following are taken care to use binary semaphore
mucos-II with relevant examples. (a) Declaration of initial value, SEM_EMPTY
Answer : April-15, Set-4, Q2(a) M[8] (b) Use Sem Take ( ) ; SEM_FULL
Programming Concepts of MUCOS-II (c) Use Sem Give ( ) ; SemB Create ( )
MUCOS-II or µ COS-II Stands for micro-controller 2. Waiting for IPC for binary semaphore release; Use the
operating system it is a popular RTOS for the development of function STATUS Sem Take for letting task wait untill the event
embedded system. It finds many applications in various fields is released.
like avionics, automotive, consumer electronics, medical, Passing parameters include SemID, time out, returning
aerospace, military, SOC development and networking. parameters in clude Sem Take ( )
The codes of µ COS are written in ‘C’ and some are in 3. Sending an IPC after the release of binary semaphore;
assembly language. The programming features of MUCOS -II The function ‘ STATUS SemGive (semId)’ enables the
include ROMable, scalable, portable, preemptive, multitasking, task to release the binary or some other type of semaphore.
reliable, supporting different platforms and deterministic. Thus, at the end of this task, a waiting-task can be unblocked.
It has an additional advantage of having full source code This unblocking can be carried out as the two functions i.e.;
availability. MUCOS is considered as a real time kernel and SEM_Q _FlFO and SEM_Q_ PRIORITT.
supports the following features, Passing parameter : Sem ID
1. µC/Building blocks Returning parameter : SemGive ( ) returns STATUs.
2. µc/FL (embedded flash memory loader) Q3. (a) Discuss the real time programming
3. µc/FS (memory file system) concepts of windows CE.
4. µc/GUI (GUI plat form) Answer : April-15, Set-4, Q3(a) M[8]
5. µc/Probe (a tool that monitors in real-time) For answer refer Unit-III, Q4, Topic: Database Record
Properties and its Data types, Q6 and Q7
6. µc/TCP-IP (embedded TCP/IP Stack)
7. µc/CAN (Control Area Network bus) (b) Bring out the difference in OSEK, RTOS
Linux
8. µc/MOD (embedded mod bus)
Answer : April-15, Set-4, Q3(b) M[7]
9. µc/USB (device and host).
OSEK
Types of source files in MUCOS-II
For answer refer Unit-III, Q13, Topic: OSEK/ VDX and Q14.
1. Processor -dependent Source Files
RTOS Linux
(a) OS-CPU.h (header file at master) RT Linux was basically developed to provide hard real-
(b) OS-cfg. h (Kernel building configuration file) time performance in linux. Hence it is defined as the hard real-
2. Processor-Independent Source Files time RTOS microkernal that allow the complete linux operating
(a) µ cos -ii.h (MUCOS header in master) system to be executed as a whole preemptive process.
For remaining answer refer Unit-III, Q15.
(b) µ cos-ii.c (C file)
(b) Illustrate how the synchronization through Q4. (a)
Write the design and coding of an
binary semaphores done in Vx works. automatic chocolate vending machine
using Mucos RTOS.
Answer : April-15, Set-4, Q2(b) M[7]
Answer : April-15, Set-4, Q4(a) M[8]
The RTOS-Vx works basically provides three types of
binary semaphores i.e., binary (flag), mutex and counting. For answer refer April-15, Set-3, Q4(a).

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
S.20 Real Time Operating Systems (April-2015, Set-4) JNTU-Kakinada
(b) Draw and explain the digital camera Q6. (a) Discus about the off-the-shelf operating
hardware and software architecture systems.
Answer : April-15, Set-4, Q4(b) M[7] Answer : April-15, Set-4, Q6(a) M[8]
For answer refer Unit-IV, Q11, Q12. For answer refer Unit-VI, Q1.
Q5. (a) Write about the program development (b) Explain about the target Image creation
modelling of Robots with RTOS. for Window XP embedded.
Answer : April-15, Set-4, Q5(a) M[8] Answer : April-15, Set-4, Q6(b) M[7]
For answer refer Unit-V, Q4. For answer refer Unit-VI, Q3.
(b) Explain the design issues in an embedded Q7. (a) With the help of diagram explain the
system for an adaptive cruise control architecture of a generic Linux system.
system in car. Explain the following,
Answer : April-15, Set-4, Q5(b) M[7] (i) Write
The embedded system for Adaptive Cruise Control (ii) Read
(ACC) in a car is designed to control the cruising of car using (iii) Exec
adaptive control for speed of the car and inter-car distance.
(iv) Fork.
The design issues include,
Answer : April-15, Set-4, Q7(a) M[8]
1. Power source and power dissipation done in the car
Linux Architecture
battery
Linux Operating System, consists of a hardware, Kernel,
2. An inter-car distance of 2m is to be maintained as
Shell and various tools and utilities. All the parts are arranged
resolution.
around the computer hardware. The structure of Linux operating
3. ACC has to be designed to meet the performance and to system is shown below,
set the safe distance, i.e. 75m to 200m.
Applic ation p
4. Process deadlines lies lesser than 1 second to respond rogr
a ms
s L a ng and
when unsafe distance is being observed from the car at Edit o
r
ua g

Pa
USERS ec
front-end.

ck
m

om

ag
ste

SHELL pile
S

es
rs
Sy

CC

5. User interfaces: G of LCD with touch screen display and


e nt

eS

c es ck

alarming with various tones for ACC messages to driver.


gem

ak

pr o nd ba

I/O
ses
M

redi
6. Extendibility: The ACC system has to be extendable for
na l Data base Mana

Te xt proc
re c
tion
und d a

KERNEL
the maintenance of stability of string of multiple cars in
gro groun

Debuggers

a row
on

essing
Hardware
e
For
anipu lati

7. Engineering cost
Pi
8. Manufacturing cost. pe
ra b
le
m
Rela tio

s filt nfigu ent


e

The out-cruise control is also termed as speed control er o


Fil

s C ironm
Env
s e

which is used to control the speed of the car. The driver has to
lit i
Uti

set the speed, then system will take over the control of car.
Com
It is commonly used in aviation and defence purpose for mun
ica tion networks
cruising. Recently it is adopted by automotives. Figure below
shows the units of ACC system. User programs

String wheel Speedometer Clutch pedal Brake pedrl


Figure: Linux Architecture
1. Hardware
Hardware constitute of peripheral devices such as,
Embedded System
(Cruise Control System) (i) Random Access Memory (RAM)
(ii) Hard Disk Drive (HDD)
Control signal
(iii) Central Processing Unit (CPU)
Throttle Vacuum
Position valve control (iv) Input/output devices.
Sensor 2. Kernel
The Kernel, is the central core of Unix Operating System.
Throttle Valvc
It can directly interact with the hardware. The main functions
Figure Units in ACC System of Car performed by the Kernel are,

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
Real Time Operating Systems (April-2015, Set-4) JNTU-Kakinada S.21
(i) It controls computer hardware resources such as memory, (ii) read( )
disc, printers and so on. Data is read from an opened file by calling the read
(ii) Schedules processes, controls and executes various function.
users jobs. Syntax
(iii) Manages data storage and access. #include <unistd.h>
(iv) Controls the access to the computer by several users. ssize_t read(int filedes, void * buff, size_t n bytes);
Surrounding the Kernel, there are the software for The read( ) function reads the number of bytes specified
executing commands, running processes under foreground and by “nbytes” from the file pointed to by the ‘filedes’ into the
background and configuring the hardware etc. buffer ‘buff read( ) starts reading from the file’s current offset.
The data structure of a Kernel, has a fixed size tables. On successful completion, before the function returns, the offset
This makes the Kernel code to be simple. But limits the entries is incremented by the number of bytes actually read. It returns
in the data structure to a number, that was fixed when generating the number of bytes read or 0 if and end-of-file is reached or -1
the system. if an error is occured. There are many cases in which the number
of bytes read are less than the number of bytes requested.
3. Shell They are as follows,
The Shell acts as an interface between the user and the 1. While reading from a file, if the end of file is reached.
Kernel. It is the most important component of the Unix structure, This occurs, if the request to read ‘n’ number of bytes is
since it receives and understands the commands issued by the more than the number of bytes remaining until the end
user. The user interacts with the shell, by issuing the shell of file. For example, if the request is for 100 bytes and
commands. There are two responsibilities of a shell. First, to there are only 40 bytes remaining until the end of file
interpret the commands given by user and get them executed then the read function returns only 40 bytes.
by the Kernel. Second, the programming capability, that allows
2. Reading from a terminal device is normally upto one line
the users to write a shell script consisting of shell commands to
at a time.
perform a specific task.
3. When reading from a network, buffering within the
4. Tools and Utilities
network may cause the number of bytes read to be less
Tools and Utilities, are also commands defined in the than the requested number of bytes.
system directories/bin and /usr/bin. The tools are used to open 4. Some record-oriented devices for example, magnetic tape
files, process them and then return the output. The utilities are return a single record at a time.
used to ease the job of the user, particularly in efficient system
(iii) Exec( )
programming and application development. There are numerous
tools available for processing files such as, wc, pipes; for editing The exec system call, replaces the calling process by the
programs such as ed, vi, ex; for processing text such as grep, new program and this new program starts executing at its main
cut, paste; for developing program such as m4, make, SCCS; for function. There are six different exec functions, which have the
communication such as mail, write, message and so on. The same functionality, but differ in their argument lists. The exec
user itself can create his own tools, which are executable files system call has the following syntax,
defined in his own directory. #include<unistd.h>
(i) write( ) int execl(const char *path, const char *arg, ...,);
Data is written to an opened file by calling the write int execv(const char *path, char *const argv[ ]);
function. int execle(const char *path, const char *arg, ...., char
Syntax *const env[ ]);
#include <unistd.h> int execve(const char *path, char *const argv[ ],char
*const env[ ]);
ssize_t write(int filedes, const void *buff, size_t nbytes);
int execlp(const char *file, const char *arg, ....,);
The write( ) function writes the number of bytes
int execvp(const char *file, char *const argv[ ]);
specified by ‘nbytes’ from the buffer “buff” into the file pointed
to by ‘filedes’. The functions returns the number of bytes written The first argument to exec function is, either the
on successful completion and ‘–1’ on error. pathname or a filename of a program to be executed which is an
executable file (i.e., in a.out format). The first four functions
For a regular file, the write( ) function starts writing at
take a pathname, while the last two functions take a filename, as
the files current offset. If the O_APPEND option was specified
their first argument. If the first argument begins with a slash (“/
at the time of opening a file then the files offset is set to the
”), then it is taken as a pathname otherwise the executable file.
current end of the file before each write operation begins. After
The executable file is searched in the PATH environment
the write operation, the files offset is incremented by the number
variable, to execute a programme. However, the two functions
of bytes actually written.
with suffix p i.e., execlp and execvp can also take a shell script
A write( ) function fails, if the disk is full or the file size and try to invoke a Bourne shell, (/bin/sh) to interpret the shell
limit is exceeding for a given process. script.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
S.22 Real Time Operating Systems (April-2015, Set-4) JNTU-Kakinada
The next argument to exec functions, are the arguments for an exceed program. The functions execl, execlp and execlv
(functions containing ‘l’ character), take a list of arguments (arg) separated by a comma while the functions execv, execvp and
execve (functions containing ‘v’ character), take a vector of character strings(argv). In either of the way, the argument list is
terminated by a null pointer. The null pointer, written an (char *) 0, indicates the end of the argument list.
The exec functions, take at least two arguments i.e., the name of the program to be executed and the null pointer. The
functions execle and execve, take another argument as the environment list, to be passed to the new program. This environment
list is a vector of character strings, (env) where each string is an environment variable which has a name/value pair <env_name>
= <value>.
The env list must end with a null pointer, to indicate the end of a vector list. To copy the existing environment for the new
program, the other functions use the environ variable in the calling process.
If the call to exec function succeeds, then it replaces the original process text, data, heap and stack segments by new
segments for the new program. However, only the file descriptor table of the calling process, remains the same and the new
program starts executing at its main functions. Further, when the new program completes execution, the calling process is
terminated and its exit status is passed to its parent.
A call to an exec system call, returns –1 on error. It fails, if the program to be executed is not accessible or it has no execute
permissions.
(iv) Fork
For answer refer Unit-VII, Q11, Topic: fork( ) Function.
(b) Write about the concepts of shell programming.
Answer : April-15, Set-4, Q7(b) M[7]
For answer refer Unit-VII, Q9, Q10.
Q8. (a) Develop a program to display a message periodically using RT Linux.
Answer : April-15, Set-4, Q8(a) M[8]
For answer refer Unit-VIII, Q6.
(b) Explain the semaphore management done in RT Linux.
Answer : April-15, Set-4, Q8(b) M[7]
For answer refer Unit-VIII, Q7.

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

You might also like