Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists