Table of Contents
The OS Library
The OS Library (OSLIB) is an optional set of RTOS features that can be added on top of both RT and NIL kernels.
Introduction
The two kernels are now so compatible that it would have been a waste to duplicate so much code in both code trees. This is why some functionalities, previously part of RT, have now been moved in OSLIB.
From the application perspective it makes no difference if an certain feature is in the kernel or OSLIB so it is purely a source code architectural decision.
Requirements
In OSLIB can be implemented all those features that meet the following requirements:
- Features that only use the common RT and NIL common API.
- Features that cannot be optimized using tricks or details of the underlying RT or NIL kernels.
- Features that are CPU architecture agnostic.
- Features that are compiler agnostic.
- Features that have no dependencies on external modules other than RT or NIL kernels.
Features Summary
This is a list of the features found in the OSLIB, some of which will be detailed in next chapters. Some of the features are quite “high level”, not what you usually find in your average RTOS.
Memory Allocators
Three kind of memory allocators are provided:
- Core Allocator.
- Heap Allocator.
- Pool Allocator.
The above mechanisms were previously in the RT kernel and have been moved into OSLIB.
Binary Semaphores
A variation on the semaphore mechanism with only two internal states, this mechanism was previously in the RT kernel and has been moved into OSLIB.
Mailboxes
Queues of asynchronous messages, this mechanism was previously in the RT kernel and has been moved into OSLIB.
Objects FIFOs
Queues of objects composed by a pool of free object and a mailbox for pointers exchange. It is useful when there is the need to exchange fixed-size objects in a copy-less way.
Pipes
Structure-less streams of bytes exchanged between threads.
Delegate Threads
It is a mechanism that allows to perform function calls in the context of another thread which is acting as a “functions server thread”. Function calls are “delegated” to a dedicated thread which performs the call synchronously.
Jobs Queues
Implements a queue of “jobs” that are consumed and executed by a “jobs server thread” asynchronously. A job is simply a structure containing a function pointer and a pointer argument.
Objects Caches
Implements a cache of fixed-size objects which can be then retrieved by their numeric identifier. It could be used for a disk cache for example.
Objects Factory
A system that allows to allocate other objects dynamically and attribute them a name. Objects can be used by reference, references can be obtained by searching for name.
Notes on Testing
The OSLIB has its own suite of tests, the tests are performed on both RT and NIL host kernels.