# Suspend a task from an ISR

**URL:** <https://forums.freertos.org/t/suspend-a-task-from-an-isr/9775>\
**Category:** Kernel\
**Created:** [May 12, 2020, 1:25pm UTC](https://forums.freertos.org/t/suspend-a-task-from-an-isr/9775 "2020-05-12T13:25:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dot\_Pixis](https://avatars.discourse-cdn.com/v4/letter/d/c89c15/32.png) [@Dot\_Pixis](https://forums.freertos.org/u/Dot_Pixis)\
**Post date:** [May 12, 2020, 1:25pm UTC](https://forums.freertos.org/t/suspend-a-task-from-an-isr/9775/1 "2020-05-12T13:25:35Z")

</div>

Hello!  
Is it safe to suspend a task from an Interrupt SubRoutine using vTaskSuspend API function, since vTaskSuspendFromISR is not implemented?  
I’m using FreeRTOS v10.2.1 with Microchip’s PIC18F port on MPLABx IDE.  
Thanks in advance !

---

<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:** [May 12, 2020, 2:21pm UTC](https://forums.freertos.org/t/suspend-a-task-from-an-isr/9775/2 "2020-05-12T14:21:08Z")

</div>

No - it’s not as you already assumed.  
IMHO vTaskSuspend is not the appropriate way of task synchronization anyway.  
It’s usually better to _tell_ a task to do something even if it means to fall asleep (waiting for a wake-up event to resume).

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [May 12, 2020, 2:32pm UTC](https://forums.freertos.org/t/suspend-a-task-from-an-isr/9775/3 "2020-05-12T14:32:10Z")

</div>

You can add your own implementation of vTaskSuspendFromISR() into tasks.c without having to edit the source file by using the task C additions header file [https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/master/tasks.c#L5300](https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/master/tasks.c#L5300) - but as hs2 already mentioned, suspending and resuming tasks from an interrupt is a common source of error. See the note on [https://www.freertos.org/taskresumefromisr.html](https://www.freertos.org/taskresumefromisr.html) for why this is considered dangerous.

---

<div class="post-metadata">

**Author:** ![richard-damon](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/richard-damon/32/38_2.png) [@richard-damon](https://forums.freertos.org/u/richard-damon)\
**Post date:** [May 12, 2020, 2:34pm UTC](https://forums.freertos.org/t/suspend-a-task-from-an-isr/9775/4 "2020-05-12T14:34:08Z")

</div>

I will add that I have NEVER found a case where it was useful for something other than the thread itself to suspend the thread. The biggest problem is you can’t in general know if the Task is currently holding some important resource, unless you know where it is executing, and generally if you know that, it is because it is blocked (or on the way to be blocked) on some resource, at which case you generally don’t need to suspend it.

Using Suspend/Resume as a synchronization mechanism is only really useful in the most simple cases, and is full of ‘gotchas’, and in my mind only useful for the smallest, most resource constrained systems. Much better to use higher level primitives like Direct-to-Task, Semaphores, Queues, Event Groups and the like to synchronize things.
