/** * \mainpage Introduction * \author George Fankhauser * * This documentation describes the port of microC/OS-II to the Linux user * space target. As with real hardware, the porting abstraction layer has * been implemented using system and library calls. * * The basic functionality has been implemented to provide all microC/OS-II * services. As the RTOS (Real-Time Operating System) does not provide any * I/O abstractions (driver models etc.) additional funtionality and hardware * interfacing has to be provided by the programmer. * * For demonstration purposes, output functions for a terminal are implemented. * In addition, some of the timing functions found in the DOS/PC examples * have been implemented on Linux to run the demos properly. * * The following screen shots show these examples. Program #1 has been changed * in its appearance. Program #2 has an additional function that fills up one * tasks stack over time. * * \image latex "../doc/ex1.png" "Example #1 from the book running 7 Threads (colorised version)." width=0.75\columnwidth * * \image latex "../doc/book2.png" "Example #2 from the book. This example shows the stack checking feature and measures time for the checking. The example has been modified with a recursive function that fills the stack using random numbers as a parameter. Note Task 4 which runs dangerously low on stack memory." width=0.75\columnwidth * * \image latex "../doc/book3.png" "Example #3 from the book timing some tasks while exchanging messages." width=0.75\columnwidth * * \section details Linux Interaction * * The basic port has been mapped onto Linux signals and is implemented in * os_cpu_c.c; note that there is no assembly file in this port. Some of the * functionality is inlined in os_cpu.h. In other words, there is only one * Linux process (also only one thread) and all the task creation and scheduling * is done by microC/OS-II. * * Signals are delivered on the current tasks stack. OSTCBStkPtr is made * pointing to the ucontext_t structure on the stack for later use. * * - OS_TASK_SW(): The context switching on system calls is implemented using * the Linux kill() syscall which sends the signal SIGUSR1 to itself. * - OSCtxSw(): Switching tasks is done after an interrupt has occured and a * new task becomes ready to run, or, a task voluntarily gives up the CPU. * This function is called by the signal handlers for SIGUSR1 and SIGALRM. * Switching is done by setcontext(). * - OSTickISR() is a standard implementation as described in the book. It * is periodically called by the OSTimeTickSigHandler(). * - OSInitHookBegin(): This hook is used to initialise Linux signals and * handlers. It calls linuxInit() * - linuxInitInt() has to be called by the user in the first task. It starts * the clock ticking. * - OSTaskIdleHook() is either empty, sleeps for some time or sleeps until * the next signal is delivered issuing a select() system call. * - OSTaskStkInit() prepares a ucontext_t structure on the tasks stack and * adjusts the TCBs fields. The SysV calls getcontext() and makecontext() * help with this procedure. * - OSStartHighRdy() restores the proviously made context using setcontext(). * Since this function is used only once it should be replaced by a call * to OSCtxSw in the future. * - OS_CPU_SR: This type is mapped to a sigset_t. It is used to mask and * unmask signals. Since the Linux port employs critical method #3 it is * used throughout the system. * - OS_CRITICAL_METHOD := 3; The Linux port must remember the previous * state of the signal mask. * - OS_ENTER_CRITICAL() is a macro that blocks SIGALRM and SIGUSR1 using * the Linux syscall sigprocmask(). * - OS_EXIT_CRITICAL() restores the previous signal mask. * - OS_TASK_DEF_STK_SIZE: A reasonalbe size on Linux is 2000 words. This is * mainly due to taking signals on the stack. * * * \section ext Extensions using SIGIO * * Adding new virtual devices to this port may be done using a signal handler * for IO related signals from real devices and syscalls. * * For multiple sources, a vectoring table should be implemented. * * * \section lic License * * This port of microC/OS-II may be freely used for personal and educational purposes. * For commercial development contact Sensaco GmbH, http://sensaco.com/en/contact.php, * to obtain a free license and/or support. * * For the basic microC/OS-II license, please contact Micrium Inc. */