/** * Update the status of all tasks */ void TaskMonitorUpdateAll(void) { TaskInfoData data; int n; // Lock xSemaphoreTakeRecursive(lock, portMAX_DELAY); // Update all task information for (n = 0; n < TASKINFO_RUNNING_NUMELEM; ++n) { if (handles[n] != 0) { data.Running[n] = TASKINFO_RUNNING_TRUE; #if defined(ARCH_POSIX) || defined(ARCH_WIN32) data.StackRemaining[n] = 10000; #else data.StackRemaining[n] = uxTaskGetStackHighWaterMark(handles[n]) * 4; #endif } else { data.Running[n] = TASKINFO_RUNNING_FALSE; data.StackRemaining[n] = 0; } } // Update object TaskInfoSet(&data); // Done xSemaphoreGiveRecursive(lock); }
/** * Update the status of all tasks */ void TaskMonitorUpdateAll(void) { #if defined(DIAGNOSTICS) TaskInfoData data; int n; // Lock xSemaphoreTakeRecursive(lock, portMAX_DELAY); #if ( configGENERATE_RUN_TIME_STATS == 1 ) uint32_t currentTime; uint32_t deltaTime; /* * Calculate the amount of elapsed run time between the last time we * measured and now. Scale so that we can convert task run times * directly to percentages. */ currentTime = portGET_RUN_TIME_COUNTER_VALUE(); deltaTime = ((currentTime - lastMonitorTime) / 100) ? : 1; /* avoid divide-by-zero if the interval is too small */ lastMonitorTime = currentTime; #endif // Update all task information for (n = 0; n < TASKINFO_RUNNING_NUMELEM; ++n) { if (handles[n] != 0) { data.Running[n] = TASKINFO_RUNNING_TRUE; #if defined(ARCH_POSIX) || defined(ARCH_WIN32) data.StackRemaining[n] = 10000; #else data.StackRemaining[n] = uxTaskGetStackHighWaterMark(handles[n]) * 4; #if ( configGENERATE_RUN_TIME_STATS == 1 ) /* Generate run time stats */ data.RunningTime[n] = uxTaskGetRunTime(handles[n]) / deltaTime; #endif #endif } else { data.Running[n] = TASKINFO_RUNNING_FALSE; data.StackRemaining[n] = 0; data.RunningTime[n] = 0; } } // Update object TaskInfoSet(&data); // Done xSemaphoreGiveRecursive(lock); #endif }
/** * Update the status of all tasks */ void TaskMonitorUpdateAll(void) { #if defined(DIAG_TASKS) TaskInfoData data; int n; // Lock PIOS_Mutex_Lock(lock, PIOS_MUTEX_TIMEOUT_MAX); uint32_t currentTime; uint32_t deltaTime; /* * Calculate the amount of elapsed run time between the last time we * measured and now. Scale so that we can convert task run times * directly to percentages. */ #if defined(PIOS_INCLUDE_FREERTOS) currentTime = portGET_RUN_TIME_COUNTER_VALUE(); #elif defined(PIOS_INCLUDE_CHIBIOS) currentTime = hal_lld_get_counter_value(); #endif /* defined(PIOS_INCLUDE_CHIBIOS) */ deltaTime = ((currentTime - lastMonitorTime) / 100) ? : 1; /* avoid divide-by-zero if the interval is too small */ lastMonitorTime = currentTime; // Update all task information for (n = 0; n < TASKINFO_RUNNING_NUMELEM; ++n) { if (handles[n] != 0) { data.Running[n] = TASKINFO_RUNNING_TRUE; data.StackRemaining[n] = PIOS_Thread_Get_Stack_Usage(handles[n]); /* Generate run time stats */ data.RunningTime[n] = PIOS_Thread_Get_Runtime(handles[n]) / deltaTime; } else { data.Running[n] = TASKINFO_RUNNING_FALSE; data.StackRemaining[n] = 0; data.RunningTime[n] = 0; } } // Update object TaskInfoSet(&data); // Done PIOS_Mutex_Unlock(lock); #endif }
/** * Update the status of all tasks */ void TaskMonitorUpdateAll(void) { TaskInfoData data; int n; // Lock xSemaphoreTakeRecursive(lock, portMAX_DELAY); // Update all task information for (n = 0; n < TASKINFO_RUNNING_NUMELEM; ++n) { if (handles[n] != 0) { data.Running[n] = TASKINFO_RUNNING_TRUE; #if defined(ARCH_POSIX) || defined(ARCH_WIN32) data.StackRemaining[n] = 10000; #else data.StackRemaining[n] = uxTaskGetStackHighWaterMark(handles[n]) * 4; #if ( configGENERATE_RUN_TIME_STATS == 1 ) /* Generate run time stats */ data.RunningTime[n] = 100 * (float) uxTaskGetRunTime(handles[n]) / portGET_RUN_TIME_COUNTER_VALUE(); #endif #endif } else { data.Running[n] = TASKINFO_RUNNING_FALSE; data.StackRemaining[n] = 0; data.RunningTime[n] = 0; } } // Update object TaskInfoSet(&data); // Done xSemaphoreGiveRecursive(lock); }