当前位置:网站首页>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)
边栏推荐
- COMP1721 Creating Classes
- [matlab] matlab simulates digital baseband transmission system eye diagram of bipolar baseband signal (cosine roll off forming pulse)
- [interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre
- 中科磐云—模块A 基础设施设置与安全加固 评分标准
- [matlab] matlab simulates digital bandpass transmission system ask, PSK, FSK system
- Flask
- Flink1.13 basic SQL syntax (II) join operation
- Unity2D--人物移动并转身
- Flask
- C language simple student management system (including source code)
猜你喜欢

Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..

Simple g++ and GDB debugging

Just do it with your hands 7 - * project construction details 2 - hook configuration

Detailed comparison of Hynix emmc5.0 and 5.1 series

Customize a pager needed in your project

《Cross-view Transformers for real-time Map-view Semantic Segmentation》论文笔记

Zhongke panyun-d module analysis and scoring standard

Appearance of LabVIEW error dialog box

Electronic components mall and data manual download website summary

2022g2 power station boiler stoker special operation certificate examination question bank and answers
随机推荐
LabVIEW错误对话框的出现
Supplement the JS of a video website to decrypt the video
[paper summary] zero shot semantic segmentation
c语言经典指针和数组笔试题解析
2022G2电站锅炉司炉特种作业证考试题库及答案
2022年R2移动式压力容器充装复训题库及答案
Daily question brushing record (12)
Just do it with your hands 7 - * project construction details 2 - hook configuration
[matlab] matlab simulates digital baseband transmission system eye diagram of bipolar baseband signal (class I part response waveform)
Notepad++--显示相关的配置
We believe that the development of consumer Internet will still be limited to the Internet industry itself
Zkevm (12) state proof of appliedzkp
如何使用postman实现简单的接口关联【增删改查】
中科磐云—模块A 基础设施设置与安全加固 评分标准
[matlab] general function of communication signal modulation Fourier transform
[matlab] matlab simulates digital baseband transmission system eye diagram of bipolar baseband signal (cosine roll off forming pulse)
Flink1.13 SQL basic syntax (I) DDL, DML
小程序毕业设计---美食、菜谱小程序
LM小型可编程控制器软件(基于CoDeSys)笔记二十一:错误3703
Zhongke panyun-2022 Guangdong Trojan horse information acquisition and analysis