EmbeddedRelated.com
Forums

Restarting a task in freeRTOS

Started by Nishant Agrawal June 25, 2012
Hi,

Is there a way to restart a task in freeRTOS?

--
With Regards,
Nishant Agrawal


An Engineer's Guide to the LPC2100 Series

>
> Is there a way to restart a task in freeRTOS?
>
Restart it in what sense? You can always delete it an then re-create it.
Regards,
Richard.

+ http://www.FreeRTOS.org
Designed for microcontrollers. More than 7000 downloads per month.

+ http://www.FreeRTOS.org/trace
15 interconnected trace views. An indispensable productivity tool.

> Is there a way to restart a task in freeRTOS?
>> Restart it in what sense? You can always delete it an then re-create it.
I wonder if he is aware of "Suspend/Resume".

Chris.

Dear Richard,

Here is the task routine

static void
_output_control(void *pv_parameters) {
while(1) {
oi.frequency = 0;
vTaskSuspend(NULL);
while(oi.frequency--) {
OUTPUT_ON();
vTaskDelay(oi.on_duration);
OUTPUT_OFF();
vTaskDelay(oi.off_duration);
}
}
}

Now what I want to do is reset the state of this task. So as you said of
deleting and creating the task again, I did that, but with the call to the
process of deleting and creating the task, I also need to make the call to
resume the task, but the task has not been called yet and is not in suspend
state, so the resume call is just lost. Do you have any suggestions on how
I can do that or even make a call to the task after recreating it and
before changing the state to Resume.

And Chris, thanks for letting me know about such a hidden feature in the
OS. You changed my world my friend.
On Tue, Jun 26, 2012 at 7:01 AM, Chris wrote:

> **
> > Is there a way to restart a task in freeRTOS?
> >> Restart it in what sense? You can always delete it an then re-create it.
>
> I wonder if he is aware of "Suspend/Resume".
>
> Chris.
>
>
>

--
With Regards,
Nishant Agrawal,
Design Engineer,
Real Time Solutions Pvt. Ltd.
Ph: +977-1-4253717
Mobile: +977-9841259267
www.rts.com.np


Hi

> Here is the task routine

Which seems buggy !
>
> static void
> _output_control(void *pv_parameters) {
> while(1) {
> oi.frequency = 0;

Sure about the "0" ?

> vTaskSuspend(NULL);
> while(oi.frequency--) {

This loop will never be entered !

> OUTPUT_ON();
> vTaskDelay(oi.on_duration);
> OUTPUT_OFF();
> vTaskDelay(oi.off_duration);
> }
> }
> }

The task is so simple, which state needs to be "restarted" ? After
counting down (given oi.frequency > 0 ) it will be suspended and waiting
for another resume.

--
42Bastian
+
| http://www.sciopta.com
| Fastest direct message passing kernel.
| IEC61508 certified.
+
Dear Bastian,

Yes the task is very simple. But there could be conditions that while the
task is stuck in vTaskDelay routine, new set of information is received
which needs to executed thus the need to restart the task. The line
oi.frequency = 0 was only an attempt to make it work by recreating the task
so will be removed if I find a way to accomplish my requirement.

On Tue, Jun 26, 2012 at 9:45 AM, 42Bastian wrote:

> **
> Hi
> > Here is the task routine
>
> Which seems buggy !
>
> >
> > static void
> > _output_control(void *pv_parameters) {
> > while(1) {
> > oi.frequency = 0;
>
> Sure about the "0" ?
>
> > vTaskSuspend(NULL);
> > while(oi.frequency--) {
>
> This loop will never be entered !
>
> > OUTPUT_ON();
> > vTaskDelay(oi.on_duration);
> > OUTPUT_OFF();
> > vTaskDelay(oi.off_duration);
> > }
> > }
> > }
>
> The task is so simple, which state needs to be "restarted" ? After
> counting down (given oi.frequency > 0 ) it will be suspended and waiting
> for another resume.
>
> --
> 42Bastian
> +
> | http://www.sciopta.com
> | Fastest direct message passing kernel.
> | IEC61508 certified.
> +
>
>
>

--
With Regards,
Nishant Agrawal,
Design Engineer,
Real Time Solutions Pvt. Ltd.
Ph: +977-1-4253717
Mobile: +977-9841259267
www.rts.com.np


Nishant Agrawal,

Just out of curiosity: Is this you: http://csengineersbooks.blogspot.de ??

I will not hope, as this guy does not deserve any serious help from other
engineers.

--
42Bastian
+
| http://www.sciopta.com
| Fastest direct message passing kernel.
| IEC61508 certified.
+
Dear Bastian,

This seriously is not me. This guy is from India, I am from Nepal.

On Tue, Jun 26, 2012 at 10:03 AM, 42Bastian wrote:

> **
> Nishant Agrawal,
>
> Just out of curiosity: Is this you: http://csengineersbooks.blogspot.de ??
>
> I will not hope, as this guy does not deserve any serious help from other
> engineers.
> --
> 42Bastian
> +
> | http://www.sciopta.com
> | Fastest direct message passing kernel.
> | IEC61508 certified.
> +
>
>
>

--
With Regards,
Nishant Agrawal,
Design Engineer,
Real Time Solutions Pvt. Ltd.
Ph: +977-1-4253717
Mobile: +977-9841259267
www.rts.com.np


Hi

> Yes the task is very simple. But there could be conditions that while the
> task is stuck in vTaskDelay routine, new set of information is received

I am pretty sure with FreeRTOS there a blocking system calls which can
wait on events with timeout. This should be used.
These will return either if an event happened (what FRTOS declares an
event) or if the timeout expires.

It is always a bad habit to kill and recreate a task as you cannot know
its current state.

--
42Bastian
+
| http://www.sciopta.com
| Fastest direct message passing kernel.
| IEC61508 certified.
+
Am 26.06.2012 06:29, schrieb Nishant Agrawal:
> Dear Bastian,
>
> This seriously is not me. This guy is from India, I am from Nepal.

Great.

--
42Bastian
+
| http://www.sciopta.com
| Fastest direct message passing kernel.
| IEC61508 certified.
+