/** * * @brief Returns runtime of a thread. * * @param[in] threadp pointer to instance of @p struct pios_thread * * @return runtime in milliseconds * */ uint32_t PIOS_Thread_Get_Runtime(struct pios_thread *threadp) { #if (INCLUDE_uxTaskGetRunTime == 1) return uxTaskGetRunTime((xTaskHandle)threadp->task_handle); #else return 0; #endif /* (INCLUDE_uxTaskGetRunTime == 1) */ }
/** * 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) { 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); }