We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ 问题 ] SMP模式下中断与互斥锁同时使用的存在死锁,_cpus_lock死锁
[ 测试版本 ] 主线最新版本
[ 测试BSP ] qemu-vexpress-a9
[ 测试用例 ]
#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <rtthread.h> #include <rthw.h> #define NUM 1000000 #define TASK_NUM 3 static volatile unsigned long long count = 0; static int ac = 0; static rt_mutex_t test_mutex; static void test_thread(void *param) { for (int i = 0; i < NUM; i++) { rt_mutex_take(test_mutex, RT_WAITING_FOREVER); ++count; rt_mutex_release(test_mutex); } printf("count: %llu\n", count); } int main(void) { rt_thread_t threads[TASK_NUM]; test_mutex = rt_mutex_create("test_mutex", RT_IPC_FLAG_PRIO); for (int i = 0; i < TASK_NUM; i++) { char buf[64]; rt_snprintf(buf, sizeof(buf), "test%d", i); threads[i] = rt_thread_create(buf, test_thread, 0, 2048, 20+i, 10u); rt_thread_startup(threads[i]); } while(1) { if (count == (NUM * TASK_NUM)) { printf("finish test...\n"); rt_thread_mdelay(5000); continue; } if (++ac % 5 == 0) { printf("count: %llu\n", count); } rt_thread_mdelay(100); } return 0; }
The text was updated successfully, but these errors were encountered:
看上去更像是调度器的冲突区保护存在问题。
Sorry, something went wrong.
BernardXiong
Guozhanxin
Rbb666
Yaochenger
Successfully merging a pull request may close this issue.
[ 问题 ] SMP模式下中断与互斥锁同时使用的存在死锁,_cpus_lock死锁
[ 测试版本 ] 主线最新版本
[ 测试BSP ] qemu-vexpress-a9
[ 测试用例 ]
以下是目前探索找到的临时的解决办法:
-等待一定时间获取不到锁主动释放
-在互斥锁获取与释放之间添加rt_thread_mdelay
The text was updated successfully, but these errors were encountered: