You are on page 1of 14

Real Time Operating Systems (JNTU-Kakinada) (Unit-3) 51

UNIT-3: Real-Time Operating System Programming-II


UNIT-3:
Important Questions

Q1. Explain about windows CE.

Answer :

For answer refer Unit-III, Q1.

Q2. Write short notes on,

(a) Windows and windows management

(b) Memory management

(c) Files and registry.

Answer :

For answer refer Unit-III, Q4.

Q3. Explain the windows CE exceptions, notifications and interprocess communication objects and their
synchronization.

Answer :

For answer refer Unit-III, Q7.

Q4. What are the embedded softwares in automotive system that need special features, standards and
specifications in its operating system?

Answer :

For answer refer Unit-III, Q12.

Q5. Describe linux functions for the signal, multithreading and semaphore and message queue
interprocess communication.

Answer :

For answer refer Unit-III, Q17.

Q6. Describe registering, de-registering, priority and scheduling of real time thread and FIFO-related
functions in RTLinux.

Answer :

For answer refer Unit-III, Q19.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
52 (Unit-3) 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-3) 53

Unit-3 Real-Time Operating System Programming-II


Solutions
5. It makes use of unicode 16 bit characters in order to
3.1 Programming Concepts of RTOS support international characters and different
Windows CE languages.
Q1. Explain about windows CE. 6. It has less number of windows control when compared
to personal systems.
Answer : Model Paper-I, Q3(a)
7. It has a small display screen with touch screen feature.
Windows CE (WCE)
8. It supports win32 API subset only i.e., it doesnot
WCE is a RTOS for handheld computers (laptops) and
provide environment related functions, current
mobile systems. ‘CE’ here stands for the properties it possess directory information and environment blocks.
compact, connectable, compatible, companion and efficient.
Q3. Describe the additional features in windows
Features CE 6.0 and windows CE extensions to pocket
The features of WCE are as follows, PC, windows mobile 6 and windows
automobile 5.0.
1. It provides a windows platform for the systems that
have resource constraints of power, memory, Answer :
processing speeds, touch screen or display screen Windows CE 6.0
size.
 It has 216 processes with low 2GB virtual memory
2. It is a scalable 32-bit Operating System (OS). address per process. It has 2GB upper kernel VM space
3. It supports the running of pocket PC applications i.e., and device driver that runs in user mode as well as
outlook, pocket power-point, pocket word, pocket kernel mode.
excel, explorer etc.  It has system components that run in kernel. These
4. It also supports multi tasking and multi threading components are converted to Dynamic Link Libraries
properties of OS. (DLLS) for Executables (EXEs). These components are
loaded into kernel support at run time.
5. The processor used in the WCE can be a 80X86 or
superH or ARM or SH4 or MIPS.  It has enhanced infrastructure with 802.11; and 802.11e
wireless LAN supports.
6. WCE provides internet services and supports windows
API (Application Programming Interface).  It supports UDF 2.5 and exFAT file system.

7. The Kernel of WCE is about 400 kB wide. It can support  It supports IDE integrated with Visual Studio 5.0 which
upto 256 priority levels for each process and has the is used in consumer electronics devices and industrial
controllers.
features of carrying out preemptive priority scheduling.
 It offers easy data connections for new cell core for
Q2. What are the features that differentiate WCE
cellular networks.
from windows?
Windows Mobile, 6 Second Edition
Answer :
 It supports office mobile 2007.
The features that differentiate WCE from windows are
as follows,  It has enhanced bluetooth stack.
1. It does not have a hard disk, instead it makes use of  It supports data encryption for the data stored in
low capacity RAM, ROM and flash memory. external removable storage cards.
2. It supports three different system processors such as  It has smart phone with touch screen.
x86, SuperH and ARM.  It supports smart filter to filter contacts, songs and
3. It imports device drivers such as DLL’S. files.
4. It does not support some security attributes and handle  It can also be used as modem for laptops and note
inheritance. books.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
54 (Unit-3) Real Time Operating Systems (JNTU-Kakinada)
Windows Automotive 5.0 1. Program Memory
 It is based on windows CE 5.0 and building blocks to The programs are alloted a memory space from the
be used in automobile board service. heap. Heap can be defined as a memory space which is kept
unused therefore, all the applications programs running make
 It has virtual memory which enables complex 3-D use of the heap and stacks. Each application is provided a
graphics to be created. block of memory from the heap. The reserved block of heap
 It offers Automotive User Interface Tool Kit (AUITK). can be freed when not in use or required. The memory size of
heap depends on the requirement of the system. A local heap
 It provides increased power management and cold- is usually of size 188 kB.
bold times.
2. Object Store
 It suggests users to cheapest gas stations. It is a 256 MB virtual RAM for storing data permanently.
 It offers navigation display and real-time traffic It doesnot get turned off even if the system gets shutdown.
updates. Each file is assigned 32 MB of memory if RAM acts as an
object store. It also stores PIM (Personal Information
Q4. Write short notes on, Manager) data such as contacts, calendar and task to do in
(a) Windows and windows management the object store. Each contact consists of name, phone number,
(b) Memory management email ID, home number, office number and personal mobile
number. Object store is provided power by the backup battery
(c) Files and registry.
of a handled pocket PC.
Answer : Model Paper-II, Q3(a)
WCE executes its files in execute-in-place file thus
(a) Windows and Windows Management saving the ROM memory but this file cannot be read and
A display screen usually called a desktop consists of opened using the standard file functions read( ) and open( ).
many windows within it. Some of the relationships which can It supports page memory management technique and virtual
be defined in between the windows are parent-child, owner- memory management. Virtual memory mapping technique maps
owned, sibling relationship. Command-tool-task bar and the virtual address of pages using the physical addresses of
button are the windows present on the screen. Main window the page. In WCE, a page size varies depending on the type of
is at the top level which can have as many children it wants system processor used. There are three types of virtual pages
but it does not have any parent whenever a parent window is used by WCE. They are,
either moved or removed then all the child windows present  Committed Page
at the next levels or also moved or removed. The child window
is usually hidden and can be seen only at the edges of the It directly maps to the RAM address and
window. CreateWindow or createwindowEx is used for creating reserves the page for the use of applications.
a window. Whenever a style parameter of 32 bit is set as  Reserve Page
WS_Child then a child window is created. bMenu parameter It cannot be utilized for applications as it is
of 8 bit style parameter is used as an ID of the window. Some mapped with a virtual address.
of the windows management functions used for managing
the windows are as follows,  Free Page
1. FindWindow It can be used anytime and is usually alloted
during the execution of an application.
It is used for searching a window and for getting a
handle. (c) Files and Registry
2. GetParent Files are generated through a CreateFile function
It is used to find the parent. which takes the following parameters,
3. GetWindow (i) 32-bit shared mode specification
It is used for querying about siblings, children and (ii) 32-bit desired access argument.
owner. (iii) Long pointer for character string.
(b) Memory Management (iv) Long pointer for security attributes.
Memory management is an important issue in any of (v) 32-bit to mention creation and distribution.
the real time operating system. Managing memory in windows
CE 6.0 can be done as follows. It supports a virtual memory of (vi) 32-bit to mention flag and its features.
2GB which can be used in 3D graphics. It also supports 1MB (vii) Handle for template file.
and 64 MB of system memory in which 512 kB and 4 kB ram The parameters are assigned in the following way,
memory is accumulated by operating system. It also manages
the low memory conditions. WCE divides the RAM into two (i) Character string for file name.
parts one part is called program memory and the other part is (ii) WCE creates file to set 32-bit shared mode specification
called object store. as FILE_SHARE_WRITE, FILE_SHARE_READ or 0.

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-3) 55
(iii) WCE file accesses argument GENERIC_WRITE, There is no concept of nested records i.e., a record
GENERIC_READ or both. does not contain another record in it. Further, every record
has four-level indices to sort data.
(iv) WCE create file must use long pointer as NULL to
specify secured attributes. 2. Database Record Properties and its Data Types
(v) 32-bit specifies WCE flags and its attributes such as, Windows CE database supports the following data
types,
(a) FILE_FLAG_WRITE_THROUGH.
(a) Double 64-bit signed boolean
(b) FILE_FLAG_RANDOM_ACCESS
(b) Collection of bytes
(c) FILE_ATTRIBUTE_READONLY (c) 16-bit signed
(d) FILE_ATTRIBUTE_ARCHIVE (d) 16-bit unsigned
(e) FILE_FLAG_RANDOM_ACCESS (e) 0-temined unicode string
(f) FILE_ATTRIBUTE_NORMAL (f) Time
(g) FILE_ATTRIBUTE_HIDDEN (g) Date structure
(h) FILE_ATTRIBUTE_SYSTEM (h) 32-bit signed

(vi) WCE files are created and distributed through 32 bits (i) 32-bit unsigned.
3. Record Number and Size
CREATE_NEW, CREATE_ALWAYS, OPEN_ALWAYS,
OPEN_EXISTING or TRUNCATE_EXISTING. It supports 216-1 and 217 record size.
(vii) WCE do not support file template therefore handle for 4. CeMountDBVol Windows CE Function
template file is NULL. This function mounts an external media or flash on a
Similarities Between WCE Files and other Windows database volume to store database files.
Operating Systems 5. CeUnmountDBVol Windows CE Function
1. WCE uses many Win32 file APIs. This function unmounts a mounted external media or
flash.
2. WCE also uses the attribute flags as used in other
windows operating systems. 6. CeCreateDatabaseEX Windows CE Function
3. WCE also uses standard Input/output procedures It creates a new database.
such as_createFile, ReadFile, OpenFile. 7. CeOpenDatabaseEx Windows CE Function
Differences Between Windows CE and other Windows It opens created database.
Operating Systems
8. CeReadrecordPropsEx Windows CE Function
1. Windows CE uses compact flash and RAM with a It reads a record of given attribute.
battery to backup in case of battery failure.
9. CeWriteRecordProps Function
2. Windows CE uses upto 256 storage devices.
It writes new property of record
3. Windows does not uses current directory concept.
10. CeSeekDatabaseEx Windows CE Function
4. It uses object store as a default RAM-based file
It sets a pointer to database record.
system.
11. CeSetDatabaseInfoEx Windows CE Function
5. Files are read as byte streams.
It sets the sort order for the opened database.
Q5. Explain in detail about windows CE functions
in WCE databases. 12. CloseHandle( )
Answer : It closes the handle.

Different windows CE functions performed in WCE 13. Windows CE Notification


database are, It notifications a process that a thread has performed
changes in the database.
1. Database Format
14. CeDeleteDatabaseEx Function
These are the records that cannot be locked however,
data and its properties are in safe records. It deletes records, properties and whole database.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
56 (Unit-3) Real Time Operating Systems (JNTU-Kakinada)
Q6. Describe the properties and windows CE 11. GetThread-Priority
functions for threads and processes.
It acquires thread priority level.
Answer :
12. CeGetThread-Priority
Threads and processes has the following properties
It acquires thread priority level between 0 and 255 using
and functions,
Handle arguments.
1. Thread Attributes
13. CeSetThread-Quantum
Threads that belong to the same process share memory
and handle access permissions. A primary thread is It sets thread time slice value using two arguments,
capable of generating secondary threads. The threads 32-bit time slice and handle.
use handlers to synchronize files and memory objects. 14. CeGetThread-Quantum
2. Thread Priorities It acquires thread time slice using Handle parameter.
Every thread is assigned one priority level from eight 15. SuspendThread
levels. The total number of priority levels is 256 and
wherein 255 is the lowest and 0 is the highest priority It suspends a thread using handle argument.
level. System-level threads and device drivers use 16. ResumeThread
upper 248 priority levels.
It resumes a suspended thread using handle thread.
Further, higher priority threads are executed first and
then lower level threads. 17. Sleep
3. Processes Number and Memory Size It is used to delay the execution of threads for a time
16 period. Its argument is 32-bit time slice in milliseconds.
Windows CE 6.0 supports upto 2 processes wherein
each process has 2GB virtual memory.
4. CreateProcess WCE Function Q7. Explain the windows CE exceptions,
notifications and interprocess communication
It creates a new process with four arguments.
objects and their synchronization.
5. TerminateProcess Windows CE Function
Answer : Model Paper-I, Q3(b)
It terminates an existing process.
Windows CE handles exceptions through signals and
It uses two arguments,
notifications such as power up, system event and serial device
(i) Handle for process detect. It manages interprocess communication objects such
(ii) 32-bit exit code for process. as semaphores and message queues through handles. In a
6. CreateThread WCE Function multi tasking or multithreading system an IPC object generates
a synchronization object. This object offers information about
It creates new process using the following arguments, computation of one process and allows other processes
(i) 32-bit StackSize waiting for the object to obtain information and further
(ii) Long pointer for application specified thread processing. These objects are created, released and made to
parameter. wait by kernels. Windows CE performs the following functions
(iii) Long pointer for THREAD_START_ROUTINE for exceptions, mutex, events, semaphores and message-
queues.
(iv) 32-bit ThreadId
1. Signalling Exception Functions
(v) 32-bit CreationFlags.
It raises exceptions using 32-bit code number of
7. OpenProcess Windows CE Function
arguments, exception flags and 32-bit constant of array for
It opens a process using ProcessId. arguments. All of these arguments passes data to routines
8. ExitThread Windows CE Function that handles exception.
It terminates a thread using a 32-bit exit code. 2. Signalling Notification Functions
9. CeSetThreat-Priority It manages notifications such as,
It sets thread priority value between 0 and 255. It uses (i) CeGetUserNotificationEx through handle for long
two arguments priority value and handle pointer and notification.
10. SetThread - Priority (ii) CeClearUserNotificationEx using handle to
It sets thread priority among eight levels. It also uses acknowledge a notification through responding
two arguments a priority value and handle. function.

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-3) 57
(iii) CeSetUserNotificationEx using handle for CE_NOTI- 8. Wait for Multiple Objects
FICATION_TRIGGER object, CE_USER_NOTI- WaitForMultipleObjects through count number for
FICATION object and for notification. objects such as events or mutexes, 32-bit waiting time,
3. Semaphore Functions boolean WaitAll and pointer to handle objects.
Four functions are performed through semaphores. 9. Wait Single Object Functions
(i) CreateSemaphore is used to create a semaphore. WaitForSingleObject through object handle and 32-
bit waiting time value.
(ii) ReleaseSemaphore is used to unblock the waiting
thread code. Q8. How do the inputs from keys, touch screen or
mouse handled in windows CE?
(iii) CreateMutex is used to create mutex.
Answer :
(iv) ReleaseMutex is used to unblock the waiting thread
A keyboard is used to enter commands, characters
code.
and text. Handheld devices cannot use physical device
4. Critical Section Functions conveniently therefore, a soft keyboard is used. This soft
keyboard controls and simulates virtual keyboard or touch
Functions performed in critical section are,
screen. However, an application is capable of receiving input
(i) InitializeCriticalSection to initialize a critical section. of physical as well as soft keyboard. SetFocus function
specifies the focus window to direct input to windows and
(ii) TryEnterCriticalSection is used to try to enter a critical
then send messages to it. Further, every action or key has a
section.
value associated to it for instance, VK_LBUTTON passes a
(iii) EnterCriticalSection is used to enter a critical section. 01 value on a stylus tap.
(iv) LeaveCriticalSection is used to exit from a critical Touch screen input is similar to a single button mice
section. input. When a mice is pressed, WM_LBUTTONDOWN
message is sent on the left button down and
(v) DeleteCriticalSection is used to delete a critical section. WM_LBUTTONUP on left button up event. When the stylus
5. Event Functions is moved within the same window, the WM_MOUSEMOVE
message is sent. Similarly when the stylus is dragged outside
Event functions performed for a process thread of the focus window, the WM_MOUSEMOVE message stops.
includes,
When SetCapture process is called, WM_MOUSEMOVE
(i) CreateEvent is used to create an event. message continues. When ReleaseCapture procedure is called
(ii) SetEvent is used to set the occurrence of an event. the WM_MOUSEMOVE signal message is stopped.
(iii) ResetEvent is used to reset an event forcibly. When stylus traces a point on the screen, GetMouse-
MovePoints sends message. The GetMouseMovePoints
(iv) GetEventData is used to acquire the event data. works well with handwriting recognizes application and it is
used to write messages, texts and commands on pocket pc.
(v) SetEventData is used to set event data through the
event handle and 32-bit data arguments. When the ALT key of stylus is held down while
tapping, the right button click of the mice is simulated.
(vi) PulseEvent sets the event and then resets it by
unblocking all threads waiting for that event to occur. Further, the double tap of the stylus raises the message
WM_LBUTTONDBLCLK.
6. Message Queue Functions
Q9. Explain the following,
(i) CreateMsgQueue is used to create a message queue.
(a) Windows CE serial communication
(ii) OpenMsgQueue is used to open a message queue. functions
(iii) WriteMsgQueue is used to write into a queue. (b) WNet API network connection functions.
(iv) ReadMsgQueue is used to read from a queue. Answer :
(v) CloseMsgQueue is used to close an open message (a) Windows CE Serial Communication Functions
queue. Windows CE uses the following serial communication
7. Wait for Message Objects functions,
MsgWaitForMultipleObjectsEx through count number 1. CreateFile WCE Function
for message objects, boolean WaitAll, 32-bit waiting It creates a port for communication. The arguments
time value, and 32-bit flags and long pointer for handles used are GENERIC_READ, GENERIC_WRITE, TEXT, 0, NULL
objects. and OPEN_EXISTING.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
58 (Unit-3) Real Time Operating Systems (JNTU-Kakinada)
2. ReadFile/WriteFile 2. WNetCancel-Connection
These functions read from the port and returns an It disconnects the remote network connection. It uses
integer. They are arguments such as, the following arguments.
(i) Pointer to character
(i) One long pointer for name
(ii) Pointer to 8-bit number of bytes read.
(ii) Boolean to identify forced disconnection. This
(iii) NULL
usually happens when devices are opened but
(iv) Handle returned on creation. not closed.
3. Set CommMask
(iii) 32-bit value for flags.
It sets communication mask using the arguments.
It also returns a 32-bit code irrespective of whether an
(i) Handle returned on creation
error occurs or not.
(ii) 32-bit for event mask to identify break, error,
transmit buffer empty, character received and flag 3. WNetConnection - Dialog
received. It is used to dialog. It uses a long pointer for connection
4. Get CommMask dialog structure.
It is used to acquire communication mask. Two 4. WNetDis - ConnectDialog
arguments are used for communication are,
(i) Handle returned on creation It dialogs on disconnection. It uses two arguments
(ii) A long pointer for 32-bit event mask. (i) Window handle
5. WaitCommEvent (ii) 32 bits for resource type which can be a disk or
It is used to wait for an event to occur using the printer.
arguments.
5. SetCommState
(i) Handle for file
It sets communication state. It uses two arguments,
(ii) NULL
(iii) Long pointer for 32-bit event mask (i) Handle for file
6. SetCommState (ii) Long pointer to device control block structure.
It is used to set communication state. Its argument are, 6. WNetGet-Connection
(i) Handle for file
It requires the network remote resource connection
(ii) Long pointer to device control block structures. and returns a 32-bit code irrespective of whether an
7. TransmitCommChar error occurs or not. Its arguments are,
It transfers characters into queue for port transmission. (i) Long pointers for name and user name
The two arguments are,
(ii) Long pointer for 32-bit value.
(i) Handle returned on creation
(ii) Character for transmission. 7. WNetGet UniversalName
It returns a boolean when a transmission succeeds or It requires the name according to universal naming
fail. conventions and uses the following arguments.
(b) WNet API Network Connection Functions
(i) 32-bit info-level
The different WNet API Network connection functions
are, (ii) 32-bit buffer size
1. WNetAdd-Connection (iii) Long pointers for buffer address
It maps the network resource. (iv) Long pointer for string.
It uses the following argument,
8. WNetGetUser
(i) One window handle
(ii) One 32-bit value for flags It requires the user name using the following
arguments.
(iii) Astring for user names and password
(iv) Three long pointers for network resource. (i) Long pointer for 32-bit to specify remote buffer’s
length.
It returns a 32-bit code when an error occurs or does
not occur. (ii) Long pointers for string.

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-3) 59
Q10. List winsock API subset in windows CE for 7. Send Function
device to device socket communication It is used to send data from a socket. It uses the
functions. How communication functions for following arguments,
socket differ from the serial port communica-
tion? (i) SOCKET
(ii) Integer for flag
Answer :
(iii) Integer for length
The Winsock API subset in window CE for device-to-
device socket communication functions are as follows, (iv) Constant char for addressed buffer information.
8. Shutdown
1. Socket Function
It shuts down to send and receive functions by using
It creates new socket. It uses three arguments, two arguments,
(i) Addressed family specification (i) SOCKET
(ii) Addressed socket type specification (ii) Integer.
(iii) Protocol. 9. Close Socket
2. Accept Function It closes socket connection using the argument socket.
Q11. How win32 API programming is used for the
It accepts client connection at the server in listen mode.
development of windows for the GUIs in an
It uses three parametes.
application?
(i) SOCKET
Answer :
(ii) Structure for addressed buffer information
Windows development for GUI is one of the significant
(iii) Integer for buffer length. part of the application development in a handled or embedded
3. Bind Function system.
GUI enables input from users and allows interaction
It finds the desired server using three arguments.
through dialog boxes, buttons, check boxes and labels. Win32
(i) SOCKET API programming has huge volume of APIs in a personal
(ii) Constant structure for addressed socket computer. However, only few APIs are needed for small screen
information sized systems. Once an application is ready, a window displays
message in the center of the screen, title, tool, status bar and
(iii) Integer. command. The window further displays stylus tap or mice
4. Connect Function through display buttons to send the commands through
buttons and menus. The window also show help? icon and
It connects a new by created client socket with server. buttons such as maximize window button, minimize window
It uses three arguments, button and close window button at the top right corner of the
(i) Connecting SOCKET window.
(ii) Integer Windows CE use single-line controls for status bar,
tool and command. It has,
(iii) Constant structure for addressed socket
(i) New controls such as data, time and calender
information.
(ii) Organizer i.e., (task-to-do)
5. Listen Function
(iii) New format for windows controls such as
It connects with server after binding for data toolbars and menu.
transmission. It uses two arguments,
(i) Integer 3.2 RTOS OSEK
(ii) SOCKET. Q12. What are the embedded softwares in
6. Recv Function automotive system that need special features,
standards and specifications in its operating
It receives data from a socket using four arguments,
system?
(i) SOCKET
Answer : Model Paper-II, Q3(b)
(ii) Integer for flags
The embedded software of the automotive system
(iii) Integer for length needs the following special characteristics, standards and
(iv) Constant char for addressed buffer information. specifications.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
60 (Unit-3) Real Time Operating Systems (JNTU-Kakinada)
1. Each method, run-time library and class must be scal- Corresponding Interfaces for Automotive Electronics (OSEK)
able to optimize the memory requirements. is a German automotive consortium. It was founded in the
2. Data types should be application specific, they should year 1993. Later, the French car producers joined the consortium
with their Vehicle Distributed executive (VDX) initiative.
be binded for RTOS. Further, language should be ap-
plication-specific, it should not be restricted to C or Standards
Java. OSEK/VDX defines and specifies three standards for
3. Operating system should schedule tasks in unique embedded operating system.
way. 1. Real time execution of Electronic Control Units (ECUs).
4. Tasks should be categorized into four types. This cat- 2. Network management protocols for automotive em-
egorization enables programmers to use special class bedded system.
type for every module.
3. Communication stack to exchange data between con-
(i) Basic with single task of single activation and trol units.
priority. This class is called basic conformance
This consortium was developed to reduce the recur-
class1.
ring expenses in application development and incompatibili-
(ii) Basic with multiple tasks of multiple time activa- ties of control units produced by different manufacturers. The
tion and single priority. It is called basic con- reduction is made possible by,
formance class2.
(a) Specifying an user interface independent of hardware
(iii) Extended with one task of single priority and ac-
and network.
tivation. It is called extended conformance class1.
(b) Verification of prototypes in selected project.
(iv) Extended with multiple task of multiple times ac-
tivation during run time and single priority. It is (c) Efficient architectural design.
called extended conformance class2. (d) Making interface application-independent.
5. Tasks can be scheduled in real time for automotive Advantages
systems.
1. It enhances quality of software.
6. Interrupt system is disabled at the starting of service
2. It reduces production cost.
routine and it enabled on return. This mechanism en-
ables tasks to run in real time environment. 3. It improves performance.
7. Semaphore objects, tasks or timers should not be al- 4. It enhances standards interface.
lowed to be created or deleted. A bug at run time may Q14. List all the basic features of OSEK. How does
call delete( ) for semaphore and lead to incorrect out- it provide for functional extendibility and
put. portability?
8. Task consists three types of objects, Answer :
(i) Devices such as alarm Features of OSEK
(ii) Resources such as functions
OSEK has the following features,
(iii) Events such as semaphore.
1. It has four categories of classes,
9. All interrupts must be disabled before entering into
the critical section and while executing a service rou- (a) Basic conformance class1
tine. These can be enabled only while returning. (b) Basic conformance class2
10. Interprocess communication and message queue post- (c) Extended conformance class1
ing should not be allowed. This is to restrict a waiting
task to avoid waiting indefinitely for receiving full (d) Extended conformance class2.
message. 2. It does not allow message queues.
Q13. What is OSEK/VDX? What are the three 3. Semaphores are used as flags in OSEK.
standards specified for an embedded OS by
4. It does not allow creation and killing of tasks during
OSEK/VDX?
run time.
Answer : 5. User interfaces are specified independent of network
OSEK/VDX and hardware.
Offene system and deren Schnittstellen fur die 6. Its architecture allows easy integration and configura-
Elektronik in Kraftfahrzeugen (Open Systems and the tion of new applications.

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-3) 61
7. Abstract interfaces are specified as application inde- 7. A process that uses fork( ) creates a child process.
pendent as possible. This child creates a copy of parent process.
8. Control units have standard interface with different 8. It supports signals when an event occurs. Further it
architectural designs. supports mutex, semaphores and multithreading.
9. Prototypes are implemented and verified in selected 9. It handles errors and prevents unauthorized port ac-
projects. cesses and root-level access.
10. It efficiently utilizes resources and improves overall
10. Linux 2.6.24 offers high resolution timers and tick-less
performance.
timers.
11. OSEK offers easy integration of application functions
into it with other APIs. 11. In linux. 2.6.x every task is assigned static priorities
between –19 to +20.
It also allows transfer of application from one hard-
ware ECU to another. It also emphasize that portability and 12. Linux 2.6.24 restricts block devices from consuming
extendability must not be dependent on API sources. It en- cpu resources and enhances overall performance.
sures different sources of software to coexist together. Fur- 13. Linux header file Linux/time.h supports timing func-
ther, it does not enforce any implementation module as vari- tions in scheduling.
ous ECUs can have their own implementation inspite of hav-
ing same interface. 14. Real-time Linux 2.6.24 offers support for group-sched-
uling functions.
The implementation is dependent on the architecture
of the software and the type of functions needed. Q16. Describe the functions for registering and de-
registering related functions of linux modules.
Standards
Answer :
OSEK defines three standards.
The following are registering and de-registering func-
1. OSEK-OS for operating system.
tions of linux modules,
2. OSEK-NM for network architecture.
1. init( )
3. OSEK-COM for communication between cpu tasks.
In the kernel, init_module( ) is called prior initializing
the module. The initializing function returns a negative value
3.3 RTOS Linux 2.6.x and RTOS if the initialization fails and 0 value when initialization suc-
RTLinux ceeds. It also replaces one kernel function by overloading
Q15. List the features of real time linux. and registers a handler with the kernel.
Answer : 2. register_capability

Linux has the following useful features, It schedules a function which is executed later.
3. unregister_capability
1. It is a multiuser operating system.
It ignores a module.
2. It has huge number of files, directories, editors and
input/output commands. 4. register_symtab
3. Its root directory is represented as /sign and a direc- It offers symbol table function which can replace a
tory can contain several subdirectories. function that declares functions and variables static.

4. It has several user interfaces. 5. insmod( )


It inserts a module into the kernel.
5. It uses POSIX processes and threads POSIX maps are
used in shared memory functions. 6. rmmod( )
6. It supports 4095 device types wherein each device It deletes a module file from kernel.
can have 230 device addresses. 7. cleanup( )
A character device such as mice, sends and receives It is invoked when an rmmod function is called for
sequential byte stream. An input device accepts from execution. It nullifies the actions performed by the
a device such as keyboard. A net device handles net- init_module() and safely unloads the module. Further, it is
work interface device through line protocols. called just prior cleaning the module.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
62 (Unit-3) Real Time Operating Systems (JNTU-Kakinada)
Q17. Describe linux functions for the signal, multi (b) pthread_mutex_init( );
threading and semaphore and message It initiates a mutex and returns an integer createdstate.
queue interprocess communication.
(c) pthread_mutex_destroy( );
Answer :
It destroys mutex.
Different linux functions for signal, multithreading,
semaphore and message queue interprocess communication (d) pthread_mutex_lock( );
are as follows, It locks a pthread mutex.
1. Thread Functions (e) pthread_mutex_unlock( );
(a) C statements define three POSIX threads. It unlocks a locked pthread mutex.
1. struct pthread_t clientThd_1 5. Semaphore Functions
2. ClientThd_2 and ServingThd. (a) struct sem_t sem1, sem2;
(b) pthread_create(&ClientThd_1, NULL, 0, thread_1, (b) sem_post(&sem1);
NULL). It post the sem1 semaphore.
It creates thread with structures clientThd_1 and call- (c) sem_wait(&sem1);
ing function thread_1. It waits for sem1 semaphore.
It returns an integer createdstate. (d) sem_init( );
(c) pthread_self( ); It initiates a semaphore and returns an integer.
It returns ID of the pthread_self calling thread. (e) sem_destroy(&sem1);
(d) pthread_kill( ); It destroys sem1 semaphore.
It sends ‘kill’ message to the thread. 6. Time Functions
(e) pthread_join(&clientThd_1, &threadNew) (a) nanosleep(sleeptime);
It joins thread with threadNew and clientThd_1 struc- It makes thread to sleep for the specified time period
ture. i.e., in nanoseconds.
It returns an createdstate integer. (b) clock_gettime( );
(f) sleep(Sleeptime) It returns the clock time.
The thread sleeps for the number of nanoseconds (c) clock_settime( );
specified.
It sets time of the clock.
(g) pthread_exit (''text'') (d) clock_getthrtime( );
It exits the execution thread and displays message. It returns high resolution time specified in nanosec-
2. Signal Functions onds in a clock.
(a) signal_1.sa_flags = 0; (e) getthrtime( );
It sets flag = 0. It returns high resolution time in a thread.
(b) struct sigaction signal_1; 7. Message Queue Functions
It is a C statement structure. (a) pthread_mq_open( ),
(c) sigaction (SIGINIT, &signal_1, 0); It initialises a pthread.
It initiates signal function handlingfunction_1( ). (b) mq_close( )
(d) signal_1.sa_handler = handlingfunction_1; It closes a queue.
It defines signal handler as a user defined function. (c) mq_unlink( )
(e) sigemptyset (&signal_1.sa_mask); It removes a named queue and it restricts other tasks
It defines signal as empty. from using the queue.
3. Thread Features (d) pthread_mq_setattr( )
Threads that belong to same process manage access It sets the attributes.
permissions and share memory space. (e) pthread_mq_lock( )
4. Mutex Functions It locks a mq queue.
(a) struct.pthread_mutex_t ms1, ms2, C statement that (f) pthread_mq_unlock( )
defines semaphore structure, ms1 and ms2. It unlocks a mq queue.

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-3) 63
(g) pthread_mq_getattr( ) 6. Deterministic interrupt latency ISRs are executed as
It receives the features of POSIX queue. real time linux core interrupts and non-deterministic
(h) pthread_mq_notify( ) processes are transferred to linux.
It notifies a single waiting task that the message has Real time linux possess the following characteristics
arrived. that are useful for real time embedded systems,
(i) pthread_mq_send( ) 1. Real time tasks directly access the hardware as they
run in privileged mode. They are written as exclusive
It is used to send message to a queue.
linux modules to enable dynamic loading into memory.
It uses four arguments msgid, &qsendingdata, sizeof Further, they do not use virtual memory.
and 0.
2. The core of RTLinux has small footprint core which is
(j) pthread_mq_receive( ) like a virtual machine layer. It offers kernel as preempt-
It is used to receive message from a queue. It uses five ing and non-preempting kernel.
arguments msgid, &qreceivedata void*, 0 and sizeof. 3. It has deterministic worst-case latency for various pro-
8. Shared Memory Functions cesses.
These are used instead of IPC functions. 4. Linux or Unix has lowest priority threads.
(a) include <shm.h> 5. Its real time threads also meet worst-case limited dead-
(b) include <common.h> lines.
It includes common memory file header. 6. Cpu also can be allocated to specific threads.
(c) struct common_struct sharedblck; Q19. Describe registering, de-registering, priority
It specifies a new structure. and scheduling of real time thread and FIFO-
related functions in RTLinux.
(d) int shmemdetect_status = shmdt( )
Answer :
It uses pointer to shared memory block sharedMem1
argument. It returns–1 if the pointer is not detected. 1. RT Linux Functions
(e) int shmId = shmget( ), sizeof( ); (a) rtl_hard_enable_irq( );
key_t, num( = 2377), common structure size and use of It allows hard real time interrupts.
IPC. (b) rtl_getchedclock( );
(f) int shmem_status = shmctl( ); It receivers current clock schedule.
Its arguments are ID of shared memory block, option 0
(c) rtl_no_interrutps( );
and IPC_RMID. It returns the status of shared memory.
It does not allow cpu interrupts.
(g) sharedMem1 = shmat( );
It points to memory block and uses the parameter null (d) rtl_request_irq( );
pointer function, option 0 and ID of shared memory It installs real time interrupt handler.
block. (e) rtl_printf( );
Q18. How does RTlinux add a new core for real It prints text from real time thread.
time tasks? How does hard real-time executes
in RT Linux? How does shared memory help (f) rtlinux_sigaction( );
as a fast alternative to the use of IPC? It handles signals.
Answer : (g) rtl_restore_interrupts( );
Real time linux has the following basic features, It restores cpu interrupts state.
1. Real time tasks run when interrupts are disabled with (h) rtl_hard_disable_irq( );
no address space protection. It disables hard real time interrupt.
2. Virtual memory is not allowed for real time threads only (i) rtl_stop_interrupts( );
primitive tasks are allowed. It stops cpu interrupts.
3. Shared memory synchronizes hard real time tasks and 2. Thread Wait
follows FIFO order.
pthread_wait_np( );
4. It runs a fixed priority schedules.
It makes one thread to wait for another thread to com-
5. Non real time processes run as linux processes. plete its processing.

WARNING : Xerox/Photocopying of this book is a CRIMINAL act. Anyone found guilty is LIABLE to face LEGAL proceedings.
64 (Unit-3) Real Time Operating Systems (JNTU-Kakinada)
3. Running RT thread period definition (l) rtf_notify( );
pthread_make_periodic_np( ); It sends single waiting task that the message is avail-
It defines periodicity of thread with a thread self using able.
three arguments, (m) rtf_allow_interrupts( );
(i) reference to self thread It controls real time interrupt handler.
(ii) gethrtime( ) (n) rtf_put( )
(iii) define period of thread. It sends FIFO buffer.
4. RT thread deletion 8. Real-time Thread Functions
pthread_delete_np( ); (a) pthread_attr_setcpu_np
It deletes a thread. It sets cpu pthread features.
5. Put into the FIFO from thread (b) pthread_attr_getcpu_np
thrd1_put( ); It gets cpu thread features.
Its arguments are address of queue buffer, an option- (c) pthread_setfp_np( );
1 and FIFO descriptor ID. It allows floating point arithmetic.
6. Thread Priority (d) pthread_delete_np( );
(a) struct sched_param thrd1, thrd2; It deletes a thread.
It specifies two structures for two threads thrd1 and (e) pthread_wait_np( );
thrd2.
It waits for a thread to start.
(b) thrd1.sched_priority = 1;
(f) pthread_wakeup_np( );
It defines thrd1 scheduled priority.
It wakes up a thread.
(c) pthread_setschedparam( );
(g) pthread_attr_setfp_np( );
7. Real Time FIFO Functions
It sets cpu pthreading floating points.
(a) rtf_setattr( );
(h) pthread_suspend_np( );
It sets the attributes.
It suspends a thread.
(b) rtf_create( );
9. Thread Creation
It creates FIFO device.
pthread_create( )
(c) rtf_open( );
It creates thread with structure clientThd_1 and call-
It opens FIFO device.
ing function thread_1.
(d) rtf_create_rt_handler( );
It returns an integer createdstate.
It creates real time handler.
10. pthread_self( )
(e) rtf_close( );
It returns ID of the pthread_self calling thread.
It closes FIFO device.
11. Mutex Functions
(f) rtf_unlink( );
For answer refer Unit-III, Q17, Topic: Mutex Functions.
It removes a named RT FIFO.
12. Semaphore Functions
(g) rft_lock( ) and rtf_unlock( );
For answer refer Unit-III, Q17, Topic: Semaphore Func-
They lock and unlock a queue. tions.
(h) rtf_free_irq( ); 13. init( )
It frees real time interrupt handler. For answer refer Unit-III, Q16, Topic: init( )
(i) rtf_flush( ); 14. insmod( )
It flushes out data of a RT FIFO. For answer refer Unit-III, Q16, Topic: insmod( )
(j) rtf_getattr( ); 15. rmmod( )
It retrieves attributes of a RT FIFO. For answer refer Unit-III, Q16, Topic: rmmod( )
(k) rtf_get( ); 16. cleanup( )
It receives queue buffer. For answer refer Unit-III, Q16, Topic: cleanup( )

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

You might also like