Skip to content

Haibo-S/ARM-Real-Time-Executive

Repository files navigation

RTX Kernel for ARM Cortex-M4

This project presents a lightweight Real-Time Executive (RTX) built for the ARM Cortex-M4 microcontroller. The kernel provides essential facilities for real-time systems: predictable scheduling, dynamic memory support, and a clean system call interface. The design is aimed at exploring the fundamentals of real-time operating system behavior in resource-constrained embedded environments.


Introduction

The RTX kernel coordinates multiple tasks running in parallel, each with its own execution context. It ensures that tasks meet deadlines while keeping CPU utilization efficient. The project demonstrates:

  • A block-based memory allocator using the buddy system.
  • A deadline-aware task scheduler with fallback to an idle task.
  • Supervisor call (SVC) handling for user-to-kernel transitions.

Memory Subsystem

Dynamic memory is managed through a buddy allocation technique. This allows the kernel to split large memory blocks or merge adjacent ones, balancing performance with memory efficiency.

Highlights

  • Memory divided into binary-sized blocks.
  • Free lists track availability across block sizes.
  • Utility functions to translate between addresses, indices, and buddy locations.
  • Allocation (k_mem_alloc) finds the best-fit block, while deallocation (k_mem_dealloc) coalesces free buddies back together.

Design Rationale: Keeps fragmentation low, makes merging quick, and uses metadata for safe deallocation.


Task Handling

Each task is represented by a Task Control Block (TCB) that keeps track of its context, scheduling info, and priority.

Highlights

  • TCB Contents: stack pointer, priority, deadline, and current status.
  • Scheduling Policy: earliest-deadline-first, ensuring critical tasks run in time.
  • Null Task: a fallback task that runs when no others are ready, preventing idle CPU states.
  • Context Switching: saves state of the outgoing task and restores the next scheduled one.

Design Rationale: Keeps execution deterministic and ensures the processor is always active.


System Calls

Privileged operations are exposed through the SVC instruction, which traps into the kernel. This mechanism isolates kernel functions from user tasks.

Highlights

  • SVC Dispatcher: interprets the immediate value in the SVC call and routes to the appropriate handler.
  • Supported Operations: include memory management, task creation, and task switching.

Design Rationale: Modularity for future extensions, and privilege enforcement for system integrity.


Wrap-Up

The RTX kernel developed here provides a compact but capable environment for experimenting with real-time concepts on ARM Cortex-M4. By combining buddy-based memory management, a deadline-driven scheduler, and modular SVC handling, the system offers a practical starting point for embedded developers interested in real-time software.

About

RTX on ARM Cortex-M4

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages