Quality RTOS & Embedded Software

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


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 IAR EWARM 6.60.2 STM32F205/STM32L151

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

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

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

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

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

Latest News

Meet us at Embedded World. Hall 3A-525.

Hear from Richard Barry at Embedded World. Feb 28, 16:00, Hall 4-428.

Video: Watch James Gosling & Richard Barry at re:Invent, Las Vegas 2017.

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

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

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