How to know the task xTaskHandle?

Hi. I wanto to suspend a task with vTaskSuspend and then call vTaskResumeFromISR. My question is: -my task calls some function and in that function there is a call to vTaskSuspend. But how can I now the xTaskHandle of that task in order to suspend it? Best regards, Matias

How to know the task xTaskHandle?

The task handle is returned as a parameter to the task create function. Look at the file FreeRTOSDemoCommonMinimaldynamic.c which contains an example.  Search this file for the variable xContinousIncrementHandle, you will see it is of type xTaskHandle. xContinousIncrementHandle is passed into xTaskCreate by reference.  Following the call to xTaskCreate it contains the task handle. It is then later used in a call to TaskSuspend().

How to know the task xTaskHandle?

Ok, but there is no way to get xTaskHandle from within the current task? Let’s say some function that returns the current task xTaskHandle?

How to know the task xTaskHandle?

In FreeRTOSConfig.h enter: #define INCLUDE_xTaskGetCurrentTaskHandle 1 Then call: xTaskHandle xTaskGetCurrentTaskHandle( void ); from your function. Why do you need this?  If you want to suspend yourself you can just pass in NULL as the parameter.

How to know the task xTaskHandle?

I want to suspend a task with vTaskSuspend, and call vTaskResumeFromISR to resume it from an interrupt. To call vTaskSuspend and vTaskResumeFromISR I think I need to know the xTaskHandle. If I am wrong please explain… Here is what I want do do: static xTaskHandle xHandle; void DoSomething (void) {      // Get resource semaphore with xSemaphoreTake      // I must get the xHandle from current task here…      // Use the xHandle to suspend the created task.      vTaskSuspend( xHandle );           // Release resource semaphore with xSemaphoreGive } void vAnExampleISR( void ) {   portBASE_TYPE xYieldRequired;   // Resume the suspended task.   xYieldRequired = xTaskResumeFromISR( xHandle );   if( xYieldRequired == pdTRUE )   {          portYIELD_FROM_ISR();   } }