PicOS is a real-time multi-tasking micro kernel for embedded system.

Nowadays, micro-controller developing environment has been massively improved. We can use both assembly and C/C++ language in the programs for most micro-processors such as TI DSP and ARM-based SoC. Most of them can run at frequency from 20MHz to 500MHz. It’s time to utilize the powerful advantages of multi-tasking to increase the efficiency of processors.

If an engineer just wants a simple program then micro-kernel is not necessary. But if he wants a program which has several tasks, for example, sampling two audio/video channels, do signal processing, output the result to I/O, handle user interface and, most of important, emergency handling then he has to schedule all these tasks. If the task flow is not sequential then he will get into big trouble for arranging these tasks.

When the speed of optimised C code is fast enough, we don’t need to use Assembly code. When the speed of processor is fast enough, we can spend some CPU time for task scheduling and context switching. This is why I developed such a simple and easy-to-use real-time multi-tasking micro-kernel since 1996.

PicOS, named for Pico Operating System, means a RTOS with very small footprint and good efficiency. Please notice that it is only a real-time kernel. It doesn’t include the file system, window system and others.

Multi-Tasking System Overview

There are three major parts in a micro-kernel: tadk-scheduling, interrupt-handling and inter-process communication.

The hardware timer interrupt (also known as the kernel ticker) will drive the scheduler to schedule tasks. The scheduler will select one of the ready tasks with the highest priority to be the current task. A ready task is a task that is ready to use CPU. A suspended task is a task that has been suspended and will not be scheduled to use CPU.

In industrial applications, real-time processing is very important. Usually, we implement real-time processing by using interrupts. With PicOS, we can register an interrupt handler and then create a task as the bottom half to process soft real-time job. This kind of task can be resumed to run by the corresponding interrupt handler when the associated event occurs. The major advantage is that all other interrupts won’t be disabled (blocked) for long time and we can do mass data processing without worrying about the CPU time used by the task.

The last part is inter-process communication (IPC). In a multi-tasking system, all tasks should communicate with each other by using IPC. PicOS provide several methods for this purpose. A task can send message to other tasks. It can also wait for semaphore event signaled by other tasks. And, mutex is very useful for protecting shared resources.

PicOS Design Principles

PicOS is designed according to the following principles:
  • Understand the CPU hardware structure and take the specific advantages to improve the kernel efficiency. For example, CPU can enter power saving mode while no task is scheduled to use CPU.
  • Hardware layer is designed in assembly code to provide the best efficiency. Upper level is designed in C code to provide the most flexibility.
  • Implement a priority-based, preemptive and time-sliced scheduler.
  • Implement a method for handling interrupts. User doesn’t have to worry about interrupt vector table and interrupt controller. Programmers only need to write a regular function and then register it as the interrupt handler.
  • Implement task message, task timer, semaphore, mutex and mbox mechanism for IPC.
Most of all, PicOS will maintain task scheduling, interrupt handling and IPC for tasks. The major principle of PicOS is to let user quickly plan system architecture and design applications without worrying about scheduling problem. With PicOS, products can be in-time, in-budget and easily maintained.