Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

How to know the task xTaskHandle?

Posted by Nobody/Anonymous on November 22, 2006
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

RE: How to know the task xTaskHandle?

Posted by Nobody/Anonymous on November 22, 2006
The task handle is returned as a parameter to the task create function.

Look at the file FreeRTOS\Demo\Common\Minimal\dynamic.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().

RE: How to know the task xTaskHandle?

Posted by Nobody/Anonymous on November 22, 2006
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?

RE: How to know the task xTaskHandle?

Posted by Nobody/Anonymous on November 22, 2006
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.

RE: How to know the task xTaskHandle?

Posted by Nobody/Anonymous on November 22, 2006
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();
}
}



[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Careers

FreeRTOS and other embedded software careers at AWS.


Latest News

FreeRTOS kernel V10.0.1 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner