daicheng

ucos系统中怎样查看当前系统 的状态

0
阅读(2660)

1:查看CPU的使用情况

osinit       会创建两个任务。
OS_TaskIdle  空闲任务

#if OS_TASK_STAT_EN > 0  需要将其实设置为1 
OSStatInit(); 统计任务
OS_TaskStat  cpu占用率统计任务。
OSTaskCtr  ---总共创建成功的任务数目。
OSCPUUsage ---cpu占用率/每秒  
OSCtxSwCtr  ---总共任务切换次数 
2:堆栈的检测
堆栈问题:最好比大负荷情况下多出10%到25%,对稳定性要求高情况下,最好*2。
堆栈检查功能需要初始堆栈区为0。OSTaskCreateExt可以执行此操作。
OS_STK_DATA state;
 if (OSTaskStkChk(9, &state) == OS_NO_ERR)
 printf("%4ld  %4ld  %4ld",
         state.OSFree + state.OSUsed,
          state.OSFree,
          state.OSUsed);
3:使用uCOS-View
功能
。The address of the TCB of each task
• The name of each task
• The status (Ready, delayed, waiting on event) of each task
• The number of ticks remaining for a timeout or if a task is delayed
• The amount of stack space used and left for each task
• The percentage of CPU time each task relative to all the tasks
• The number of times each task has been ‘switched-in’
• The execution profile of each task