SlideShare a Scribd company logo
Real Time Operating System For Embedded Systems
Rajan Singh
M.E EXTC Sem1(2015-2017)
kumar.rajan1812@gmail.com
Abstract— An embedded system is a special-purpose computer
system designed to perform one or a few dedicated functions,
often with real-time computing constraints. Embedded systems
contain a processor, software and Memory and The processor
may be 8051 micro-controller or a Pentium-IV processor,
Memory ROM and RAM respectively Memory Input Processor
Output.
Index Terms— freeRTOS, ARM LPC2148X, Task, Scheduling,
Semaphore, mutex .
INTRODUCTION (RTOS)
An RTOS is an OS for response time-controlled and event-
controlled processes. It is very essential for large scale
embedded systems. RTOS occupy little space from 10 KB to
100KB The main task of a RTOS is to manage the resources
of the computer such that a particular operation executes in
precisely the same amount of time every time it occur.
When RTOS is not necessary?
For small-scaled systems, RTOS’s function can be replaced by C.
For example, instead of the memory allocation and de-allocation
functions of RTOS, the C function , 'melloc' and 'free' can be used.
Software can directly handle inter-process communication.
3. When RTOS is necessary?
However, RTOS is essential when… A common and effective way
of handling of the hardware source calls from the interrupts I/O
management with devices, files, mailboxes becomes simple using an
RTOS Effectively scheduling and running and blocking of the tasks
in cases of many tasks and many more….. In conclusion, an RTOS
may not be necessary in a small-scaled embedded system. An RTOS
is necessary when scheduling of multiple processes and devices is
important.
THEORY
Hard Real time system: Failure to meet such a dead line is
considered to be a fatal fault and will lead to disastrous consequences
e.g. Response of the break system of a speeding Train approaching a
Red Signal to the stop command must come before the train crosses
the Red signal.
Soft Real time system : Failure to miss a Soft Deadline is
undesirable but a few misses does no serious harm like occasional
delay in an on line trading of stocks. However the system’s overall
performance becomes poorer and poorer as more and more jobs starts
missing the deadline.
The most important component of RTOS is its kernel (Monolithic &
Microkernel). BSP or Board Support Package makes an RTOS
target-specific (It’s a processor specific code onto (processor) which
we like to have our RTOS running).
RTOS Kernel Functions:
1. Task Management2. Intertask Communication & Synchronization
3. Dynamic Memory Allocation 4. Timers5. Devices I/O Supervisor*
Task States of RTOS :--
WORKING
Task Management:
Set of services used to allow application software developers to
design their software as a number of separate chunks of software
each handling a distinct topic, a distinct goal, and sometimes its own
real-time deadline. Main service offered is Task Scheduling controls
the execution of application software tasks  can make them run in a
very timely and responsive fashion.
RTOS perform priority-based pre emptive task scheduling. Basic
rules for priority based pre emptive task scheduling  The Highest
Priority Task that is Ready to Run, will be the Task that Must be
Running.
Priority based Preemptive Task Scheduling: Every Task in a software
application is assigned a priority. Higher Priority = Higher Need for
Quick Response.
Nested Preemption Timeline for Priority-based Preemptive
Scheduling.
Inter task Communication &Synchronization These services makes
it possible to pass information from one task to another without
information ever being damaged. Makes it possible for tasks to
coordinate & productively cooperate with each other.
Inter-Task communication &Synchronization The most important
communication b/w tasks in an OS is the passing of data from one
task to another. Message Producer Task Receiver Task If messages
are sent more quickly than they can be handled, the OS provides
message queues for holding the messages until they can be
processed.
Message passing in RTOS In RTOS, the OS copies a pointer to the
message, delivers the pointer to the message-receiver task, and then
deletes the copy of the pointer with message-sender task. Message
Sender RAM Task Message Message Message
Example of Rtos:-
freeTOS, VxWorks, pSOS OS QNX •ETLinux • VRTX •uCLinux •uCOS
•uLinux (muLinux) SymbianOS distro fits on a single floppy
Mutexes :
Mutex means mutual exclusion A mutex is a synchronization object that
can have only two states. They are not-owned and owned. Two operations
are defined for mutexes
Lock: This operation attempts to take ownership of a mutex, if the mutex
is already owned by another thread then the invoking thread is queued.
Unlock: This operation relinquishes ownership of a mutex. If there are
queued threads then a thread is removed from the queue and resumed,
ownership is implicitly assigned to the thread.
Interrupt processing using Semaphore mutex
Priority-ceiling mutex locking and unlocking
uint8_t SST_mutexLock(uint8_t
prioCeiling) {
uint8_t p;
SST_INT_LOCK();
p = S_currPrio_; /* save
the original SST priority to return */
if (prioCeiling > SST_currPrio_) {
SST_currPrio_ = prioCeiling; /*
set the SST priority to the ceiling */
}
SST_INT_UNLOCK();
return p;
}
/*.........................................
.................................*/
void SST_mutexUnlock(uint8_t orgPrio) {
SST_INT_LOCK();
if (orgPrio < SST_currPrio_) {
SST_currPrio_ = orgPrio; /*
restore the saved priority to unlock */
SST_schedule_(); /* the
scheduler unlocks the interrupts internally
*/
}
SST_INT_UNLOCK();
}
Unlike the simple INT_LOCK macros, the SST mutex interface
allows locks to be nested, because the original SST priority is
preserved on the stack. Above example shows how the mutex is
used in the SST example to protect the non-reentrant DOS
random number generator calls inside the clock-tick
tasks tickTaskA() and tickTaskB().
Priority Inversion Problem In any real time embedded system ,if
a high priority task is blocked or waiting and a low priority task is
running or under execution ,this situation is called Priority
Inversion. This priority Inversion is shown in the diagram below.
In Scheduling, priority inversion is the scenario where a low priority
Task holds a shared resource that is required by a high priority task.
This causes the execution of the high priority task to be blocked
until the low priority task releases the resource, effectively
“inverting” the relative priorities of the two tasks.
Suppose some other medium priority task, one that does not depend
on the shared resource, attempts to run in the interim, it will take
precedence over both the low priority task and the high priority task.
The consequences of the priority Inversion are
(i) Reduce the performance of the system (ii) May reduce the
system responsiveness
which leads to the violation of response time guarantees (iii) Create
problems in real-time systems.
There are two types of priority inversions.(i) Bounded and
(ii).Unbounded.
The Priority Inversion is avoided by using two protocolas.,namely
(i).Priority Inheritance Protocol (PIP)
(ii) Priority Ceiling Protocol(PCP).
APPLICATION
Creating Three Tasks :-
1. Blinking LED 2. Print on USART1 3. Print on USART2
void blinkyLed_task()
{
while(1)
{ // Set PORTC.8
GPIOC->BSRR = (1 << 8);
vTaskDelay(200);
// Reset PORTC.8
GPIOC->BRR = (1 << 8);
vTaskDelay(500);
}
}
void usart_task1()
{ while(1)
{
if(xSemaphoreTake( mutex, ( TickType_t ) 0 )
== pdTRUE )
{ usart1_puts("HOD of EXTC Department ");
xSemaphoreGive(mutex);
vTaskDelay(1000);
} } }
void usart_task2()
{ while(1)
{
if(xSemaphoreTake( mutex, ( TickType_t ) 0 )
== pdTRUE )
{
usart1_puts("Y . S . RAO Sir ");
xSemaphoreGive(mutex);
vTaskDelay(1000);
} }}
Calling Tasks inside main( ) :
int main(void)
{
RCC->AHBENR |= RCC_AHBENR_GPIOCEN;
// enable the clock to GPIOC
RCC->AHBENR |= RCC_AHBENR_GPIOAEN;
// enable the clock to GPIOA
// Put PORTC.8 in output mode
GPIOC->MODER |= (1 << 16);
// Put PORTC.9 in output mode
GPIOC->MODER |= (1 << 18);
// Put PORTA.0 in input mode
GPIOA->MODER &= ~(3 << 0);
usart1_init();
mutex = xSemaphoreCreateMutex();
xTaskCreate(usart_task1,
(const char *)"blinkyLed_task",
configMINIMAL_STACK_SIZE,
NULL, /* pvParameters */
tskIDLE_PRIORITY + 1, /* uxPriority */
NULL /* pvCreatedTask */);
xTaskCreate(usart_task1,
(const char *)"usart_task2",
configMINIMAL_STACK_SIZE,
NULL, /* pvParameters */
tskIDLE_PRIORITY + 2, /* uxPriority */
NULL /* pvCreatedTask */);
xTaskCreate(usart_task2,
(const char *)"usart_task3",
configMINIMAL_STACK_SIZE,
NULL, /* pvParameters */
tskIDLE_PRIORITY + 3, /* uxPriority */
NULL /* pvCreatedTask */);
vTaskStartScheduler();
while(1); }
RESULT
After successful compilation of program .hex file will be
generated. we used to connect the ARM board kit via
Universal serial bus for debugging purpose to see Blinking
LED.
For debugging purpose openOCD.bin file is used. it provides
Real time interfacing of ARM LPC2148X to the code i.e
RTOS.
Procedure to see the USART output on
Minicom screen:---
rajan@Rajan:~$ sudo minicom
Welcome to minicom 2.7
OPTIONS: I18n
Compiled on Jan 1 2014, 17:13:19.
Port /dev/ttySNX0, 19:59:10
Press CTRL-A Z for help on special keys
+-----[configuration]------+
| Filenames and paths |
| File transfer protocols |
| Serial port setup |
| Modem and dialing |
| Screen and keyboard |
| Save setup as dfl |
| Save setup as.. |
| Exit |
+--------------------------+
CTRL-A Z for help | 9600 8N1 | NOR | Minicom 2.7 | VT102 |
Offline | ttySNX0
After setting the serial usb port and Baud rate we will start
getting the output on the Minicom screen as shown below:--
If Tasks have equal priority then use of Semaphore is essential.
It is better shown in the output on Minicom window.
1. With Mutex (i.e Output device is locked for a single Task)
Task 1: Display the task1 output at USART1 ( Embedded GURU of
SPIT )
Task 2: Display the task2 output at USART2 ( Y . S . RAO Sir )
OUTPUT : HOD of EXTC Department Y . S . RAO Sir HOD of
EXTC Department Y . S . RAO Sir HOD of EXTC Department
Y . S . RAO Sir HOD of EXTC Department Y . S . RAO Sir
HOD of EXTC Department Y . S . RAO Sir HOD of EXTC
Department Y . S . RAO Sir .........
2. Without Mutex (i.e Output device is used Task)
OUTPUT : HOD of EXTC Department Y . S . RAO Sir HO Y .
D .S o. FRA EXO STC irDe HOpar D otm f EXenTCt S o. FRA
EXO STC irDe HOpar D otm f EXenTCt S o. FRA EXO STC
irDe HOpar D otm f EXenTCt S o. FRA EXO STC irDe HOpar
D otm f ExenTCt...........................
References:
1.Embedded/Real Time Systems : Concepts,Design
&Programming –Dr.K.V.K.K Prasad : Dreamtech Publs
2. Embedded & Real Time Systems Notes - Mr. Suman
Kalyan Oduri
3.www.freertos.org
RTOS implementation
Ad

More Related Content

What's hot (20)

Embedded c
Embedded cEmbedded c
Embedded c
Ami Prakash
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
Tech_MX
 
Coa module1
Coa module1Coa module1
Coa module1
cs19club
 
FreeRTOS basics (Real time Operating System)
FreeRTOS basics (Real time Operating System)FreeRTOS basics (Real time Operating System)
FreeRTOS basics (Real time Operating System)
Naren Chandra
 
Real Time Operating Systems
Real Time Operating SystemsReal Time Operating Systems
Real Time Operating Systems
Murtadha Alsabbagh
 
Real Time Operating system (RTOS) - Embedded systems
Real Time Operating system (RTOS) - Embedded systemsReal Time Operating system (RTOS) - Embedded systems
Real Time Operating system (RTOS) - Embedded systems
Hariharan Ganesan
 
Reference model of real time system
Reference model of real time systemReference model of real time system
Reference model of real time system
Kamal Acharya
 
Real Time OS For Embedded Systems
Real Time OS For Embedded SystemsReal Time OS For Embedded Systems
Real Time OS For Embedded Systems
Himanshu Ghetia
 
RTOS APPLICATIONS
RTOS  APPLICATIONSRTOS  APPLICATIONS
RTOS APPLICATIONS
Dr.YNM
 
Real time operating system
Real time operating systemReal time operating system
Real time operating system
Khuram Shahzad
 
Os rtos.ppt
Os rtos.pptOs rtos.ppt
Os rtos.ppt
rahul km
 
UNIT-I-RTOS and Concepts
UNIT-I-RTOS and ConceptsUNIT-I-RTOS and Concepts
UNIT-I-RTOS and Concepts
Dr.YNM
 
Chapter 1-Microprocessors, Microcomputers, and Assembly Language
Chapter 1-Microprocessors, Microcomputers, and Assembly LanguageChapter 1-Microprocessors, Microcomputers, and Assembly Language
Chapter 1-Microprocessors, Microcomputers, and Assembly Language
cmkandemir
 
RTOS Basic Concepts
RTOS Basic ConceptsRTOS Basic Concepts
RTOS Basic Concepts
Pantech ProLabs India Pvt Ltd
 
FreeRTOS
FreeRTOSFreeRTOS
FreeRTOS
Ankita Tiwari
 
Embedded C programming based on 8051 microcontroller
Embedded C programming based on 8051 microcontrollerEmbedded C programming based on 8051 microcontroller
Embedded C programming based on 8051 microcontroller
Gaurav Verma
 
Real Time Systems
Real Time SystemsReal Time Systems
Real Time Systems
leo3004
 
Components Of Computer unit-2
Components Of Computer  unit-2Components Of Computer  unit-2
Components Of Computer unit-2
Amit Chandra
 
Computer Organization and Architecture.pdf
Computer Organization and Architecture.pdfComputer Organization and Architecture.pdf
Computer Organization and Architecture.pdf
mekelle university(EiT-M)
 
Course file for theory of computation dt 08 08-2016.
Course file for theory of computation dt 08 08-2016.Course file for theory of computation dt 08 08-2016.
Course file for theory of computation dt 08 08-2016.
sumit jain
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
Tech_MX
 
Coa module1
Coa module1Coa module1
Coa module1
cs19club
 
FreeRTOS basics (Real time Operating System)
FreeRTOS basics (Real time Operating System)FreeRTOS basics (Real time Operating System)
FreeRTOS basics (Real time Operating System)
Naren Chandra
 
Real Time Operating system (RTOS) - Embedded systems
Real Time Operating system (RTOS) - Embedded systemsReal Time Operating system (RTOS) - Embedded systems
Real Time Operating system (RTOS) - Embedded systems
Hariharan Ganesan
 
Reference model of real time system
Reference model of real time systemReference model of real time system
Reference model of real time system
Kamal Acharya
 
Real Time OS For Embedded Systems
Real Time OS For Embedded SystemsReal Time OS For Embedded Systems
Real Time OS For Embedded Systems
Himanshu Ghetia
 
RTOS APPLICATIONS
RTOS  APPLICATIONSRTOS  APPLICATIONS
RTOS APPLICATIONS
Dr.YNM
 
Real time operating system
Real time operating systemReal time operating system
Real time operating system
Khuram Shahzad
 
Os rtos.ppt
Os rtos.pptOs rtos.ppt
Os rtos.ppt
rahul km
 
UNIT-I-RTOS and Concepts
UNIT-I-RTOS and ConceptsUNIT-I-RTOS and Concepts
UNIT-I-RTOS and Concepts
Dr.YNM
 
Chapter 1-Microprocessors, Microcomputers, and Assembly Language
Chapter 1-Microprocessors, Microcomputers, and Assembly LanguageChapter 1-Microprocessors, Microcomputers, and Assembly Language
Chapter 1-Microprocessors, Microcomputers, and Assembly Language
cmkandemir
 
Embedded C programming based on 8051 microcontroller
Embedded C programming based on 8051 microcontrollerEmbedded C programming based on 8051 microcontroller
Embedded C programming based on 8051 microcontroller
Gaurav Verma
 
Real Time Systems
Real Time SystemsReal Time Systems
Real Time Systems
leo3004
 
Components Of Computer unit-2
Components Of Computer  unit-2Components Of Computer  unit-2
Components Of Computer unit-2
Amit Chandra
 
Course file for theory of computation dt 08 08-2016.
Course file for theory of computation dt 08 08-2016.Course file for theory of computation dt 08 08-2016.
Course file for theory of computation dt 08 08-2016.
sumit jain
 

Viewers also liked (8)

Ecs new scheme vtu syllabus
Ecs new scheme vtu syllabusEcs new scheme vtu syllabus
Ecs new scheme vtu syllabus
Khalids Parveez
 
Rtos by shibu
Rtos by shibuRtos by shibu
Rtos by shibu
Shibu Krishnan
 
REAL TIME OPERATING SYSTEM
REAL TIME OPERATING SYSTEMREAL TIME OPERATING SYSTEM
REAL TIME OPERATING SYSTEM
prakrutijsh
 
Real Time Operating System Concepts
Real Time Operating System ConceptsReal Time Operating System Concepts
Real Time Operating System Concepts
Sanjiv Malik
 
Unit 4 Real Time Operating System
Unit 4 Real Time Operating SystemUnit 4 Real Time Operating System
Unit 4 Real Time Operating System
Dr. Pankaj Zope
 
Real Time Operating System
Real Time Operating SystemReal Time Operating System
Real Time Operating System
vivek223
 
RTOS - Real Time Operating Systems
RTOS - Real Time Operating SystemsRTOS - Real Time Operating Systems
RTOS - Real Time Operating Systems
Emertxe Information Technologies Pvt Ltd
 
Rtos Concepts
Rtos ConceptsRtos Concepts
Rtos Concepts
Sundaresan Sundar
 
Ad

Similar to RTOS implementation (20)

Embedded os
Embedded osEmbedded os
Embedded os
K Senthil Kumar
 
Rtos
RtosRtos
Rtos
lakshmivinod7
 
RTOS Material hfffffffffffffffffffffffffffffffffffff
RTOS Material hfffffffffffffffffffffffffffffffffffffRTOS Material hfffffffffffffffffffffffffffffffffffff
RTOS Material hfffffffffffffffffffffffffffffffffffff
adugnanegero
 
Lab6 rtos
Lab6 rtosLab6 rtos
Lab6 rtos
indirakumar86
 
IJCER (www.ijceronline.com) International Journal of computational Engineeri...
 IJCER (www.ijceronline.com) International Journal of computational Engineeri... IJCER (www.ijceronline.com) International Journal of computational Engineeri...
IJCER (www.ijceronline.com) International Journal of computational Engineeri...
ijceronline
 
Os Concepts
Os ConceptsOs Concepts
Os Concepts
rajesh panda
 
Project report of ustos
Project report of ustosProject report of ustos
Project report of ustos
Murali Mc
 
Embedded Intro India05
Embedded Intro India05Embedded Intro India05
Embedded Intro India05
Rajesh Gupta
 
L1 and L3 _uCOS Task and scheduler concepts
L1 and L3 _uCOS Task and scheduler conceptsL1 and L3 _uCOS Task and scheduler concepts
L1 and L3 _uCOS Task and scheduler concepts
Varsha506533
 
1230 Rtf Final
1230 Rtf Final1230 Rtf Final
1230 Rtf Final
luisotaviomedici
 
Intro To RTOS by Silicon labs covering fundamentals
Intro To RTOS by Silicon labs covering fundamentalsIntro To RTOS by Silicon labs covering fundamentals
Intro To RTOS by Silicon labs covering fundamentals
sivakumarrohit2917
 
UNIT -2 Real Time Operating System for VLSI.ppt
UNIT -2 Real Time Operating System for VLSI.pptUNIT -2 Real Time Operating System for VLSI.ppt
UNIT -2 Real Time Operating System for VLSI.ppt
sagarashwin939
 
Real time operating system which explains scheduling algorithms
Real time operating system which explains scheduling algorithmsReal time operating system which explains scheduling algorithms
Real time operating system which explains scheduling algorithms
Lavanya Sandeep
 
The Free RTOS kernel By Khaled AMIRAT
The Free RTOS kernel    By Khaled AMIRATThe Free RTOS kernel    By Khaled AMIRAT
The Free RTOS kernel By Khaled AMIRAT
Khaled AMIRAT
 
Real time os(suga)
Real time os(suga) Real time os(suga)
Real time os(suga)
Nagarajan
 
PPT.pdf
PPT.pdfPPT.pdf
PPT.pdf
RameshBabu461344
 
TechnoScripts- Free Interview Preparation Q & A Set.pdf
TechnoScripts- Free Interview Preparation Q & A Set.pdfTechnoScripts- Free Interview Preparation Q & A Set.pdf
TechnoScripts- Free Interview Preparation Q & A Set.pdf
TechnoscriptsPunesNo
 
Beyond the RTOS: A Better Way to Design Real-Time Embedded Software
Beyond the RTOS: A Better Way to Design Real-Time Embedded SoftwareBeyond the RTOS: A Better Way to Design Real-Time Embedded Software
Beyond the RTOS: A Better Way to Design Real-Time Embedded Software
Quantum Leaps, LLC
 
Autosar Basics hand book_v1
Autosar Basics  hand book_v1Autosar Basics  hand book_v1
Autosar Basics hand book_v1
Keroles karam khalil
 
Welcome to International Journal of Engineering Research and Development (IJERD)
Welcome to International Journal of Engineering Research and Development (IJERD)Welcome to International Journal of Engineering Research and Development (IJERD)
Welcome to International Journal of Engineering Research and Development (IJERD)
IJERD Editor
 
RTOS Material hfffffffffffffffffffffffffffffffffffff
RTOS Material hfffffffffffffffffffffffffffffffffffffRTOS Material hfffffffffffffffffffffffffffffffffffff
RTOS Material hfffffffffffffffffffffffffffffffffffff
adugnanegero
 
IJCER (www.ijceronline.com) International Journal of computational Engineeri...
 IJCER (www.ijceronline.com) International Journal of computational Engineeri... IJCER (www.ijceronline.com) International Journal of computational Engineeri...
IJCER (www.ijceronline.com) International Journal of computational Engineeri...
ijceronline
 
Project report of ustos
Project report of ustosProject report of ustos
Project report of ustos
Murali Mc
 
Embedded Intro India05
Embedded Intro India05Embedded Intro India05
Embedded Intro India05
Rajesh Gupta
 
L1 and L3 _uCOS Task and scheduler concepts
L1 and L3 _uCOS Task and scheduler conceptsL1 and L3 _uCOS Task and scheduler concepts
L1 and L3 _uCOS Task and scheduler concepts
Varsha506533
 
Intro To RTOS by Silicon labs covering fundamentals
Intro To RTOS by Silicon labs covering fundamentalsIntro To RTOS by Silicon labs covering fundamentals
Intro To RTOS by Silicon labs covering fundamentals
sivakumarrohit2917
 
UNIT -2 Real Time Operating System for VLSI.ppt
UNIT -2 Real Time Operating System for VLSI.pptUNIT -2 Real Time Operating System for VLSI.ppt
UNIT -2 Real Time Operating System for VLSI.ppt
sagarashwin939
 
Real time operating system which explains scheduling algorithms
Real time operating system which explains scheduling algorithmsReal time operating system which explains scheduling algorithms
Real time operating system which explains scheduling algorithms
Lavanya Sandeep
 
The Free RTOS kernel By Khaled AMIRAT
The Free RTOS kernel    By Khaled AMIRATThe Free RTOS kernel    By Khaled AMIRAT
The Free RTOS kernel By Khaled AMIRAT
Khaled AMIRAT
 
Real time os(suga)
Real time os(suga) Real time os(suga)
Real time os(suga)
Nagarajan
 
TechnoScripts- Free Interview Preparation Q & A Set.pdf
TechnoScripts- Free Interview Preparation Q & A Set.pdfTechnoScripts- Free Interview Preparation Q & A Set.pdf
TechnoScripts- Free Interview Preparation Q & A Set.pdf
TechnoscriptsPunesNo
 
Beyond the RTOS: A Better Way to Design Real-Time Embedded Software
Beyond the RTOS: A Better Way to Design Real-Time Embedded SoftwareBeyond the RTOS: A Better Way to Design Real-Time Embedded Software
Beyond the RTOS: A Better Way to Design Real-Time Embedded Software
Quantum Leaps, LLC
 
Welcome to International Journal of Engineering Research and Development (IJERD)
Welcome to International Journal of Engineering Research and Development (IJERD)Welcome to International Journal of Engineering Research and Development (IJERD)
Welcome to International Journal of Engineering Research and Development (IJERD)
IJERD Editor
 
Ad

Recently uploaded (20)

MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Journal of Soft Computing in Civil Engineering
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)
Vəhid Gəruslu
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
some basics electrical and electronics knowledge
some basics electrical and electronics knowledgesome basics electrical and electronics knowledge
some basics electrical and electronics knowledge
nguyentrungdo88
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.
anuragmk56
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)
samueljackson3773
 
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E..."Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
Infopitaara
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)
Vəhid Gəruslu
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
some basics electrical and electronics knowledge
some basics electrical and electronics knowledgesome basics electrical and electronics knowledge
some basics electrical and electronics knowledge
nguyentrungdo88
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.
anuragmk56
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)
samueljackson3773
 
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E..."Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
Infopitaara
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 

RTOS implementation

  • 1. Real Time Operating System For Embedded Systems Rajan Singh M.E EXTC Sem1(2015-2017) [email protected] Abstract— An embedded system is a special-purpose computer system designed to perform one or a few dedicated functions, often with real-time computing constraints. Embedded systems contain a processor, software and Memory and The processor may be 8051 micro-controller or a Pentium-IV processor, Memory ROM and RAM respectively Memory Input Processor Output. Index Terms— freeRTOS, ARM LPC2148X, Task, Scheduling, Semaphore, mutex . INTRODUCTION (RTOS) An RTOS is an OS for response time-controlled and event- controlled processes. It is very essential for large scale embedded systems. RTOS occupy little space from 10 KB to 100KB The main task of a RTOS is to manage the resources of the computer such that a particular operation executes in precisely the same amount of time every time it occur. When RTOS is not necessary? For small-scaled systems, RTOS’s function can be replaced by C. For example, instead of the memory allocation and de-allocation functions of RTOS, the C function , 'melloc' and 'free' can be used. Software can directly handle inter-process communication. 3. When RTOS is necessary? However, RTOS is essential when… A common and effective way of handling of the hardware source calls from the interrupts I/O management with devices, files, mailboxes becomes simple using an RTOS Effectively scheduling and running and blocking of the tasks in cases of many tasks and many more….. In conclusion, an RTOS may not be necessary in a small-scaled embedded system. An RTOS is necessary when scheduling of multiple processes and devices is important. THEORY Hard Real time system: Failure to meet such a dead line is considered to be a fatal fault and will lead to disastrous consequences e.g. Response of the break system of a speeding Train approaching a Red Signal to the stop command must come before the train crosses the Red signal. Soft Real time system : Failure to miss a Soft Deadline is undesirable but a few misses does no serious harm like occasional delay in an on line trading of stocks. However the system’s overall performance becomes poorer and poorer as more and more jobs starts missing the deadline. The most important component of RTOS is its kernel (Monolithic & Microkernel). BSP or Board Support Package makes an RTOS target-specific (It’s a processor specific code onto (processor) which we like to have our RTOS running). RTOS Kernel Functions: 1. Task Management2. Intertask Communication & Synchronization 3. Dynamic Memory Allocation 4. Timers5. Devices I/O Supervisor* Task States of RTOS :-- WORKING Task Management: Set of services used to allow application software developers to design their software as a number of separate chunks of software each handling a distinct topic, a distinct goal, and sometimes its own real-time deadline. Main service offered is Task Scheduling controls the execution of application software tasks  can make them run in a very timely and responsive fashion. RTOS perform priority-based pre emptive task scheduling. Basic rules for priority based pre emptive task scheduling  The Highest Priority Task that is Ready to Run, will be the Task that Must be Running.
  • 2. Priority based Preemptive Task Scheduling: Every Task in a software application is assigned a priority. Higher Priority = Higher Need for Quick Response. Nested Preemption Timeline for Priority-based Preemptive Scheduling. Inter task Communication &Synchronization These services makes it possible to pass information from one task to another without information ever being damaged. Makes it possible for tasks to coordinate & productively cooperate with each other. Inter-Task communication &Synchronization The most important communication b/w tasks in an OS is the passing of data from one task to another. Message Producer Task Receiver Task If messages are sent more quickly than they can be handled, the OS provides message queues for holding the messages until they can be processed. Message passing in RTOS In RTOS, the OS copies a pointer to the message, delivers the pointer to the message-receiver task, and then deletes the copy of the pointer with message-sender task. Message Sender RAM Task Message Message Message Example of Rtos:- freeTOS, VxWorks, pSOS OS QNX •ETLinux • VRTX •uCLinux •uCOS •uLinux (muLinux) SymbianOS distro fits on a single floppy Mutexes : Mutex means mutual exclusion A mutex is a synchronization object that can have only two states. They are not-owned and owned. Two operations are defined for mutexes Lock: This operation attempts to take ownership of a mutex, if the mutex is already owned by another thread then the invoking thread is queued. Unlock: This operation relinquishes ownership of a mutex. If there are queued threads then a thread is removed from the queue and resumed, ownership is implicitly assigned to the thread. Interrupt processing using Semaphore mutex Priority-ceiling mutex locking and unlocking uint8_t SST_mutexLock(uint8_t prioCeiling) { uint8_t p; SST_INT_LOCK(); p = S_currPrio_; /* save the original SST priority to return */ if (prioCeiling > SST_currPrio_) { SST_currPrio_ = prioCeiling; /* set the SST priority to the ceiling */ } SST_INT_UNLOCK(); return p; } /*......................................... .................................*/ void SST_mutexUnlock(uint8_t orgPrio) { SST_INT_LOCK(); if (orgPrio < SST_currPrio_) { SST_currPrio_ = orgPrio; /* restore the saved priority to unlock */ SST_schedule_(); /* the scheduler unlocks the interrupts internally */ } SST_INT_UNLOCK(); } Unlike the simple INT_LOCK macros, the SST mutex interface allows locks to be nested, because the original SST priority is preserved on the stack. Above example shows how the mutex is used in the SST example to protect the non-reentrant DOS random number generator calls inside the clock-tick tasks tickTaskA() and tickTaskB(). Priority Inversion Problem In any real time embedded system ,if a high priority task is blocked or waiting and a low priority task is running or under execution ,this situation is called Priority Inversion. This priority Inversion is shown in the diagram below. In Scheduling, priority inversion is the scenario where a low priority Task holds a shared resource that is required by a high priority task. This causes the execution of the high priority task to be blocked until the low priority task releases the resource, effectively “inverting” the relative priorities of the two tasks. Suppose some other medium priority task, one that does not depend on the shared resource, attempts to run in the interim, it will take precedence over both the low priority task and the high priority task. The consequences of the priority Inversion are (i) Reduce the performance of the system (ii) May reduce the system responsiveness which leads to the violation of response time guarantees (iii) Create problems in real-time systems. There are two types of priority inversions.(i) Bounded and (ii).Unbounded. The Priority Inversion is avoided by using two protocolas.,namely (i).Priority Inheritance Protocol (PIP) (ii) Priority Ceiling Protocol(PCP). APPLICATION Creating Three Tasks :- 1. Blinking LED 2. Print on USART1 3. Print on USART2 void blinkyLed_task() { while(1) { // Set PORTC.8 GPIOC->BSRR = (1 << 8); vTaskDelay(200); // Reset PORTC.8 GPIOC->BRR = (1 << 8); vTaskDelay(500); } }
  • 3. void usart_task1() { while(1) { if(xSemaphoreTake( mutex, ( TickType_t ) 0 ) == pdTRUE ) { usart1_puts("HOD of EXTC Department "); xSemaphoreGive(mutex); vTaskDelay(1000); } } } void usart_task2() { while(1) { if(xSemaphoreTake( mutex, ( TickType_t ) 0 ) == pdTRUE ) { usart1_puts("Y . S . RAO Sir "); xSemaphoreGive(mutex); vTaskDelay(1000); } }} Calling Tasks inside main( ) : int main(void) { RCC->AHBENR |= RCC_AHBENR_GPIOCEN; // enable the clock to GPIOC RCC->AHBENR |= RCC_AHBENR_GPIOAEN; // enable the clock to GPIOA // Put PORTC.8 in output mode GPIOC->MODER |= (1 << 16); // Put PORTC.9 in output mode GPIOC->MODER |= (1 << 18); // Put PORTA.0 in input mode GPIOA->MODER &= ~(3 << 0); usart1_init(); mutex = xSemaphoreCreateMutex(); xTaskCreate(usart_task1, (const char *)"blinkyLed_task", configMINIMAL_STACK_SIZE, NULL, /* pvParameters */ tskIDLE_PRIORITY + 1, /* uxPriority */ NULL /* pvCreatedTask */); xTaskCreate(usart_task1, (const char *)"usart_task2", configMINIMAL_STACK_SIZE, NULL, /* pvParameters */ tskIDLE_PRIORITY + 2, /* uxPriority */ NULL /* pvCreatedTask */); xTaskCreate(usart_task2, (const char *)"usart_task3", configMINIMAL_STACK_SIZE, NULL, /* pvParameters */ tskIDLE_PRIORITY + 3, /* uxPriority */ NULL /* pvCreatedTask */); vTaskStartScheduler(); while(1); } RESULT After successful compilation of program .hex file will be generated. we used to connect the ARM board kit via Universal serial bus for debugging purpose to see Blinking LED. For debugging purpose openOCD.bin file is used. it provides Real time interfacing of ARM LPC2148X to the code i.e RTOS. Procedure to see the USART output on Minicom screen:--- rajan@Rajan:~$ sudo minicom Welcome to minicom 2.7 OPTIONS: I18n Compiled on Jan 1 2014, 17:13:19. Port /dev/ttySNX0, 19:59:10 Press CTRL-A Z for help on special keys +-----[configuration]------+ | Filenames and paths | | File transfer protocols | | Serial port setup | | Modem and dialing | | Screen and keyboard | | Save setup as dfl | | Save setup as.. | | Exit | +--------------------------+ CTRL-A Z for help | 9600 8N1 | NOR | Minicom 2.7 | VT102 | Offline | ttySNX0 After setting the serial usb port and Baud rate we will start getting the output on the Minicom screen as shown below:-- If Tasks have equal priority then use of Semaphore is essential. It is better shown in the output on Minicom window. 1. With Mutex (i.e Output device is locked for a single Task) Task 1: Display the task1 output at USART1 ( Embedded GURU of SPIT ) Task 2: Display the task2 output at USART2 ( Y . S . RAO Sir ) OUTPUT : HOD of EXTC Department Y . S . RAO Sir HOD of EXTC Department Y . S . RAO Sir HOD of EXTC Department Y . S . RAO Sir HOD of EXTC Department Y . S . RAO Sir HOD of EXTC Department Y . S . RAO Sir HOD of EXTC Department Y . S . RAO Sir ......... 2. Without Mutex (i.e Output device is used Task) OUTPUT : HOD of EXTC Department Y . S . RAO Sir HO Y . D .S o. FRA EXO STC irDe HOpar D otm f EXenTCt S o. FRA EXO STC irDe HOpar D otm f EXenTCt S o. FRA EXO STC irDe HOpar D otm f EXenTCt S o. FRA EXO STC irDe HOpar D otm f ExenTCt........................... References: 1.Embedded/Real Time Systems : Concepts,Design &Programming –Dr.K.V.K.K Prasad : Dreamtech Publs 2. Embedded & Real Time Systems Notes - Mr. Suman Kalyan Oduri 3.www.freertos.org