当前位置:网站首页>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)
边栏推荐
- Useful plug-ins for vscode
- 2022G2电站锅炉司炉特种作业证考试题库及答案
- [interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre
- Encryption and decryption
- Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
- Yyds dry goods inventory TCP & UDP
- Simulink and Arduino serial port communication
- Roles of rollup components
- LM small programmable controller software (based on CoDeSys) note XXI: error 3703
- VB.net 简单的处理图片,黑白(类库——7)
猜你喜欢
Unity is connected to the weather system
2022 Guangdong provincial competition - code information acquisition and analysis flag
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
National vocational college skills competition (secondary vocational group) network security competition questions - Analysis
Notes on the paper "cross view transformers for real time map view semantic segmentation"
ping端口神器psping
Electronic components mall and data manual download website summary
《Cross-view Transformers for real-time Map-view Semantic Segmentation》论文笔记
基于单片机的太阳能杀虫系统
Flask
随机推荐
[matlab] general function of communication signal modulation - generation of narrow-band Gaussian white noise
[matlab] matlab simulates digital bandpass transmission systems - QPSK and OQPSK systems
IP时代来临,电竞酒店如何借好游戏的“东风”?
Annex II: confidentiality agreement for offensive and defensive drills docx
LM小型可编程控制器软件(基于CoDeSys)笔记二十一:错误3703
2022 question bank and answers for safety management personnel of hazardous chemical business units
练习-冒泡排序
Just do it with your hands 7 - * project construction details 2 - hook configuration
Zkevm (12) state proof of appliedzkp
Zhongke Panyun - module a infrastructure setting and safety reinforcement scoring standard
Zhongke panyun-d module analysis and scoring standard
With the advent of the IP era, how can E-sports hotels take advantage of the "east wind" of games?
Notepad++--显示相关的配置
Zhongke Panyun - data analysis and forensics packet flag
光模块字母含义及参数简称大全
VB.net 简单的处理图片,黑白(类库——7)
Sécurité du réseau dans les écoles professionnelles secondaires - preuve de mémoire
[matlab] communication signal modulation general function - low pass filter
PostgreSQL has officially surpassed mysql. Is this guy too strong!
ping端口神器psping