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

eTaskGetState reporting

Posted by casper0 on October 11, 2013

I am trying to understand the result reported by eTaskGetState(). In my simplified case I have Task 1 querying the state of Task 2. Task 2 gets put in suspend mode when it is not needed, during which Task 1 is not allowed to do some "thing". But when Task 2 is not suspended, Task 1 'd better do this "thing" or it will go all haywire.

What I have noticed is that when I use eTaskGetState() to check Task 2 for !eSuspended and I know that Task 2 has been resumed, at times Task 2 still reports being suspended. It appears that when I think Task 2 may be blocked, it reports eSuspended instead. The code seems to bear this out, indicating something to the effect that if portMAX_DELAY is used as part of the blocking call, it puts the task into suspend mode--something that causes me to misinterpret its real state.

What's the reason for this? And what's a better way to identify if a task is suspended or not than using a variable in parallel with the suspend and resume calls?

FreeRTOS 7.4.2

Task 1:   while(1) {       ...       if (eTaskGetState(task2_tid) != eSuspended) {         <>       }       ...   }

Task 2:   while(1) {     ...     xSemaphoreTake(semid, portMAXDELAY);     ...   }

Other code:   ...   vTaskSuspend(task2tid);   ...   vTaskResume(task2tid);   ...

 

Casper

eTaskGetState reporting

Posted by edwards3 on October 11, 2013

You are right. If INCLUDEvTaskSuspend is set to 1 in FreeRTOSConfig.h then a task using portMAXDELAY as a block period is placed in the suspended task list. A side effect is what you are observing. The task is not really suspended though.

I think this is documented somewhere, but I've just checked the eTaskGetState() documentation on the web and its not documented there. Maybe I read it in the book.


[ 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