Comparison of FreeRTOS Semaphores (Part Five)

Comparison of FreeRTOS Semaphores (Part Five)

Message queues/semaphores/mutexes can be further compared. The following APIs seem well-organized(in fact, their underlying implementations come from the same source~) QueueHandle_t xQueue = xQueueCreate(10, sizeof(int)); // Create a queuexQueueSend(xQueue, &data, portMAX_DELAY); // Send dataxQueueReceive(xQueue, &receivedData, portMAX_DELAY); // Receive data SemaphoreHandle_t xSemaphore = xSemaphoreCreateBinary(); // Create a binary semaphore xSemaphoreGive(xSemaphore); // Release the semaphore xSemaphoreTake(xSemaphore, portMAX_DELAY); … Read more

Understanding the Three Major Task Scheduling Mechanisms in Microcontrollers: Preemptive, Round-Robin, and Coroutines

Understanding the Three Major Task Scheduling Mechanisms in Microcontrollers: Preemptive, Round-Robin, and Coroutines

Here, I will explain these three concepts from a simple and microcontroller engineer’s perspective, ensuring you understand them at a glance. 🚀 1. Preemptive Scheduler Core: Tasks can be “forcefully interrupted”, and the CPU’s control can be taken away by higher priority tasks at any time. âś” Features Uses interrupts + priority to control task … Read more

Native Paradigms of AI Programming (III): Task Scheduling Strategies Driven by Constraints in Embedded Systems

My construction of the concepts of embedded systems and software scheduling began during my doctoral research when I obtained software materials for the Voyager 1 spacecraft through specific channels—this deep-space probe, launched in 1977, is still transmitting data back to Earth. Since 2004, when I led the National 863 Program, high-reliability embedded architecture and scheduling … Read more

C++ Multithreading Magic Guide: Build Your Own Thread Factory

Stop hiring temporary workers on the street; build your own factory. A thread pool is essentially a factory. It employs a fixed number of workers (threads) and continuously receives tasks (work) that these workers will complete in turn. This is the core idea of a thread pool: Instead of hiring a worker for each task … Read more

FreeRTOS Source Code Analysis – Implementation of Linked Lists

FreeRTOS Source Code Analysis – Implementation of Linked Lists In the previous chapter, Embedded Operating System: FreeRTOS Source Code Analysis Part Three – Task Startup and Switching, we officially started tasks. In FreeRTOS, tasks can also be referred to as threads. Next, we will introduce inter-thread synchronization mechanisms (semaphores, mutexes, event groups, etc.) and inter-thread … Read more

Understanding FreeRTOS Porting: Key Insights

In the previous article, “FreeRTOS Porting – Single-Core ARM CM7”, we briefly introduced the process of porting FreeRTOS based on the ARM CM7 core. The overall process is quite simple, summarized as follows:“Download the kernel source and integrated examples from the official website -> Copy the kernel source -> Copy the port files for the … Read more

The Philosophy of ‘Laziness’ in C++ Design

In the realm of programming, C++ stands out with its powerful performance and flexibility. However, within this language that pursues ultimate efficiency lies a seemingly contradictory yet profound wisdom—“laziness“ philosophy. This philosophy is not an excuse for idleness, but a well-considered design strategy that profoundly influences the evolution of modern software architecture and offers significant … Read more

A Quick Start Guide to FreeRTOS

FreeRTOS is a widely used real-time operating system kernel for embedded systems. 1. What is FreeRTOS? Essence: It is an open-source (MIT licensed), configurable real-time operating system (RTOS) kernel. Core Features: Characteristics: Small resource footprint: The kernel itself typically compiles to only 6KB – 12KB of ROM and a few hundred bytes of RAM (depending … Read more

Task Scheduling and Kernel Implementation of FreeRTOS

Task Scheduling and Kernel Implementation of FreeRTOS

This article introduces the tasks and scheduling kernel implementation of FreeRTOS.1. Concept of Tasks In FreeRTOS, a task is the smallest unit of system scheduling and execution. Each task has its own stack space, program counter (PC), registers, and state. Task Stack Spaceis a contiguous memory area that stores local variables, function call information, and … Read more

Switching Tasks in ThreadX RTOS

Switching Tasks in ThreadX RTOS

Using the QEMU simulator to outline the ThreadX task scheduling process.0. Build ExampleCreate Task 0 and Task 1 #include "tx_api.h" #include "tx_thread.h" // Task 0 entry void thread_0_entry(ULONG thread_input){ TX_THREAD *current_thread; thread_0_counter++; TX_THREAD_GET_CURRENT(current_thread); tx_thread_terminate(current_thread); } // Task 1 entry void thread_1_entry(ULONG thread_input){ while(1) { /* Increment the thread counter. */ thread_1_counter++; while(1); }} // Create … Read more