Microc/OS-II

  • Authors:
  • Jean J. Labrosse

  • Affiliations:
  • -

  • Venue:
  • Microc/OS-II
  • Year:
  • 1998

Quantified Score

Hi-index 0.00

Visualization

Abstract

From the Book:This book describes the design and implementation of µC/OS-II (pronounced "Micro C O S 2"), which stands for MicroController Operating System Version 2. µC/OS-II is based on µC/OS, The Real-Time Kernel that was first published in 1992. Thousands of people around the world are using µC/OS in all kinds of applications, such as cameras, medical instruments, musical instruments, engine controls, network adapters, highway telephone call boxes, ATM machines, industrial robots, and more. Numerous colleges and universities also have used µC/OS to teach students about real-time systems.   µC/OS-II is upward compatible with µC/OS V1.11 but provides many improvements, such as the addition of a fixed-sized memory manager; user-definable callouts on task creation, task deletion, task switch, and system tick; TCB extensions support; stack checking; and much more. I also added comments to just about every function, and I made µC/OS-II much easier to port to different processors. The source code in µC/OS was placed in two files. Because µC/OS-II contains many new features and functions, I decided to split µC/OS-II into a few source files to make the code easier to maintain.   If you currently have an application that runs with µC/OS, it should run virtually unchanged with µC/OS-II . All of the services (i.e., function calls) provided by µC/OS have been preserved. You may, however, have to change include files and product build files to "point" to the new filenames.   This book contains all the source code for µC/OS-II and a port for the Intel 80x86processor running in real mode and for the large model. The code was developed on a PC running the Microsoft Windows 95 operating system. Examples run in a DOS-compatible box under the Windows 95 environment. Development was done using the Borland International C/C++ compiler V3.1. Although µC/OS-II was developed and tested on a PC, µC/OS-II was actually targeted for embedded systems and can be ported easily to many different processor architectures. µC/OS-II Features Source Code   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. Portable   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. Check for the availability of ports on the µC/OS-II Web site at www.uCOS-II.com. ROMable   µ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. Scalable   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 . Preemptive    µ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. Multitasking    µ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. Deterministic   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. Task Stacks   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. Services    µC/OS-II provides a number of system services, such as mailboxes, queues, semaphores, fixed-sized memory partitions, time--related functions, and so on. Interrupt Management   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. Figures, Listings, and Tables Convention You will notice that when I reference a specific element in a figure, I use the letter "F" followed by the figure number. The number in parenthesis following the figure number represents a specific element in the figure that I am trying to bring your attention to. F1.2(3) thus means look at the item numbered "3" in Figure 1.2. Listings and tables work exactly the same way except that a listing starts with the letter "L" and a table with the letter "T". 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.   Table 1 provides the acronyms, abbreviations, and mnemonics (AAMs) used in this book. I combine some of these AAMs to make up function, variable, and #define names in a hierarchical way. For example, the function OSMboxCreate() reads like this: the function is part of the operating system (OS), it is related to the mailbox services (Mbox), and the operation performed is to Create a mailbox. All services that have similar operation share the same name. For example, OSSemCreate() and OSMboxCreate() perform the same operation, but on their respective objects (i.e., semaphore and mailbox, respectively).