TuskRTOS is a lightweight, pre-emptive Real-Time Operating System (RTOS) designed specifically for ARM Cortex-M microcontrollers. It offers efficient task management, minimal memory overhead, and a straightforward API for real-time embedded applications. TuskRTOS is intended as an educational project and is not meant for use in production.
Note
This project is still under active development and is not yet ready for to be used.
- Support for ARM Cortex-M4 architectures
- Pre-emptive scheduling.
- Priority scheduling
- Syncronization via Mutexs
- Inter-task communication via semaphores
- Inter-task communication via message queues
- Fixed-Block Memory Pool allocator
To build and run tuskRTOS, you will need:
- ARM Cortex-M microcontroller (e.g., STM32, nRF52, or similar)
- GCC Arm Embedded Toolchain
Clone the repository:
git clone https://gitlab.com/papakonstantinou/tuskRTOS.git
cd tuskRTOS
Use the following command to build:
make
To run the program in QEMU use
make run
And to clean up the build files afterwards run
make clean
Include the tusk header file in your application:
#include "include/tusk.h"Create and initialize tasks:
tusk_init(); // Initializes the scheduler
tusk_create_task(myTaskFunction); // Create a new task
tusk_start(); // Starts scheduler. this function shouldn't return#include "../include/tusk.h" // Scheduler interface
#include "../include/sync.h" // Syncronization OS primitices
#include "../include/serial.h" // Printing to serial
tusk_mutex_t uart_mutex;
void task1_handler(void)
{
while (1) {
tusk_mutex_acquire(&uart_mutex);
serial_print("Task 1: Holding the mutex!\r\n");
tusk_delay(1000); // Hold mutex for 1000 ticks (1 second)
serial_print("Task 1: Releasing the mutex!\r\n");
tusk_mutex_release(&uart_mutex);
tusk_delay(500); // Wait before trying again
}
}
void task2_handler(void)
{
while (1) {
tusk_mutex_acquire(&uart_mutex);
serial_print("Task 2: Got the mutex now!\r\n");
tusk_delay(800); // Hold for 800ms
tusk_mutex_release(&uart_mutex);
tusk_delay(300);
}
}
int main(void)
{
// Initialize hardware (clocks, UART, etc.)
uart_init();
// Initialize the RTOS
tusk_init();
tusk_mutex_init(&uart_mutex);
// Create the tasks
tusk_create_task(task1_handler);
tusk_create_task(task2_handler);
// Start the RTOS scheduler
// This function will not return.
tusk_start();
return 0; // Should never be reached
}
}Contributions are welcome! Please fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.
TuskRTOS is licensed under the MIT License. See LICENSE for more information.