Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
RT-Thread一般讨论
mutex例子内部数据探索
发布于 2010-02-01 23:16:27 浏览:4162
订阅该版
在RTT上运行的代码如下:(由CalmArrow提供) ``` #include
struct rt_thread thread_mutex1; struct rt_thread thread_mutex2; char thread_mutex1_stack[512]; char thread_mutex2_stack[512]; struct rt_mutex mutex; void thread_mutex1_entry(void *param) { while(1) { rt_kprintf("thread_mutex1: start to take mutex "); rt_mutex_take(&mutex, RT_WAITING_FOREVER); //rt_mutex_take(&mutex, RT_WAITING_FOREVER); rt_kprintf("thread_mutex1: take mutex ok "); rt_kprintf("thread_mutex1: start delay 5s "); rt_thread_delay(500); rt_kprintf("thread_mutex1: delay 5s done "); rt_kprintf("thread_mutex1: release mutex "); rt_mutex_release(&mutex); //rt_mutex_release(&mutex); } } void thread_mutex2_entry(void *param) { while(1) { rt_kprintf("thread_mutex2: delay 1s "); rt_thread_delay(100); rt_kprintf("thread_mutex2: start to take mutex "); rt_mutex_take(&mutex, RT_WAITING_FOREVER); rt_kprintf("thread_mutex2: take mutex ok "); rt_kprintf("thread_mutex2: start delay 10s "); rt_thread_delay(1000); rt_kprintf("thread_mutex2: delay 10s done "); rt_kprintf("thread_mutex2: release mutex "); rt_mutex_release(&mutex); } } void mutex_test(void) { rt_mutex_init(&mutex, "mutext", RT_IPC_FLAG_FIFO); rt_thread_init(&thread_mutex1, "m1", thread_mutex1_entry, RT_NULL, &thread_mutex1_stack[0], sizeof(thread_mutex1_stack), 25, 10); rt_thread_init(&thread_mutex2, "m2", thread_mutex2_entry, RT_NULL, &thread_mutex2_stack[0], sizeof(thread_mutex2_stack), 23, 7); rt_thread_startup(&thread_mutex1); rt_thread_startup(&thread_mutex2); } int rt_application_init() { mutex_test(); return 0; } ``` 注释,如果CalmArrow有时间可以加上一些。
查看更多
3
个回答
默认排序
按发布时间排序
bernard
2010-02-01
这家伙很懒,什么也没写!
再然后是用实时监视工具抓取的内部数据: (可用于系统运行状态的分析,这里的时间精度比较低,直接采用OS Tick,最好是采用32678的定时器精度。) \ | / - RT - Thread Operating System / | \ 0.3.0 build Feb 1 2010 2006 - 2009 Copyright by rt-thread team semaphore objct heap:0x200007d0 attached mutex objct mutext:0x200005a4 attached thread objct m1:0x200000a4 attached timer objct m1:0x200000f4 attached thread objct m2:0x20000124 attached timer objct m2:0x20000174 attached thread objct tidle:0x200005d0 attached timer objct tidle:0x20000620 attached thread_mutex2: delay 1s start timer object:m2 [00000000]switch from:m2 to:m1 thread_mutex1: start to take mutex try to take mutex objct:mutext take mutex objct:mutext thread_mutex1: take mutex ok thread_mutex1: start delay 5s start timer object:m1 [00000000]switch from:m1 to:tidle [00000100]switch from:tidle to:m2 thread_mutex2: start to take mutex try to take mutex objct:mutext [00000100]switch from:m2 to:tidle [00000500]switch from:tidle to:m1 thread_mutex1: delay 5s done thread_mutex1: release mutex put mutex objct:mutext [00000500]switch from:m1 to:m2 take mutex objct:mutext thread_mutex2: take mutex ok thread_mutex2: start delay 10s start timer object:m2 [00000500]switch from:m2 to:m1 thread_mutex1: start to take mutex try to take mutex objct:mutext [00000500]switch from:m1 to:tidle [00001500]switch from:tidle to:m2 thread_mutex2: delay 10s done thread_mutex2: release mutex put mutex objct:mutext thread_mutex2: delay 1s start timer object:m2 [00001500]switch from:m2 to:m1 take mutex objct:mutext thread_mutex1: take mutex ok thread_mutex1: start delay 5s start timer object:m1 [00001500]switch from:m1 to:tidle [00001600]switch from:tidle to:m2 thread_mutex2: start to take mutex try to take mutex objct:mutext [00001600]switch from:m2 to:tidle [00002000]switch from:tidle to:m1 thread_mutex1: delay 5s done thread_mutex1: release mutex put mutex objct:mutext [00002000]switch from:m1 to:m2 take mutex objct:mutext thread_mutex2: take mutex ok thread_mutex2: start delay 10s start timer object:m2 [00002000]switch from:m2 to:m1 thread_mutex1: start to take mutex try to take mutex objct:mutext [00002000]switch from:m1 to:tidle [00003000]switch from:tidle to:m2 thread_mutex2: delay 10s done thread_mutex2: release mutex put mutex objct:mutext thread_mutex2: delay 1s start timer object:m2 [00003000]switch from:m2 to:m1 take mutex objct:mutext thread_mutex1: take mutex ok thread_mutex1: start delay 5s start timer object:m1 [00003000]switch from:m1 to:tidle [00003100]switch from:tidle to:m2 thread_mutex2: start to take mutex try to take mutex objct:mutext [00003100]switch from:m2 to:tidle [00003500]switch from:tidle to:m1 thread_mutex1: delay 5s done thread_mutex1: release mutex put mutex objct:mutext [00003500]switch from:m1 to:m2 take mutex objct:mutext thread_mutex2: take mutex ok thread_mutex2: start delay 10s start timer object:m2 [00003500]switch from:m2 to:m1 thread_mutex1: start to take mutex try to take mutex objct:mutext [00003500]switch from:m1 to:tidle [00004500]switch from:tidle to:m2 thread_mutex2: delay 10s done thread_mutex2: release mutex put mutex objct:mutext thread_mutex2: delay 1s start timer object:m2 [00004500]switch from:m2 to:m1 take mutex objct:mutext thread_mutex1: take mutex ok thread_mutex1: start delay 5s start timer object:m1 [00004500]switch from:m1 to:tidle [00004600]switch from:tidle to:m2 thread_mutex2: start to take mutex try to take mutex objct:mutext [00004600]switch from:m2 to:tidle [00005000]switch from:tidle to:m1 thread_mutex1: delay 5s done thread_mutex1: release mutex put mutex objct:mutext [00005000]switch from:m1 to:m2 take mutex objct:mutext thread_mutex2: take mutex ok thread_mutex2: start delay 10s start timer object:m2 [00005000]switch from:m2 to:m1 thread_mutex1: start to take mutex try to take mutex objct:mutext [00005000]switch from:m1 to:tidle [00006000]switch from:tidle to:m2 thread_mutex2: delay 10s done thread_mutex2: release mutex put mutex objct:mutext thread_mutex2: delay 1s start timer object:m2 [00006000]switch from:m2 to:m1 take mutex objct:mutext thread_mutex1: take mutex ok thread_mutex1: start delay 5s start timer object:m1 [00006000]switch from:m1 to:tidle [00006100]switch from:tidle to:m2 thread_mutex2: start to take mutex try to take mutex objct:mutext [00006100]switch from:m2 to:tidle [00006500]switch from:tidle to:m1 thread_mutex1: delay 5s done thread_mutex1: release mutex put mutex objct:mutext [00006500]switch from:m1 to:m2 take mutex objct:mutext thread_mutex2: take mutex ok thread_mutex2: start delay 10s start timer object:m2 [00006500]switch from:m2 to:m1 thread_mutex1: start to take mutex try to take mutex objct:mutext [00006500]switch from:m1 to:tidle [00007500]switch from:tidle to:m2 总计抓取了10帧。
jiben042
2010-02-02
这家伙很懒,什么也没写!
首先非常感谢bernard版主,及时回答了我的问题,能在百忙之中为我耐心解答,实在让我十分佩服,其次,bernard版主的敬业负责态度让我十分感动,在这里再次感谢bernard版主!!
撰写答案
登录
注册新账号
关注者
0
被浏览
4.2k
关于作者
bernard
这家伙很懒,什么也没写!
提问
414
回答
5948
被采纳
77
关注TA
发私信
相关问题
1
有关动态模块加载的一篇论文
2
最近的调程序总结
3
晕掉了,这么久都不见layer2的踪影啊
4
继续K9ii的历程
5
[GUI相关] FreeType 2
6
[GUI相关]嵌入式系统中文输入法的设计
7
20081101 RT-Thread开发者聚会总结
8
嵌入式系统基础
9
linux2.4.19在at91rm9200 上的寄存器设置
10
[转]基于嵌入式Linux的通用触摸屏校准程序
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
【RT-Thread】【ci】【scons】将ci.attachconfig.yml和scons结合使用
2
Rt-thread中OTA下载后,bootloader不搬程序
3
ulog 日志 LOG_HEX 输出时间改为本地日期时间
4
在RT-Thread Studio中构建前执行python命令
5
研究一了一段时间RTT,直接标准版上手太难,想用nano,但又舍不得组件
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
USB
DMA
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
FAL
rt-smart
I2C_IIC
ESP8266
UART
WIZnet_W5500
ota在线升级
cubemx
PWM
flash
freemodbus
BSP
packages_软件包
潘多拉开发板_Pandora
定时器
ADC
flashDB
GD32
socket
编译报错
中断
Debug
rt_mq_消息队列_msg_queue
SFUD
msh
keil_MDK
ulog
C++_cpp
MicroPython
本月问答贡献
出出啊
1518
个答案
343
次被采纳
小小李sunny
1444
个答案
290
次被采纳
张世争
813
个答案
177
次被采纳
crystal266
547
个答案
161
次被采纳
whj467467222
1222
个答案
149
次被采纳
本月文章贡献
出出啊
1
篇文章
5
次点赞
小小李sunny
1
篇文章
1
次点赞
张世争
1
篇文章
3
次点赞
crystal266
2
篇文章
2
次点赞
whj467467222
2
篇文章
2
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部