Mutex Scheduling Mechanism Analysis and Performance Evaluation under the RT-Thread Open Source Framework
A mutex is an important synchronization tool in real-time operating systems (RTOS) used to protect shared resources, ensuring that at any given moment only one thread can access the resource. This prevents race conditions and data conflicts. This paper provides an in-depth analysis of the application scenarios, workflow, and scheduling timing of mutexes in RT-Thread, offering insights and reference points for designing new RTOSs.Using the RT-Thread on the ARM Cortex-M series STM32L431 microcontroller as an example, we designed three threads of equal priority (red light, blue light, green light) to demonstrate how threads request, acquire, use, and release mutexes. This design verifies that using mutexes ensures that threads access shared resources in a sequential and mutually exclusive manner, thereby avoiding issues such as data inconsistency and deadlocks.Furthermore, this paper adopts a process analysis method based on printf output, innovatively utilizing global variables to store timestamps combined with the SysTick timer for time calculation. This approach not only analyzes the response times for locking and unlocking mutexes but also examines the distribution of time during which threads hold the mutex. By effectively reducing the error introduced by the printf function, this method enhances the accuracy of experimental results, providing a new perspective for comprehensively evaluating the performance of mutex scheduling mechanisms.
Authors
- Yihuai Wang (ORCID: https://orcid.org/0000-0003-4215-2179)
- C. T. Sun (ORCID: https://orcid.org/0000-0003-1365-2780)
- Qianglong Dai (ORCID: https://orcid.org/0009-0003-3828-1581)
Institutions
- Suzhou University of Science and Technology (CN)
Publication Details
- Published
- 2025-05-23
- DOI
- https://doi.org/10.1109/ecis65594.2025.11086967
- Primary Topic
- Distributed and Parallel Computing Systems
- Type
- article
- Field-Weighted Citation Impact
- 0.00