# Is there an API call (or equivalent) to tell if the scheduler is running?

**URL:** <https://forums.freertos.org/t/is-there-an-api-call-or-equivalent-to-tell-if-the-scheduler-is-running/13039>\
**Category:** Kernel\
**Created:** [July 12, 2021, 4:45pm UTC](https://forums.freertos.org/t/is-there-an-api-call-or-equivalent-to-tell-if-the-scheduler-is-running/13039 "2021-07-12T16:45:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdpoor](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rdpoor/32/929_2.png) [@rdpoor](https://forums.freertos.org/u/rdpoor)\
**Post date:** [July 12, 2021, 4:45pm UTC](https://forums.freertos.org/t/is-there-an-api-call-or-equivalent-to-tell-if-the-scheduler-is-running/13039/1 "2021-07-12T16:45:25Z")

</div>

I have some functions that use FreeRTOS calls if the scheduler is running, and other calls if not.

While I certainly could set a global when I call `vTaskStartScheduler`, is there a reliable way to ask FreeRTOS if its scheduler has been started?

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [July 12, 2021, 4:55pm UTC](https://forums.freertos.org/t/is-there-an-api-call-or-equivalent-to-tell-if-the-scheduler-is-running/13039/2 "2021-07-12T16:55:27Z")

</div>

There is [xTaskGetSchedulerState](https://www.freertos.org/a00021.html#xTaskGetSchedulerState) available if `INCLUDE_xTaskGetSchedulerState` is enabled.

---

<div class="post-metadata">

**Author:** ![rdpoor](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rdpoor/32/929_2.png) [@rdpoor](https://forums.freertos.org/u/rdpoor)\
**Post date:** [July 12, 2021, 5:33pm UTC](https://forums.freertos.org/t/is-there-an-api-call-or-equivalent-to-tell-if-the-scheduler-is-running/13039/3 "2021-07-12T17:33:22Z")

</div>

Perfect – that’s exactly what’s needed. In particular:

```auto
static void bsp_delay_ms(bsp_duration_t ms) {
    if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) {
      delay_ms(ms);
    } else {
      vTaskDelay(pdMS_TO_TICKS(ms));
    }
}

```
