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] [August 2009 Threads] vTaskSuspend() how to use correctPosted by Peter on August 19, 2009 Hi, i would like to create a task suspended but it seems, that FreeRTOS does not have such a feature?!. So i've tried to create a task suspended... But strangely even if i suspended a task, on scheduler start the task runs... (The defines for vTaskSuspend are enabled)
xTaskHandle xTest1Task;
prvSetupHardware(); res = xTaskCreate( prvTest1Task, "Test1Tsk", 410, NULL, 4, &xTest1Task); vTaskSuspend(xTest1Task); vTaskStartScheduler();
Strangely the task is being started. But the following works:
void prvTest1Task(void * pvParameters) { while(1) { vTaskSuspend(); // we idle here until someone resumes us... {...} }
xTaskHandle xTest1Task; prvSetupHardware(); res = xTaskCreate( prvTest1Task, "Test1Tsk", 410, NULL, 4, &xTest1Task); vTaskStartScheduler();
And strangely the following will not work:
void prvTest1Task(void * pvParameters) { while(1) { vTaskSuspend(); // we idle here until someone resumes us... {...} }
xTaskHandle xTest1Task; prvSetupHardware(); res = xTaskCreate( prvTest1Task, "Test1Tsk", 410, NULL, 4, &xTest1Task); vTaskSuspend(xTest1Task); vTaskStartScheduler();
Kind regards, Peter
RE: vTaskSuspend() how to use correctPosted by MEdwards on August 19, 2009 In tasks.c find the implementation of vTaskSuspend(). At the bottom of the function you will see the line if( ( void * ) pxTaskToSuspend == NULL ). Change this to
if( (( void * ) pxTaskToSuspend == NULL )&&(xSchedulerRunning != pdFALSE) )
Then in main() create the task then use the task handle as the parameter to vTaskSuspend().
xTaskCreate( prvTest1Task, "Test1Tsk", 410, NULL, 4, &xTest1Task); vTaskSuspend(xTest1Task); //other code goes here. vTaskStartScheduler().
RE: vTaskSuspend() how to use correctPosted by Peter on August 20, 2009 Hi Edward, thanks for the idea - because otherwise the the task is being YIELDed before the scheduler has been started. Unfortunately the solution does not work. Do you have any idea? (Iam not that deep into that, yet). Thanks in advance, Peter
RE: vTaskSuspend() how to use correctPosted by Ben on August 20, 2009 If just use the following to suspend a task when it first runs, and then resume it when needed from another task.
void TaskA( void *pvParameters ) { vTaskSuspend( NULL );
while(1) {
} }
RE: vTaskSuspend() how to use correctPosted by Peter on August 20, 2009 Hi Ben, yes you are right! That was also my idea, but i've found that way not that beautiful ;-)
Kind regards, Peter
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|