Real-Time Operating Systems Programming
A real-time operating system (RTOS) is an operating system intended to serve real-time applications that process data as it comes in, typically without buffer delays.
Processing time requirements are measured in tenths of seconds or shorter increments of time. A real time system is a time bound system which has well defined fixed time constraints.
Processing must be done within the defined constraints or the system will fail. They either are event driven or time sharing. Event driven systems switch between tasks based on their priorities while time sharing systems switch the task based on clock interrupts.
A key characteristic of an RTOS is the level of its consistency concerning the amount of time it takes to accept and complete an application's task; the variability is jitter.
A hard real-time operating system has less jitter than a soft real-time operating system. The chief design goal is not high throughput, but rather a guarantee of a soft or hard performance category.
An RTOS that can usually or generally meet a deadline is a soft real-time OS, but if it can meet a deadline deterministically it is a hard real-time OS.
An RTOS has an advanced algorithm for scheduling. Scheduler flexibility enables a wider, computer-system orchestration of process priorities, but a real-time OS is more frequently dedicated to a narrow set of applications.
Key factors in a real-time OS are minimal interrupt latency and minimal thread switching latency; a real-time OS is valued more for how quickly or how predictably it can respond than for the amount of work it can perform in a given period of time.
See the comparison of real-time operating systems for a comprehensive list. Also, see the list of operating systems for all types of operating systems.
The most common designs are
- Event-driven – switches tasks only when an event of higher priority needs servicing, called preemptive priority, or priority scheduling.
- Time-sharing – switches tasks on a regular clocked interrupt, and on events, called round robin.
Time sharing designs switch tasks more often than strictly needed, but give smoother multitasking, giving the illusion that a process or user has sole use of a machine.
Early CPU designs needed many cycles to switch tasks during which the CPU could do nothing else useful. For example, with a 20 MHz 68000 processor, task switch times are roughly 20 microseconds.
Because of this, early OSes tried to minimize wasting CPU time by avoiding unnecessary task switching.
In typical designs, a task has three states:
- Running executing on the CPU
- Ready to be executed
- Blocked waiting for an event, I/O for example
Most tasks are blocked or ready most of the time because generally only one task can run at a time per CPU. The number of items in the ready queue can vary greatly, depending on the number of tasks the system needs to perform and the type of scheduler that the system uses.
On simpler non-preemptive but still multitasking systems, a task has to give up its time on the CPU to other tasks, which can cause the ready queue to have a greater number of overall tasks in the ready to be executed state.
Table of Content
- The tasks to do in this course
- Introduction to RTOS
- The common RTOS
- The concepts used in RTOS
2. Tasking and Scheduling
- Introduction to Tasking
- The status of the task
- Create a new task
- The priority of the task
- Delete the task
- Scheduler for task
3. Queue Management
- Introduction to Queue
- Using the queue
- Get the data into the queue
- Create a mailbox from the queue
4. Timer Sofware Management
- Introduction to Timer Sofware
- Features and status of Timer Software
- The context of Timer Software
- Create a Timer Software
- Change the cycle of Timer Software
- Restart the Timer Software
5. Interrupt Management
- Use RTOS in interrupts
- Delayed the interrupt
- Use Semaphore Binary
- Use queues in the interrupt
6. Resource Management
- The need to manage resources
- Pause multitasking in critical situations
- Using Mutex
- Use Gatekeeper for tasks
7. Events Management
- Introduction to Event
- Characteristics of an Event Group
- Using Event Groups
- Task Synchronization Using an Event Group
8. Task Notifications
- Introduction to Task Notifications
- Benefits and Limitations
- Using Task Notifications
9. Basic project: RTOS for MCUs
- How to use RTOS in Arduino
- Compile RTOS source code for MCU
- Programming of practical examples
- Programming RTOS for Atmega AVR
- Programming RTOS for Microchip PIC
10. Advanced Project: RTOS for 32-bit ARM MCU
- Introduction to STM32F4xx ARM Cortex-M4
- Install tools and software RTOS
- Programming examples for STM32F4xx
- Introduction to NXP ARM Cortex M3
- Programming examples for NXP ARM Cortex M3