FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [May 2013 Threads] Task Suspend & ResumePosted 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 & ResumePosted 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 & ResumePosted 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 & ResumePosted by akhil on May 9, 2013 sorry,
It is , -> I am not using any FreeRTOS Queue APIs.
RE: Task Suspend & ResumePosted 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 & ResumePosted 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
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|