some questions on co-routine
Posted by choren lin
on August 6, 2008
My version is v4.2.1,
1. What are the differences between a co-routine and a task?
What is the meaning that a co-routine really is?
I know an app can include several tasks or several co-routines, or the mixture. But how to decide that when to use a co-routine rather than a task?
2. Is it right that a task can not be access to a queue created by a co-routine? Or, a co-routine can not be access to a queue created by a task.
I think that it is right because there is not a serial of routines to implement it in FreeRTOS. Beside, if a task can be
access to a co-routine queue. It is possible that the co-routine queue will suspends the task, if that happens, then how to
order the event list in the queue? The result is that the queue can not order the task from co-routines, because the priority of the task is essentially different from that of a co-routine.
Is my understanding right?
3. Does a co-routine 'that run by the idle_task_hook' use the stack of idle task?
I think it does. Because a co-routine can be treated as a part of idle task, and it just is a normal subroutine in the body of idle task.
4. A high priority task interrupts the running co-routine, then the task finishes and the idle task gets the CPU again. Will
the idle task run at the interrupted point within the co-routine? And will the registers resume?
I think it will. Because co-routine is just a part of idle task.
5. Will the content resume , when a co-routine previously suspened itself but now it is running again?
I think the content can not resume, and the registers maybe change. Because the implement of a co-routine suspending itself is different from that of a task, a co-routine suspends itself just exit from a 'for(;;)' loop. When the co-routine is entered again, it will start to run from the top, not the suspended point.
Is that above right?
Expecting for your answer!
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.