1
The Real-Time Operating
System uCOS-II
Enric Pastor
Dept. Arquitectura de Computadors
µC/OS-II Overview
µC/OS-II Overview
µC/OS-II
z Task Management
z Rate Monotonic Scheduling
z Memory Management
µC/GUI
µC/FS
2
Books and Resources
Books and Resources
MicroC/OS-II The Real-Time Kernel Second Edition
z Jean J. Labrosse
z Copy available in Library
MicroC/OS-II e-book (1
st
edition)
z Jean J. Labrosse
z Will be on the course website shortly
µC/OS-II
3
µC/OS - II
µC/OS - II
µC/OS-II is a 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)
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
Task Management – Services
Task Management – Services
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
4
Task Feature
Task Feature
µ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 us with 56
application tasks.
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
Rate Monotonic Scheduling
Rate Monotonic Scheduling
In Rate Monotonic Scheduling tasks with the highest rate
of execution are given the highest priority
Assumptions:
z All tasks are periodic
z Tasks do not synchronize with one another, share
resources, etc.
z Preemptive scheduling is used (always runs the highest
priority task that is ready)
Under these assumptions, let n be the number of tasks, E
i
be the execution time of task i, and T
i
be the period of task
i. Then, all deadlines will be met if the following inequality
is satisfied:
∑E
i
/ T
i
≤ n(2
1/n
–1)
5
Rate Monotonic Scheduling: Example
Rate Monotonic Scheduling: Example
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(2
1/3
– 1) = 0.780
z Thus, all the deadlines will be met
General Solution?
z 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
Process Cycle
Process Cycle