This project implements a primitive real-time operating system (RTOS) for educational purposes. It demonstrates:
- Round-robin scheduling with task delays.
- A basic idle task.
- Semaphore-based synchronization.
- A callback-based message queue with integrated wait and signaling.
- A versatile scheduler that combines round-robin and event-based task unblocking.
include/rtos.h: RTOS API definitions, TCB, Semaphore_t, and function declarations.mq.h: Callback-based message queue API.
src/rtos_kernel.c: Core kernel functions (task creation, yield, delay, and scheduler).rtos_semaphore.c: Semaphore API implementation.mem.c: Custom memory allocator.mq.c: Callback message queue implementation.main.c: Example application with non-dummy tasks.
CMakeLists.txt: CMake build configuration.
- Task Management: Create tasks with their own stacks using a custom allocator.
- Scheduling: Round-robin scheduling with delay support.
- Idle Task: Runs when no other tasks are ready.
- Inter-task Communication:
- Semaphores for basic synchronization.
- Callback-based message queue to publish messages and unblock waiting tasks.
- Primitive IPC: A task can wait for a message, and when a message is published, it is signaled via a callback.
- Install CMake (minimum version 3.10) and a C compiler that supports C11.
- From the project root, create a build directory:
mkdir build && cd build
- Generate build files with CMake:
cmake .. - Build the project:
cmake --build .
After a successful build, run the generated executable (e.g., `SimpleRTOS`):
./SimpleRTOSThe executable demonstrates several tasks:
- A SenderTask that publishes messages.
- A ReceiverTask that waits for and processes messages.
- An OtherTask that performs independent work.
- An idle task runs automatically when no tasks are ready.
- This RTOS is a simplified, educational implementation and is not suitable for production use.
- The context switching uses the POSIX ucontext API and simulates task delays.
- Further enhancements (e.g., advanced context switching in assembly, real hardware interrupt handling) would be needed for a full RTOS.
This project is provided as-is for educational purposes.