SlideShare a Scribd company logo
08/05/2025 RTOS Mucos
Unit-II: RTOS Programming
 Basic Functions and Types of RTOS for Embedded Systems
 RTOS mCOS-II
 RTOSVxWorks
 Programming concepts of mCOS-II &VxWorks with
relevant Examples,
 Programming concepts of RTOSWindows CE
 RTOS Linux 2.6.x
 RTOS RT Linux
MicroC/OS-II
S
O
T
R
08/05/2025 RTOS Mucos
MicroC/OS-II (commonly termed as µC/OS-
II or uC/OS-II), is the acronym for Micro-Controller
Operating Systems Version 2.
It is a priority-based real-time multitasking operating
system kernel for microprocessors, written mainly in the
C programming language.
It is intended for use in embedded systems.
INTRODUCTION
08/05/2025 RTOS Mucos
It is a very small real-time kernel.
Memory footprint is about 20KB for a fully functional
kernel.
Source code is written mostly in ANSI C.
Highly portable, ROMable, very scalable, preemptive real-
time, deterministic, multitasking kernel.
It can manage up to 64 tasks (56 user tasks available).
It has connectivity with μC/GUI and μC/FS (GUI and File
Systems for μC/OS II).
Features of MicroC/OS-II :
08/05/2025 RTOS Mucos
It is ported to more than 100 microprocessors and
microcontrollers.
It is simple to use and simple to implement but very
effective compared to the price/performance ratio.
It supports all type of processors from 8-bit to 64-bit.
Cont…
08/05/2025 RTOS Mucos
µC/OS-II is a multitasking operating system. Each task is
an infinite loop and can be in any one of the following five
states:
 Dormant
 Ready
 Running
 Waiting
 ISR (Interrupt Service Routine)
Task states:
08/05/2025 RTOS Mucos
 Task Feature
 Task Creation
 Task Stack & Stack Checking
 Task Deletion
 Change a Task’s Priority
 Suspend and Resume a Task
 Get Information about a Task
Task Management (Services):
08/05/2025 RTOS Mucos
 μC/OS-II can manage up to 64 tasks.
The four highest priority tasks and the four lowest priority
tasks are reserved for its own use. This leaves 56 tasks for
applications.
The lower the value of the priority, the higher the priority
of the task. (Something on the lines of Rate Monotonic
Scheduling).
The task priority number also serves as the task identifier.
Task Feature :
08/05/2025 RTOS Mucos
Rate Monotonic Scheduling :
 In Rate Monotonic Scheduling tasks with the highest rate of
execution are given the highest priority
Assumptions:
 All tasks are periodic
 Tasks do not synchronize with one another, share resources, etc.
 Preemptive scheduling is used (always runs the highest priority
task that is ready)
 Under these assumptions, let n be the number of tasks, Ei be the
execution time of task i, and Ti be the period of task i. Then, all
deadlines will be met if the following inequality is satisfied:
ΣEi / Ti ≤ n(2^1/n – 1)
08/05/2025 RTOS Mucos
Rate Monotonic Scheduling :
Suppose we have 3 tasks. Task 1 runs at 100 Hz and takes 2
ms. Task 2 runs at 50 Hz and takes 1 ms. Task 3 runs at 66.7 Hz
and takes 7 ms. Apply RMS theory…
(2/10) + (1/20) + (7/15) = 0.717 ≤ 3(21/3 – 1) = 0.780
Thus, all the deadlines will be met
 General Solution?
 As n →∞, the right-hand side of the inequality goes to
ln(2)=0.6931. Thus, you should design your system to use less
than 60-70% of the CPU
08/05/2025 RTOS Mucos
PROCESS CYCLE :
08/05/2025 RTOS Mucos
There are two functions for creating a task:
OSTaskCreate()
 OSTaskCreateExt().
Task Creation :
08/05/2025 RTOS Mucos
Task Management :
08/05/2025 RTOS Mucos
Task Management :
After the task is created, the task has to get a stack in
which it will store its data.
 A stack must consist of contiguous memory locations.
 It is necessary to determine how much stack space a
task actually uses.
 Deleting a task means the task will be returned to its
dormant state and does not mean that the code for the
task will be deleted. The calling task can delete itself.
08/05/2025 RTOS Mucos
If another task tries to delete the current task, the
resources are not freed and thus are lost. So the task has to
delete itself after it uses its resources
Priority of the calling task or another task can be changed
at run time.
A task can suspend itself or another task, a suspended task
can resume itself.
A task can obtain information about itself or other tasks.
This information can be used to know what the task is doing
at a particular time.
Task Management (cont…):
08/05/2025 RTOS Mucos
The services of Memory management includes:
Initializing the Memory Manager.
Creating a Memory Partition.
Obtaining Status of a Memory Partition.
Obtaining a Memory Block.
Returning a Memory Block.
Waiting for Memory Blocks from a Memory Partition.
Memory Management :
08/05/2025 RTOS Mucos
Each memory partition consists of several fixed-sized memory
blocks.
A task obtains memory blocks from the memory partition. A
task must create a memory partition before it can be used.
Allocation and de-allocation of these fixed-sized memory
blocks is done in constant time and is deterministic.
Multiple memory partitions can exist, so a task can obtain
memory blocks of different sizes.
A specific memory block should be returned to its memory
partition from which it came.
Memory Management :
08/05/2025 RTOS Mucos
Clock Tick : A clock tick is a periodic time source to
keep track of time delays and time outs.
Here, tick intervals varies from 10 ~ 100 ms.
The faster the tick rate, the higher the overhead
imposed on the system.
Whenever a clock tick occurs μC/OS-II increments
a 32- bit counter, the counter starts at zero, and rolls
over to 4,294,967,295 (2^32-1) ticks.
A task can be delayed and a delayed task can also be
resumed.
Time Management :
08/05/2025 RTOS Mucos
It involves five services that includes:
OSTimeDLY()
OSTimeDLYHMSM()
OSTimeDlyResume()
OSTimeGet()
OSTimeSet()
Time Management :
08/05/2025 RTOS Mucos
Inter-task or inter process communication in μC/OS
takes place using:
Semaphores
Message mailbox
Message queues
Tasks and Interrupt service routines (ISR). They can
interact with each other through an ECB (event control
block).
Inter-Task Communication :
08/05/2025 RTOS Mucos
Inter-Task Communication :
Single task waiting
08/05/2025 RTOS Mucos
Inter-Task Communication :
Multiple tasks waiting and signaling
08/05/2025 RTOS Mucos
Inter-Task Communication :
Tasks can wait and signal along with an optional time out
08/05/2025 RTOS Mucos
Inter-Task Communication :
μC/OS-II semaphores consist of two elements
16-bit unsigned integer count
list of tasks waiting for semaphore
μC/OSII provides
Create, post, pend accept and query services
08/05/2025 RTOS Mucos
Inter-Task Communication :
μC/OS-II message-mailboxes: an μC/OSII object that allows
a task or ISR to send a pointer sized variable (pointing to a
message) to another task.
08/05/2025 RTOS Mucos
Inter-Task Communication :
 μC/OS-II message-queues
Available services: Create, Post (FIFO), PostFront (LIFO),
Pend, Accept, Query, Flush
 N = #of entries in the queue: Queue full if Post or
PostFront called N times before a Pend or Accept
08/05/2025 RTOS Mucos
Inter-Task Communication :
μC/OS-II message-queues organized as circular buffers.
08/05/2025 RTOS Mucos
Tasks running under a multitasking kernel should be written in one of
two ways:
1. A non-returning forever loop. For example:
void Task (void *)
{
DoInitStuff();
while (1)
{ do this;
do that;
do the other thing;
call OS service (); // e.g. OSTimeDelay, OSSemPend, etc.
}
}
Writing Applications Under C/OS -II:
μ
08/05/2025 RTOS Mucos
2. A task that deletes itself after running.
For example:
void Task (void *)
{ do this;
do that;
do the other thing;
call OS service (); // e.g. OSTimeDelay, OSSemPend, etc.
OSTaskDelete(); // Ask the OS to delete the task
}
08/05/2025 RTOS Mucos

More Related Content

PDF
RTOS implementation
PDF
Project report of ustos
PPT
L1 and L3 _uCOS Task and scheduler concepts
PPT
UNIT -2 Real Time Operating System for VLSI.ppt
PPTX
Embedded os
PDF
Lab6 rtos
PPTX
RTOS MICRO CONTROLLER OPERATING SYSTEM-2
RTOS implementation
Project report of ustos
L1 and L3 _uCOS Task and scheduler concepts
UNIT -2 Real Time Operating System for VLSI.ppt
Embedded os
Lab6 rtos
RTOS MICRO CONTROLLER OPERATING SYSTEM-2

Similar to Real TIme Operating Systems - Programming with Micro_C (20)

PPTX
PPTX
Unit 4 _MMC_SEM3_AY2023-knoinononknmoknmko24 PPT.pptx
PPT
Rtos 3 & 4
PDF
T2: What the Second Generation Holds
PDF
xCORE architecture flyer
PPTX
Real Time OS For Embedded Systems
PDF
Rtos princples adn case study
PPTX
REAL TIME OPERATING SYSTEM
PPTX
ESD MODULE-5hdbdhbdbdbdbbdbdbbdndbdbdbdbbdbd
PPT
Os Concepts
PDF
CMSIS_RTOS_Tutorial.pdf
PPTX
Kubernetes Introduction
PDF
Beyond the RTOS: A Better Way to Design Real-Time Embedded Software
PDF
Mike Bartley - Innovations for Testing Parallel Software - EuroSTAR 2012
PPTX
Where is my MQ message on z/OS?
PPT
PDF
Efficient Dynamic Scheduling Algorithm for Real-Time MultiCore Systems
PDF
K017617786
PDF
L1.pdf
PDF
L1.pdf
Unit 4 _MMC_SEM3_AY2023-knoinononknmoknmko24 PPT.pptx
Rtos 3 & 4
T2: What the Second Generation Holds
xCORE architecture flyer
Real Time OS For Embedded Systems
Rtos princples adn case study
REAL TIME OPERATING SYSTEM
ESD MODULE-5hdbdhbdbdbdbbdbdbbdndbdbdbdbbdbd
Os Concepts
CMSIS_RTOS_Tutorial.pdf
Kubernetes Introduction
Beyond the RTOS: A Better Way to Design Real-Time Embedded Software
Mike Bartley - Innovations for Testing Parallel Software - EuroSTAR 2012
Where is my MQ message on z/OS?
Efficient Dynamic Scheduling Algorithm for Real-Time MultiCore Systems
K017617786
L1.pdf
L1.pdf
Ad

More from SasiBhushan22 (20)

PPTX
RTOS _Timer , Event, Memory, Device, File & IO Systems Management
PPTX
Interrupt_Latency_Response_Time_Presentation.pptx
PPT
INTRODUCTION TO PIC MICROCONTROLLERS 16C6X
PPTX
RTOS OS Security Issues Security Challenges, Threats & Mitigation
PDF
RTOS Keywords with Definitions and explanation
PPTX
Basic Linux Commands and implementation with Examples
PPTX
RTOS _Timer , Event, Memory, Device, File & IO Systems Management_10-07-25.pptx
PPTX
Basic Linux Commands with syntax and functions
PPT
Operating Systems Storage & Process Management
PPTX
ARM-7 ADDRESSING MODES INSTRUCTION SET
PPTX
ARM-7 ADDRESSING MODES INSTRUCTION SET
PPTX
Microprocessors & Microcontrollers Architecture and Description
PPTX
8051- Microcontrollers Architecture & Addressing modes
PPT
Operating Systems _ Process & Storage Management
PPTX
RTOS_Keywords_with basic Definitions.pptx
PPT
Operating Systems with Storage and Process Management
PPTX
Real Time Operating Systems Basic Definitions
PPT
Introduction to 8086 Microprocessors.ppt
PPT
Interrupts.ppt
PPT
Programs using Microcontrollers.ppt
RTOS _Timer , Event, Memory, Device, File & IO Systems Management
Interrupt_Latency_Response_Time_Presentation.pptx
INTRODUCTION TO PIC MICROCONTROLLERS 16C6X
RTOS OS Security Issues Security Challenges, Threats & Mitigation
RTOS Keywords with Definitions and explanation
Basic Linux Commands and implementation with Examples
RTOS _Timer , Event, Memory, Device, File & IO Systems Management_10-07-25.pptx
Basic Linux Commands with syntax and functions
Operating Systems Storage & Process Management
ARM-7 ADDRESSING MODES INSTRUCTION SET
ARM-7 ADDRESSING MODES INSTRUCTION SET
Microprocessors & Microcontrollers Architecture and Description
8051- Microcontrollers Architecture & Addressing modes
Operating Systems _ Process & Storage Management
RTOS_Keywords_with basic Definitions.pptx
Operating Systems with Storage and Process Management
Real Time Operating Systems Basic Definitions
Introduction to 8086 Microprocessors.ppt
Interrupts.ppt
Programs using Microcontrollers.ppt
Ad

Recently uploaded (20)

PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Pre independence Education in Inndia.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
Classroom Observation Tools for Teachers
PDF
Complications of Minimal Access Surgery at WLH
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
01-Introduction-to-Information-Management.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Cell Types and Its function , kingdom of life
PPTX
Institutional Correction lecture only . . .
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Renaissance Architecture: A Journey from Faith to Humanism
VCE English Exam - Section C Student Revision Booklet
Pre independence Education in Inndia.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
RMMM.pdf make it easy to upload and study
Classroom Observation Tools for Teachers
Complications of Minimal Access Surgery at WLH
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
01-Introduction-to-Information-Management.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Microbial diseases, their pathogenesis and prophylaxis
Cell Types and Its function , kingdom of life
Institutional Correction lecture only . . .

Real TIme Operating Systems - Programming with Micro_C

  • 1. 08/05/2025 RTOS Mucos Unit-II: RTOS Programming  Basic Functions and Types of RTOS for Embedded Systems  RTOS mCOS-II  RTOSVxWorks  Programming concepts of mCOS-II &VxWorks with relevant Examples,  Programming concepts of RTOSWindows CE  RTOS Linux 2.6.x  RTOS RT Linux
  • 3. 08/05/2025 RTOS Mucos MicroC/OS-II (commonly termed as µC/OS- II or uC/OS-II), is the acronym for Micro-Controller Operating Systems Version 2. It is a priority-based real-time multitasking operating system kernel for microprocessors, written mainly in the C programming language. It is intended for use in embedded systems. INTRODUCTION
  • 4. 08/05/2025 RTOS Mucos It is a very small real-time kernel. Memory footprint is about 20KB for a fully functional kernel. Source code is written mostly in ANSI C. Highly portable, ROMable, very scalable, preemptive real- time, deterministic, multitasking kernel. It can manage up to 64 tasks (56 user tasks available). It has connectivity with μC/GUI and μC/FS (GUI and File Systems for μC/OS II). Features of MicroC/OS-II :
  • 5. 08/05/2025 RTOS Mucos It is ported to more than 100 microprocessors and microcontrollers. It is simple to use and simple to implement but very effective compared to the price/performance ratio. It supports all type of processors from 8-bit to 64-bit. Cont…
  • 6. 08/05/2025 RTOS Mucos µC/OS-II is a multitasking operating system. Each task is an infinite loop and can be in any one of the following five states:  Dormant  Ready  Running  Waiting  ISR (Interrupt Service Routine) Task states:
  • 7. 08/05/2025 RTOS Mucos  Task Feature  Task Creation  Task Stack & Stack Checking  Task Deletion  Change a Task’s Priority  Suspend and Resume a Task  Get Information about a Task Task Management (Services):
  • 8. 08/05/2025 RTOS Mucos  μC/OS-II can manage up to 64 tasks. The four highest priority tasks and the four lowest priority tasks are reserved for its own use. This leaves 56 tasks for applications. The lower the value of the priority, the higher the priority of the task. (Something on the lines of Rate Monotonic Scheduling). The task priority number also serves as the task identifier. Task Feature :
  • 9. 08/05/2025 RTOS Mucos Rate Monotonic Scheduling :  In Rate Monotonic Scheduling tasks with the highest rate of execution are given the highest priority Assumptions:  All tasks are periodic  Tasks do not synchronize with one another, share resources, etc.  Preemptive scheduling is used (always runs the highest priority task that is ready)  Under these assumptions, let n be the number of tasks, Ei be the execution time of task i, and Ti be the period of task i. Then, all deadlines will be met if the following inequality is satisfied: ΣEi / Ti ≤ n(2^1/n – 1)
  • 10. 08/05/2025 RTOS Mucos Rate Monotonic Scheduling : Suppose we have 3 tasks. Task 1 runs at 100 Hz and takes 2 ms. Task 2 runs at 50 Hz and takes 1 ms. Task 3 runs at 66.7 Hz and takes 7 ms. Apply RMS theory… (2/10) + (1/20) + (7/15) = 0.717 ≤ 3(21/3 – 1) = 0.780 Thus, all the deadlines will be met  General Solution?  As n →∞, the right-hand side of the inequality goes to ln(2)=0.6931. Thus, you should design your system to use less than 60-70% of the CPU
  • 12. 08/05/2025 RTOS Mucos There are two functions for creating a task: OSTaskCreate()  OSTaskCreateExt(). Task Creation :
  • 14. 08/05/2025 RTOS Mucos Task Management : After the task is created, the task has to get a stack in which it will store its data.  A stack must consist of contiguous memory locations.  It is necessary to determine how much stack space a task actually uses.  Deleting a task means the task will be returned to its dormant state and does not mean that the code for the task will be deleted. The calling task can delete itself.
  • 15. 08/05/2025 RTOS Mucos If another task tries to delete the current task, the resources are not freed and thus are lost. So the task has to delete itself after it uses its resources Priority of the calling task or another task can be changed at run time. A task can suspend itself or another task, a suspended task can resume itself. A task can obtain information about itself or other tasks. This information can be used to know what the task is doing at a particular time. Task Management (cont…):
  • 16. 08/05/2025 RTOS Mucos The services of Memory management includes: Initializing the Memory Manager. Creating a Memory Partition. Obtaining Status of a Memory Partition. Obtaining a Memory Block. Returning a Memory Block. Waiting for Memory Blocks from a Memory Partition. Memory Management :
  • 17. 08/05/2025 RTOS Mucos Each memory partition consists of several fixed-sized memory blocks. A task obtains memory blocks from the memory partition. A task must create a memory partition before it can be used. Allocation and de-allocation of these fixed-sized memory blocks is done in constant time and is deterministic. Multiple memory partitions can exist, so a task can obtain memory blocks of different sizes. A specific memory block should be returned to its memory partition from which it came. Memory Management :
  • 18. 08/05/2025 RTOS Mucos Clock Tick : A clock tick is a periodic time source to keep track of time delays and time outs. Here, tick intervals varies from 10 ~ 100 ms. The faster the tick rate, the higher the overhead imposed on the system. Whenever a clock tick occurs μC/OS-II increments a 32- bit counter, the counter starts at zero, and rolls over to 4,294,967,295 (2^32-1) ticks. A task can be delayed and a delayed task can also be resumed. Time Management :
  • 19. 08/05/2025 RTOS Mucos It involves five services that includes: OSTimeDLY() OSTimeDLYHMSM() OSTimeDlyResume() OSTimeGet() OSTimeSet() Time Management :
  • 20. 08/05/2025 RTOS Mucos Inter-task or inter process communication in μC/OS takes place using: Semaphores Message mailbox Message queues Tasks and Interrupt service routines (ISR). They can interact with each other through an ECB (event control block). Inter-Task Communication :
  • 21. 08/05/2025 RTOS Mucos Inter-Task Communication : Single task waiting
  • 22. 08/05/2025 RTOS Mucos Inter-Task Communication : Multiple tasks waiting and signaling
  • 23. 08/05/2025 RTOS Mucos Inter-Task Communication : Tasks can wait and signal along with an optional time out
  • 24. 08/05/2025 RTOS Mucos Inter-Task Communication : μC/OS-II semaphores consist of two elements 16-bit unsigned integer count list of tasks waiting for semaphore μC/OSII provides Create, post, pend accept and query services
  • 25. 08/05/2025 RTOS Mucos Inter-Task Communication : μC/OS-II message-mailboxes: an μC/OSII object that allows a task or ISR to send a pointer sized variable (pointing to a message) to another task.
  • 26. 08/05/2025 RTOS Mucos Inter-Task Communication :  μC/OS-II message-queues Available services: Create, Post (FIFO), PostFront (LIFO), Pend, Accept, Query, Flush  N = #of entries in the queue: Queue full if Post or PostFront called N times before a Pend or Accept
  • 27. 08/05/2025 RTOS Mucos Inter-Task Communication : μC/OS-II message-queues organized as circular buffers.
  • 28. 08/05/2025 RTOS Mucos Tasks running under a multitasking kernel should be written in one of two ways: 1. A non-returning forever loop. For example: void Task (void *) { DoInitStuff(); while (1) { do this; do that; do the other thing; call OS service (); // e.g. OSTimeDelay, OSSemPend, etc. } } Writing Applications Under C/OS -II: μ
  • 29. 08/05/2025 RTOS Mucos 2. A task that deletes itself after running. For example: void Task (void *) { do this; do that; do the other thing; call OS service (); // e.g. OSTimeDelay, OSSemPend, etc. OSTaskDelete(); // Ask the OS to delete the task }