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

Signals and Semaphores in FreeRTOS

Signals and Semaphores in FreeRTOS

1. Overview of Signals and Semaphores In FreeRTOS, signals and semaphores are both important mechanisms for inter-task communication (IPC), but they serve different purposes and operate differently. 1.1 Signals • In FreeRTOS, signals refer to task notifications, which are a lightweight signaling mechanism. • Each task has a 32-bit notification value. • Can be used … Read more

Linux Kernel Character Module (Part 3)

Linux Kernel Character Module (Part 3)

Linux Kernel Character Module (Part 3) 1. Atomic Operations Atomic operations are indivisible single-step operations that either complete entirely or do not occur at all in a multi-core/concurrent environment, and cannot be interrupted by other threads. They are used to avoid race conditions and ensure the correctness of concurrent data structures without always using heavyweight … Read more

Concurrency and Race Conditions in Linux

Concurrency and Race Conditions in Linux

Tip: For a better reading experience, it is recommended to read on a PC! 1 What are Concurrency and Race Conditions In Linux systems, concurrency refers to the situation where multiple execution units (processes, threads, interrupts, etc.) access shared resources simultaneously or alternately, while a race condition refers to the uncertain behavior or errors caused … Read more