test_tls_deletecb.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include <esp_types.h>
  2. #include <stdio.h>
  3. #include "rom/ets_sys.h"
  4. #include "freertos/FreeRTOS.h"
  5. #include "freertos/task.h"
  6. #include "freertos/semphr.h"
  7. #include "freertos/queue.h"
  8. #include "freertos/xtensa_api.h"
  9. #include "unity.h"
  10. #include "soc/uart_reg.h"
  11. #include "soc/dport_reg.h"
  12. #include "soc/io_mux_reg.h"
  13. static void tskdelcb(int no, void *arg)
  14. {
  15. ets_printf("Delete callback: %d = %p!\n", no, arg);
  16. }
  17. static void tska(void *pvParameters)
  18. {
  19. vTaskSetThreadLocalStoragePointerAndDelCallback(xTaskGetCurrentTaskHandle(), 0, (void *)0xAAAAAAAA, tskdelcb);
  20. while (1) {
  21. vTaskDelay(10000000 / portTICK_PERIOD_MS);
  22. }
  23. }
  24. static void tskb(void *pvParameters)
  25. {
  26. vTaskSetThreadLocalStoragePointerAndDelCallback(xTaskGetCurrentTaskHandle(), 0, (void *)0xBBBBBBBB, tskdelcb);
  27. vTaskDelay(2000 / portTICK_PERIOD_MS);
  28. TaskHandle_t a = (TaskHandle_t)pvParameters;
  29. printf("Killing task A\n");
  30. vTaskDelete(a);
  31. while (1) {
  32. vTaskDelay(10000000 / portTICK_PERIOD_MS);
  33. }
  34. }
  35. // TODO: split this thing into separate orthogonal tests
  36. TEST_CASE("Freertos TLS delete cb", "[freertos]")
  37. {
  38. TaskHandle_t a, b;
  39. xTaskCreatePinnedToCore(tska , "tska" , 2048, NULL, 3, &a, 0);
  40. xTaskCreatePinnedToCore(tskb , "tska" , 2048, a, 3, &b, 0);
  41. // Let stuff run for 20s
  42. vTaskDelay(5000 / portTICK_PERIOD_MS);
  43. printf("Killing task B\n");
  44. //Shut down b
  45. vTaskDelete(b);
  46. }