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

Task Suspend & Resume

Posted by akhil on May 9, 2013
hi

I am using FreeRTOS CORTEX_M4F_STM32F407ZG-SK Project for my STM32F4-Discovery board.
I have two tasks i.e, Task1(Priority 4) & Task2(Priority 3)
1. Task1 gives input to the Task2 and goes to suspend state
2. Task2 does some data processing and writes onto SPI and then it resumes Task1.
Above two steps are repeated infinite times(150-200 times in a second).
Issue:
After running it for 2-3hours, found Task1 is giving input to Task2 but Task2 doesn't process the data.
FreeRTOS plugin shows both tasks as suspended.

Can anyone help me on how to debug this issue.

Thanks in advance
akhil

RE: Task Suspend & Resume

Posted by Richard on May 9, 2013
“FreeRTOS plugin shows both tasks as suspended.”


Be careful how you interpret what the plug-in is telling you. The plug-in cannot tell the difference between a task that is actually suspended (in the Suspended state) and a task that is in the Blocked state with an infinite timeout. Therefore if you call a blocking function such as xQueueReceive() and give it a block time of portMAX_DELAY then, if INCLUDE_vTaskSuspend is set to 1 in FreeRTOSConfig.h (which it must be in your case), the plug-in will show the task as being in the Suspended state.

It is almost certain that the task is actually in the Blocked state, not the Suspended state.

Regards.

RE: Task Suspend & Resume

Posted by akhil on May 9, 2013
Thanks for the reply richardbarry,

-> I am not using any FreeRTOS Queue SPIs.
-> I have question:
how can I suspend a task with timeout, something like this...vTaskSuspend(handle,timeout)?

My code template looks like this:
Code Template:
xTaskHandle task1_handle;
xTaskHandle task2_handle;
void *data_pkt = NULL;
void task1_prepare(void *arg)
{
while(1)
{
data_pkt = malloc(1000);
vTaskSuspend(task1_handle);
free(data_pkt);
data_pkt = NULL;
}
}

void task2_process(void *arg)
{
while(1)
{
if(data_pkt!=NULL)
{
/*do some processing like writing onto USART/SPI*/
vTaskResume(task1_handle);
}
else
{
while(1)
printf("input buffer is NULL\n");
|
}
}

RE: Task Suspend & Resume

Posted by akhil on May 9, 2013
sorry,

It is , -> I am not using any FreeRTOS Queue APIs.

RE: Task Suspend & Resume

Posted by Richard on May 9, 2013
I'm not sure why you would be allocating a packet in one task for use by another task - but assume if I saw all your code rather than this snippet it would be more obvious. Also personally I would always try and avoid repeatedly allocating and freeing memory blocks in this way - although heap_4.c would normally make this ok.

There is no suspend with timeout function. For that you would need to use a delay, not a suspend, but then there is no way of another task 'undelaying' as per your unsuspending (resuming). You could probably make the functionality by having the task block on a semaphore with a delay - then the other task can "give" the semaphore to unblock the task if the delay has not expired.

Task suspend and resume are not features I use very often myself. They can be dangerous to use as a synchronisation method because if a task tries to a resume another task that has not yet got to the point of suspending itself then the resume has no effect (and is not latches, as it would be if a semaphore were used instead).

Regards.

RE: Task Suspend & Resume

Posted by akhil on May 9, 2013
Thanks for your inputs,

Actually , Task1 has another job like taking user inputs from USART, before while(1) loop.
and In future I have to create few more tasks and all these tasks will use Task2 to send the data out on USART/SPI.

Anyway, I will try using semaphore once.

Thanks
Akhil


[ 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