Quality RTOS & Embedded Software

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


Loading

Reset Task

Posted by Nobody/Anonymous on May 10, 2006
Hey,

I have a question...

Is it possible to reset a task?

For example:

if i have the task like this

static portTASK_FUNCTION( vLightsTask, pvParameters )
{

initSomeThings();<----- RESART HERE

for(;;)
{
switch(light_algorithm)
{
CASE (flash_fast):
TurnLightsOn();
vTaskDelay(1000);<-------------- HERE
TurnLightsOff();
vTaskDelay(1000);
break;
CASE (flash_slow)
TurnLightsOn();
vTaskDelay(9000);
TurnLightsOff();
vTaskDelay(9000);
break;
}
}
}


This task is running and it currently is a delay.

From another function i want to be able to resart the task, so it would remove it from the delay and start over.

I guess i could delete the task and then re-create it but i thought this might take too long, is there another way

If i am not making sense let me know and i will try and explain.

Cheers

Murray

RE: Reset Task

Posted by Nobody/Anonymous on May 10, 2006
Just some more background on what i am doing.

I have 1 task that implements about 8 different LED flashing algorithms.

I have a global varible that indicated that algorithm is currently set.

This varible is check in the task and then the LED algorithm is executed.

I have a function that is called to set the current algorithm,
If this function is called i want the task to stop what it is doing and start the new algorithm.

Currently it has to wait 1 cycle before it starts the new one.

Would i be better looking a using co-routines, 1 for each LED algorithm.

Cheers

RE: Reset Task

Posted by John W. on May 10, 2006
Hello,

Have you looked at the API functions:

vTaskSuspend() and vTaskResume()?

Can't you do what you want with these?
There's also a tickHook() that can
be implemented.

HTH,
John W.

RE: Reset Task

Posted by Nobody/Anonymous on May 10, 2006
How about, instead of blocking using a delay, block on a queue read. Then if you want to change algorithms during the delay you wake the task by posting to the queue. The task recognises it has been woken before the end of the delay by the xQueueRead return value.

You could even get rid of the global variable then and post the algorithm that should be run on the queue.

RE: Reset Task

Posted by Nobody/Anonymous on May 11, 2006
yeah the suspend and resume doesn't do what i want. IF i suspend the task, then resume it, it contines from where it was, thus still executing the complete cycle.

The queue read sounds like a possibility. I will have a think about that a little more. Thanks


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




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

Latest News

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