当前位置:网站首页>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)
边栏推荐
- Write a complete answer applet (including single choice questions, judgment questions and multiple topics) (III) single choice questions, judgment questions, and the first question display
- Integer type of C language
- [QT] create mycombobox click event
- 简易零钱通
- Headache delayed double deletion
- [matlab] matlab simulation modulation system - VSB system
- Encryption and decryption
- Graduation design of small programs -- small programs of food and recipes
- 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
- [matlab] matlab simulation - low pass Gaussian white noise
猜你喜欢
Public inputs in appliedzkp zkevm (13)
Solar insect killing system based on single chip microcomputer
模拟小根堆
Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
Daily question brushing record (12)
Trie数-字典树
Integer type of C language
2022年T电梯修理操作证考试题库及模拟考试
Notes on the paper "cross view transformers for real time map view semantic segmentation"
[high concurrency, high performance and high availability of massive data MySQL practice-7] - memory data drop disk
随机推荐
Integer type of C language
Rollup各组件作用
Annex 2-2 confidentiality commitment docx
2022G2电站锅炉司炉特种作业证考试题库及答案
Letter meaning and parameter abbreviation of optical module Daquan
光模块字母含义及参数简称大全
Get the ID of the record just inserted from laravel
COMP1721 Creating Classes
Nodejs learning document
Ping port artifact psping
Unity2D--人物移动并转身
2022 a special equipment related management (elevator) examination questions simulation examination platform operation
[matlab] communication signal modulation general function - low pass filter
How to build your own knowledge engine? Community open application
[matlab] matlab simulation modulation system - DSB system
A summary of the 8544 problem that SolidWorks Standard cannot obtain a license
2022 t elevator repair operation certificate examination question bank and simulation examination
Error response from daemon: You cannot remove a running container 8d6f0d2850250627cd6c2acb2497002fc3
Trie数-字典树
Detailed comparison of Hynix emmc5.0 and 5.1 series