共2条
1/1 1 跳转至页
RAM 我怎么知道一个任务占用了多少RAM空间
问
我用LPC2220,现做一个程序老是出错,好象是缓冲区溢出,操作系统用的是UC/OS2 ,编译用ADS1。2,我怎么查看一个任务占用了多少RAM?在UC/OS2中局部变量是不是使用的任务建立起来的缓冲区???
答 1: 可以用可以调试操作系统的调试软件啊据说MICETEK的JEDIVIEW可以调试操作系统,去问一下 答 2: 参考邵贝贝的书4.3堆栈检验OSTaskStkChk() 答 3: look Uart0SendSTR("版本V1.0\r\n");
i = OSTimeGet()/100;
Uart0SendSTR("系统连续运行:");
Uart0SendNUM(i/3600,0,0);
i %= 3600;
Uart0SendSTR("小时");
Uart0SendNUM(i/60,0,0);
Uart0SendSTR("分");
Uart0SendNUM(i%60,0,0);
Uart0SendSTR("秒\r\n");
Uart0SendSTR("CPU利用率:");
Uart0SendNUM(OSCPUUsage,0,0);
Uart0SendSTR("%\r\n");
Uart0SendSTR("任务 总堆栈 空闲栈 运行态\r\n");
Uart0SendSTR("---- ------ ------ ------\r\n");
for(i = 0;i < OS_LOWEST_PRIO+1; i ++)
{
err = OSTaskQuery(i,&task_data);
if(err != OS_NO_ERR) continue;
if(i == 2) continue;
Uart0SendSTR((char *)task_name[i]);
Uart0SendSTR("\t\t");
err = OSTaskStkChk(i,&task_stk);
if(err != OS_NO_ERR) continue;
Uart0SendNUM(task_stk.OSFree+task_stk.OSUsed,0,0);
Uart0SendSTR("\t\t");
Uart0SendNUM(task_stk.OSFree,0,0);
Uart0SendSTR("\t\t");
err = task_data.OSTCBStat;
if(err == OS_STAT_RDY) Uart0SendSTR("就绪");
else if(err == OS_STAT_SEM) Uart0SendSTR("等信号量");
else if(err == OS_STAT_MBOX) Uart0SendSTR("等邮件");
else if(err == OS_STAT_Q) Uart0SendSTR("等消息队列");
else if(err == OS_STAT_SUSPEND) Uart0SendSTR("挂起");
else if(err == OS_STAT_MUTEX) Uart0SendSTR("等互斥量");
else if(err == OS_STAT_FLAG) Uart0SendSTR("等标志");
Uart0SendSTR("\r\n");
}
Uart0SendSTR("64B内存块剩余:");
err = OSSemQuery(mem64_sem,&mem_sem);
Uart0SendNUM(mem_sem.OSCnt,0,0);
Uart0SendSTR("\r\n");
Uart0SendSTR("256B内存块剩余:");
err = OSSemQuery(mem256_sem,&mem_sem);
Uart0SendNUM(mem_sem.OSCnt,0,0);
Uart0SendSTR("\r\n");
Uart0SendSTR("512B内存块剩余:");
err = OSSemQuery(mem512_sem,&mem_sem);
Uart0SendNUM(mem_sem.OSCnt,0,0);
Uart0SendSTR("\r\n");
Uart0SendSTR("1KB内存块剩余:");
err = OSSemQuery(mem1024_sem,&mem_sem);
Uart0SendNUM(mem_sem.OSCnt,0,0);
Uart0SendSTR("\r\n");
Uart0SendSTR("^_^\r\n");
答 1: 可以用可以调试操作系统的调试软件啊据说MICETEK的JEDIVIEW可以调试操作系统,去问一下 答 2: 参考邵贝贝的书4.3堆栈检验OSTaskStkChk() 答 3: look Uart0SendSTR("版本V1.0\r\n");
i = OSTimeGet()/100;
Uart0SendSTR("系统连续运行:");
Uart0SendNUM(i/3600,0,0);
i %= 3600;
Uart0SendSTR("小时");
Uart0SendNUM(i/60,0,0);
Uart0SendSTR("分");
Uart0SendNUM(i%60,0,0);
Uart0SendSTR("秒\r\n");
Uart0SendSTR("CPU利用率:");
Uart0SendNUM(OSCPUUsage,0,0);
Uart0SendSTR("%\r\n");
Uart0SendSTR("任务 总堆栈 空闲栈 运行态\r\n");
Uart0SendSTR("---- ------ ------ ------\r\n");
for(i = 0;i < OS_LOWEST_PRIO+1; i ++)
{
err = OSTaskQuery(i,&task_data);
if(err != OS_NO_ERR) continue;
if(i == 2) continue;
Uart0SendSTR((char *)task_name[i]);
Uart0SendSTR("\t\t");
err = OSTaskStkChk(i,&task_stk);
if(err != OS_NO_ERR) continue;
Uart0SendNUM(task_stk.OSFree+task_stk.OSUsed,0,0);
Uart0SendSTR("\t\t");
Uart0SendNUM(task_stk.OSFree,0,0);
Uart0SendSTR("\t\t");
err = task_data.OSTCBStat;
if(err == OS_STAT_RDY) Uart0SendSTR("就绪");
else if(err == OS_STAT_SEM) Uart0SendSTR("等信号量");
else if(err == OS_STAT_MBOX) Uart0SendSTR("等邮件");
else if(err == OS_STAT_Q) Uart0SendSTR("等消息队列");
else if(err == OS_STAT_SUSPEND) Uart0SendSTR("挂起");
else if(err == OS_STAT_MUTEX) Uart0SendSTR("等互斥量");
else if(err == OS_STAT_FLAG) Uart0SendSTR("等标志");
Uart0SendSTR("\r\n");
}
Uart0SendSTR("64B内存块剩余:");
err = OSSemQuery(mem64_sem,&mem_sem);
Uart0SendNUM(mem_sem.OSCnt,0,0);
Uart0SendSTR("\r\n");
Uart0SendSTR("256B内存块剩余:");
err = OSSemQuery(mem256_sem,&mem_sem);
Uart0SendNUM(mem_sem.OSCnt,0,0);
Uart0SendSTR("\r\n");
Uart0SendSTR("512B内存块剩余:");
err = OSSemQuery(mem512_sem,&mem_sem);
Uart0SendNUM(mem_sem.OSCnt,0,0);
Uart0SendSTR("\r\n");
Uart0SendSTR("1KB内存块剩余:");
err = OSSemQuery(mem1024_sem,&mem_sem);
Uart0SendNUM(mem_sem.OSCnt,0,0);
Uart0SendSTR("\r\n");
Uart0SendSTR("^_^\r\n");
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |