I've long wanted to know more about how a Real-Time Operating System (RTOS) performs its magic. The book muC/OS-III - The Real-Time Kernel explains all...
I just re-read µC/OS-III - The Real-Time Kernel by Jean Labrosse, which – I believe – provides a fantastic introduction to Real-Time Operating Systems.
Now, just to make sure we're all tap-dancing to the same drum beat, let's take a step back and set the scene. It's possible to create a simple computer program that can be executed directly on a microprocessor or microcontroller. More usually, we run a special piece of software called an Operating System (OS), which is responsible for coordinating resources and managing any application-level programs running on the machine.
In the case of a general-purpose operating system, there is no guarantee that anything will happen at a particular time. If you launch your web browser, for example, it may appear on your screen almost immediately or (depending on what other tasks the operating system is currently juggling) it may take a few seconds. Although this is often somewhat frustrating, we learn to live with it.
But now consider something like an industrial controller in charge of a production line. When a sensor detects something happening in the real world, it may be required for the operating system to do something NOW! In order to address this, we have the concept of a Real-Time Operating System (RTOS) – such a beast guarantees to respond to external stimuli in a certain amount of time.
Of course the above is a gross simplification. We might have large numbers of different tasks, each with their own priority level (some tasks may share the same priority), so the OS has to manage these tasks, along with scheduling, synchronization, message passing, switching, interrupts, resources, memory... and all sorts of "stuff".
And so we come to µC/OS-III (pronounced "Micro-C, O-S Three"), which is a state-of-the-art, scalable, ROMable, pre-emptive real-time kernel that manages an unlimited number of tasks. µC/OS-III is a third-generation kernel that offers all of the services expected from a modern real-time kernel, such as resource management, synchronization, inter-task communications, and more. Furthermore, µC/OS-III offers many unique features that are not found in other real-time kernels, such as the ability to complete performance measurements at run-time, to directly signal or send messages to tasks, to achieve pending on multiple kernel objects, and more.
This is actually a really interesting story. When he was a young engineer, the author – Jean Labrosse – was tasked with working on the design of a microprocessor-based ignition control system for a large industrial reciprocating engine. He had a choice between using an expensive RTOS that had served him well in the past or employing a much cheaper RTOS that he'd not used before.
Due to a tight budget, Jean initially decided to go with the cheap-and-cheerful version. The result was disastrous; even the simplest applications would not run and Jean spent most of his days on the phone to technical support. Eventually he "bit the bullet" and turned to the more expensive system. Everything was going great until a new bug was discovered; when Jean reported it, he was informed that his 90-day warranty had expired. Worse yet... even after Jean had forked over the maintenance fee, the vendor took a further six months to actually fix the problem.
I can only imagine the frustration. Determined that this wasn't going to happen to him again, Jean developed his own RTOS from the ground up. Known as µC/OS, this little scamp (the RTOS, not Jean) quickly grew in popularity, and developers around the world started using it in a wide variety of applications.
Sometime later, Jean developed µC/OS-II, a commercial-grade RTOS that meets the highest safety-critical requirements for use in applications such as industrial control environments, medical systems, and even aircraft. More recently, Jean and his team at Micriµm – the company he founded in 1999 – have introduced µC/OS-III, which extends the capabilities of its predecessors and provides the features and capabilities required by even the most demanding of applications.
In fact, this is two books in one. The first book turns the spotlight on real-time kernels and real-time operating systems, with µC/OS-III used as a reference. The second book provides worked examples that run on the evaluation board that accompanies the book. Speaking of which, this evaluation board – the uC/Eval-STM32F107 – is a thing of beauty. Designed by Micrium and STMicroelectronics, this board features the STMicroelectronics STM32F107 connectivity microcontroller.
The uC/Eval-STM32F107 Evaluation Board that accompanies the book.
At the heart of the STM32F107 is an ARM Cortex-M3 CPU. The STM32F107 runs at clock frequencies up to 72 MHz and contains such high-performance peripherals as a 10/100 Ethernet MAC, a full-speed USB OTG ("On-The-Go") controller, CAN controller, timers, UARTs, 256 Kbytes of Flash Memory, 64 kbytes of high-speed SRAM, and much, much more...
Meanwhile, in addition to the STM32F107 CPU, the uC/Eval-STM32F107 evaluation board includes an Ethernet connector, an on-board J-Tag debugger, a SD memory card socket, a USB OTG connector, a RS-232 connector, a temperature sensor, LEDs, an expansion connector, and a prototyping area. Also, you can download the entire development environment (compiler, linker, loader, debugger, etc.) and use it for free for the purposes of learning how to use the RTOS and creating and playing with experimental applications (you have to purchase licenses as soon as you start to develop something you plan to deploy as a commercial product).
The combo of the µC/OS-III book and the uC/Eval-STM32F107 evaluation board costs $199.95. This certainly isn’t peanuts but – in this case – I think it is well worth the price. Using this combo, you can teach yourself everything you need to know about how an RTOS works and how to create applications that run under the RTOS. Having said this, it should be noted that this book is not targeted at absolute beginners – readers need to have a good understanding of microprocessors and microcontrollers and C programming.
All-in-all I am very, VERY impressed, and have no hesitation in recommending this book to anyone wanting to know more about the inner machinations of real-time operating systems.