Features and Goals of µC/OS – II:
Features of µC/OS-II :
As I mentioned previously, this book contains all the source code for µC/OS-II . I went to a lot of effort to provide you with a high-quality product. You may not agree with some of the style constructs that I use, but you should agree that the code is both clean and very consistent. Many commercial real-time kernels are provided in source form. I challenge you to find any such code that is as neat, consistent, well commented, and well organized as that in µC/OS-II . Also, I believe that simply giving you the source code is not enough. You need to know how the code works and how the different pieces fit together. You will find that type of information in this book. The organization of a real-time kernel is not always apparent when staring at many source files and thousands of lines of code.
Most of µC/OS-II is written in highly portable ANSI C, with target microprocessor-specific code written in assembly language. Assembly language is kept to a minimum to make µC/OS-II easy to port to other processors. Like µC/OS, µC/OS-II can be ported to a large number of microprocessors as long as the microprocessor provides a stack pointer and the CPU registers can be pushed onto and popped from the stack. Also, the C compiler should provide either in-line assembly or language extensions that allow you to enable and disable interrupts from C. µC/OS-II can run on most 8-, 16-, 32-, or even 64-bit microprocessors or microcontrollers and DSPs.All the ports that currently exist for µC/OS can be converted to µC/OS-II in about an hour. Also, because µC/OS-II is upward compatible with µC/OS, your µC/OS applications should run on µC/OS-II with few or no changes.
µC/OS-II was designed for embedded applications. This means that if you have the proper tool chain (i.e., C compiler, assembler, and linker/locator), you can embed µC/OS-II as part of a product.
I designed µC/OS-II so that you can use only the services you need in your application. This means that a product can use just a few µC/OS-II services, while another product can have the full set of features. This allows you to reduce the amount of memory (both RAM and ROM) needed by µC/OS-II on a per-product basis. Scalability is accomplished with the use of conditional compilation. Simply specify (through #define constants) which features you need for your application or product. I did everything I could to reduce both the code and data space required by µC/OS-II .
µC/OS-II is a fully preemptive real-time kernel. This means that µC/OS-II always runs the highest priority task that is ready. Most commercial kernels are preemptive, and µC/OS-II is comparable in performance with many of them.
µC/OS-II can manage up to 64 tasks; however, the current version of the software reserves eight of these tasks for system use. This leaves your application up to 56 tasks. Each task has a unique priority assigned to it, which means that µC/OS-II cannot do round-robin scheduling. There are thus 64 priority levels.
Execution time of all µC/OS-II functions and services are deterministic. This means that you can always know how much time µC/OS-II will take to execute a function or a service. Furthermore, except for one service, execution time of all µC/OS-II services do not depend on the number of tasks running in your application.
Each task requires its own stack; however, µC/OS-II allows each task to have a different stack size. This allows you to reduce the amount of RAM needed in your application. With µC/OS-II's stack-checking feature, you can determine exactly how much stack space each task actually requires.
µC/OS-II provides a number of system services, such as mailboxes, queues, semaphores, fixed-sized memory partitions, time--related functions, and so on.
Interrupts can suspend the execution of a task. If a higher priority task is awakened as a result of the interrupt, the highest priority task will run as soon as all nested interrupts complete. Interrupts can be nested up to 255 levels deep.
Robust and Reliable:
µC/OS-II is based on µC/OS, which has been used in hundreds of commercial applications since 1992. µC/OS-II uses the same core and most of the same functions as µC/OS yet offers more features.
Source Code Conventions:
All µC/OS-II objects (functions, variables, #define constants, and macros) start with OS, indicating that they are related to the Operating System. Functions are found in alphabetical order in all the source code files. This allows you to locate any function quickly.You will find that the coding style I use is very consistent. I have been using the K&R style for many years; however, I have added some of my own enhancements to make the code (I believe) easier to read and maintain. Indention is always four spaces, Tabs are never used, at least one space appears on each side of an operator, comments are always to the right of code, and comment blocks are used to describe functions.