In-Depth Analysis of Linux Lock Mechanisms: From Principles to Practice

In-Depth Analysis of Linux Lock Mechanisms: From Principles to Practice

In-Depth Analysis of Linux Lock Mechanisms: From Principles to Practice 1 Overview of Linux Lock Mechanisms In the field of concurrent programming, lock mechanisms are the cornerstone technology for ensuring data consistency and operation atomicity in multi-threaded and multi-tasking environments. As a complex modern operating system, Linux needs to manage resource sharing issues in multi-processor … Read more

Understanding Guard and Deref in Rust

Guard <span>Guard</span> is a common concept in Rust, meaning “to guard”. What does it guard? It guards resources, data, etc., within a specific scope. For example, the guards for mutexes and read-write locks are: β€’ <span>MutexGuard</span> β€’ <span>RwLockReadGuard</span> and <span>RwLockWriteGuard</span> They are an implementation of RAII (Resource Acquisition Is Initialization), a resource management technique from … Read more

Bilibili C++ Interview: Differences Between Mutex and Spin Lock, and Their Use Cases

Bilibili C++ Interview: Differences Between Mutex and Spin Lock, and Their Use Cases

In multithreaded programming, synchronization mechanisms are essential for ensuring safe access to shared resources.Mutexes and Spin Locks, as the two most classic types of locks, are widely used in various systems and frameworks.This article will comprehensively analyze the differences between the two from the perspectives of underlying implementation principles, waiting strategy differences, performance overhead analysis, … Read more

Understanding Priority Inversion in FreeRTOS: What Is It and How to Solve It?

Understanding Priority Inversion in FreeRTOS: What Is It and How to Solve It?

Imagine a scenario in a busy office building waiting for an elevator: Low-Priority Person: A visitor in no hurry (low-priority task) enters the elevator and presses a button for a high floor. Medium-Priority Person: At this moment, a manager in a hurry for a meeting (medium-priority task) also enters the elevator. High-Priority Person: Suddenly, the … Read more

Resource Management in FreeRTOS

Resource Management in FreeRTOS

Resource Management Problem: When a task is using a resource and is preempted before it has finished using it, the resource may be left in an incomplete or corrupted state. If another task or interrupt tries to access this resource at that time, it can lead to data corruption or processing errors. That is why … Read more

FreeRTOS Semaphores Explained

FreeRTOS Semaphores Explained

Semaphores Cover generated by Nano Banana 🍌🍌🍌 Using<span><span>binary semaphores</span></span> allows deferring tasks (tasks with high processing load and time consumption) in an interrupt to be completed in a processing (synchronization) task, ensuring that ISR() executes quickly. If the task in the interrupt is very urgent, it can be set to the highest priority, allowing the … Read more

Embedded Linux: Why Is Thread Synchronization Necessary?

Embedded Linux: Why Is Thread Synchronization Necessary?

Click the aboveblue text to follow us The core purpose of thread synchronization is to ensure that multiple threads can operate on shared resources in an expected manner, preventing data inconsistency issues. Shared resources refer to variables or data structures that multiple threads may read or modify simultaneously. For example, if there is a global … Read more

FreeRTOS ‘Phantom Deadlock’! System Randomly Freezes Driving the Entire Team Crazy, Finally Resolved with Priority Inheritance + SystemView

FreeRTOS 'Phantom Deadlock'! System Randomly Freezes Driving the Entire Team Crazy, Finally Resolved with Priority Inheritance + SystemView

Intelligent Terminal Control System, “Mysterious Freeze” After Running for Several Hours We developed an intelligent gateway based on STM32 + FreeRTOS for a client, featuring: Multithreaded tasks: sensor data collection, CAN communication, UI refresh, log writing Using mutexes to protect shared resources (such as LCD, Flash, serial port) Priority design was reasonable (or so we … Read more

Resource Management in FreeRTOS

Resource Management in FreeRTOS

Scan to FollowLearn Embedded Together, learn and grow together The FreeRTOS introductory series aims to help beginners quickly get started and master the basic principles and usage of FreeRTOS while organizing knowledge. FreeRTOS Quick Start – Exploring the System FreeRTOS Official Chinese Website is Now Live FreeRTOS Coding Standards and Data Types FreeRTOS Quick Start … Read more

FreeRTOS Queue Module (Part 2)

FreeRTOS Queue Module (Part 2)

The Queue in real-time operating systems (RTOS) such as FreeRTOS is a very important communication mechanism, mainly used for 1. Inter-Process Communication (IPC) and data transfer between tasks and interrupts.2. It can perform task synchronization and resource management. General queues can protect and utilize resources by implementing semaphores and mutexes.This article, as the second part … Read more