You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1022 B

3 years ago
  1. #include "who_trace.h"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include "sdkconfig.h"
  5. #include "freertos/FreeRTOS.h"
  6. #include "freertos/queue.h"
  7. #include "freertos/task.h"
  8. #include "freertos/semphr.h"
  9. #include "esp_system.h"
  10. static void task_trace(void *arg)
  11. {
  12. while (true)
  13. {
  14. int task_num = uxTaskGetNumberOfTasks();
  15. char *buffer = (char *)malloc(task_num * 40 * sizeof(char));
  16. #if CONFIG_FREERTOS_USE_TRACE_FACILITY
  17. printf("TaskList-------------------------------------------------------------------------\n");
  18. vTaskList(buffer);
  19. printf("%s", buffer);
  20. #endif
  21. #if CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
  22. printf("TimeStats------------------------------------------------------------------------\n");
  23. vTaskGetRunTimeStats(buffer);
  24. printf("%s", buffer);
  25. #endif
  26. vTaskDelay(1000 / portTICK_RATE_MS);
  27. free(buffer);
  28. }
  29. vTaskDelete(NULL);
  30. }
  31. void register_trace()
  32. {
  33. xTaskCreate(task_trace, "trace", 3 * 1024, NULL, 5, NULL);
  34. }