Skip to content

Repository files navigation

Learning FreeRTOS (ESP Edition)

This repository contains my practical experiments and learning progression with FreeRTOS using the Arduino IDE. The project consists of .ino sketches designed to explore the fundamental mechanisms of real-time operating systems, from basic task scheduling to utilizing multiple cores and performance monitoring.

📂 Repository Contents

The repository includes four distinct .ino sketches, each focusing on a specific RTOS concept:

1. Two-Task Basics

  • Core Concept: Task creation and basic scheduling.
  • Details: Demonstrates how to create multiple tasks, assign priorities, and understand the FreeRTOS scheduler. It covers the foundational xTaskCreate API and how the OS switches contexts between two active processes running in a loop.

2. Dual-Core Task Execution

  • Core Concept: Symmetric/Asymmetric Multiprocessing (SMP).
  • Details: Explores pinning specific tasks to different processor cores using xTaskCreatePinnedToCore (highly relevant for microcontrollers like the ESP32). Demonstrates true parallel execution and hardware resource management.

3. Task Timing and Deadlines

  • Core Concept: Deterministic execution and blocking delays.
  • Details: Focuses on precise timing using FreeRTOS tick interrupts. It contrasts standard Arduino delay() with FreeRTOS blocking (vTaskDelay and vTaskDelayUntil) to ensure periodic tasks run exactly when they need to without starving the CPU.

4. Basic Runtime Monitor

  • Core Concept: System profiling and debugging.
  • Details: Implements runtime statistics gathering to monitor CPU utilization per task. It utilizes FreeRTOS APIs to analyze performance bottlenecks, check high-water marks for stack memory, and ensure critical processes are healthy.

🛠️ Key Learnings

  • Task Management: Memory allocation for tasks, stack size considerations, and priority-based preemptive scheduling within the Arduino loop.
  • Concurrency: Managing parallel operations across multiple cores without race conditions.
  • Timing Constraints: Designing deterministic systems that meet strict real-time deadlines.
  • Profiling: Measuring system health and debugging resource allocation.

🚀 Getting Started

To run these examples, you will need a microcontroller that supports FreeRTOS and has multiple cores (an ESP32 is highly recommended for the dual-core sketch) and the Arduino IDE.

  1. Clone the repository:
    git clone https://github.com/sxumit/learning-freertos.git

About

A collection of Arduino (.ino) sketches exploring core FreeRTOS concepts like task management, dual-core execution, precise timing, and runtime monitoring.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages