static void task_print(SerialDevice *dev, Task_Handle task)
{
    Task_Stat stat;
    Task_stat(task, &stat);
    const char *name = Task_Handle_name(task);
    const char *mode = "INVALID";
    switch (stat.mode) {
    case Task_Mode_RUNNING: // Task is currently executing
        mode = "RUNNING";
        break;
    case Task_Mode_READY: // Task is scheduled for execution
        mode = "READY";
        break;
    case Task_Mode_BLOCKED: // Task is suspended from execution
        mode = "BLOCKED";
        break;
    case Task_Mode_TERMINATED: // Task is terminated from execution
        mode = "TERMINATED";
        break;
    case Task_Mode_INACTIVE:  // Task is on inactive task list
        mode = "INACTIVE";
        break;
    };
    serial_printf(dev, "%s: %d, %s, stack: %u/%u\r\n", name, stat.priority,
                  mode, stat.used, stat.stackSize);
}
Example #2
0
/*
 *  ======== ThreadSupport_stat ========
 */
Bool ThreadSupport_stat(ThreadSupport_Handle obj, \
    ThreadSupport_Stat* buf, Error_Block* eb)
{
    Task_Stat statbuf;

    Task_stat(Task_self(), &statbuf);
    buf->stackSize = statbuf.stackSize;
    buf->stackUsed = statbuf.used;

    return (TRUE);
}
static void checkStackMetrics(void) {
	static uint16 maxStackUse = 0;

	Task_Stat statbuf; /* declare buffer */
	Task_stat(Task_self(), &statbuf); /* call func to get status */
//	System_printf("\nSTACK METRICS\n");

	if(statbuf.used > maxStackUse){
		maxStackUse = statbuf.used;
	}

	//RESET UNUSED STACK
	uint32 i;

	for(i = 0; i < (statbuf.sp - statbuf.stack)-1 ; i++){ //-1 for safety, don't care warning
		gapRoleTaskStack[i] = 0xBE;
	}


}