当前位置:网站首页>FreeRTOS 中 RISC-V-Qemu-virt_GCC 的 锁机制 分析
FreeRTOS 中 RISC-V-Qemu-virt_GCC 的 锁机制 分析
2022-07-04 05:07:00 【__pop_】
简介
riscv 提供了 atomic 指令扩展 (A)
freertos 也提供了 锁机制,我们看一下这两者是如何揉到一起的
有关概念
MUTEX(互斥量)源于”MUTual EXclusion
竞态
并发会产生竞态
---
我们之前在 https://blog.csdn.net/u011011827/article/details/117690639 中分析过linux的竞态
注意 : 软中断 , 内核抢占 是 linux 独有的概念
freertos 不支持SMP, 所以是单核,单核的竞态原因有两种
1. 中断
2. 调度
而 freertos-riscv 的调度时机有两种
1. 主动调度
2. systick(mtimer) 中断函数中 调度
所以 对于 freertos-riscv 来说 , "关中断" 就是 解决 竞态的 方法
而实际上, freertos 的 "锁机制" 本质上 就是 "关中断",没有用到riscv的原子指令
freertos 锁 API
https://blog.csdn.net/qq_26226375/article/details/123955528
./Source/portable/GCC/RISC-V/portmacro.h
98 /*-----------------------------------------------------------*/
99
100
101 /* Critical section management. */
102 #define portCRITICAL_NESTING_IN_TCB 1
103 extern void vTaskEnterCritical( void );
104 extern void vTaskExitCritical( void );
105
106 #define portSET_INTERRUPT_MASK_FROM_ISR() 0
107 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue
108 #define portDISABLE_INTERRUPTS() __asm volatile( "csrc mstatus, 8" )
109 #define portENABLE_INTERRUPTS() __asm volatile( "csrs mstatus, 8" )
110 #define portENTER_CRITICAL() vTaskEnterCritical()
111 #define portEXIT_CRITICAL() vTaskExitCritical()
112
113 /*-----------------------------------------------------------*/
对该代码实现进行分析, 发现只是关了 中断 (设置 mstatus 中的 MIE 为 1)
边栏推荐
- Download kicad on Alibaba cloud image station
- [matlab] communication signal modulation general function interpolation function
- Flink1.13 basic SQL syntax (II) join operation
- 《Cross-view Transformers for real-time Map-view Semantic Segmentation》论文笔记
- 中科磐云—模块A 基础设施设置与安全加固 评分标准
- Just do it with your hands 7 - * project construction details 2 - hook configuration
- With the advent of the IP era, how can E-sports hotels take advantage of the "east wind" of games?
- The second case analysis of the breakthrough of defense system from the perspective of the red team
- Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
- LM小型可编程控制器软件(基于CoDeSys)笔记二十二:错误4268/4052
猜你喜欢
![How to use postman to realize simple interface Association [add, delete, modify and query]](/img/e9/bf89eacdebcf2ec84c8a08c28b9ca8.png)
How to use postman to realize simple interface Association [add, delete, modify and query]

Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
![[paper summary] zero shot semantic segmentation](/img/78/ee64118d86a7e43ec4d1cb97191fbe.jpg)
[paper summary] zero shot semantic segmentation

中职组网络安全—内存取证

【兴趣阅读】Adversarial Filtering Modeling on Long-term User Behavior Sequences for Click-Through Rate Pre

Void convolution, deformable convolution, deformable ROI pooling

Supplement the JS of a video website to decrypt the video

c语言经典指针和数组笔试题解析

【QT】定时器

2022 t elevator repair operation certificate examination question bank and simulation examination
随机推荐
Zhongke panyun-2022 Guangdong Trojan horse information acquisition and analysis
[matlab] general function of communication signal modulation bandpass filter
PostgreSQL has officially surpassed mysql. Is this guy too strong!
flink1.13 sql基础语法(二)join操作
2022 R2 mobile pressure vessel filling retraining question bank and answers
Build an Internet of things infrared temperature measuring punch in machine with esp32 / rush to work after the Spring Festival? Baa, no matter how hard you work, you must take your temperature first
KMP匹配字符串
JS string splicing
练习-冒泡排序
IP时代来临,电竞酒店如何借好游戏的“东风”?
When using flash to store parameters, the code area of flash is erased, which leads to the interrupt of entering hardware error
中科磐云—2022广东木马信息获取解析
KMP match string
[matlab] communication signal modulation general function interpolation function
Character types of C language
Notepad++ -- display related configurations
ping端口神器psping
如何使用postman实现简单的接口关联【增删改查】
Using jsts in esmodule environment
Redis realizes ranking function