CTL_ERROR_NO_TASKS_TO_RUN
Hi,
I have started a simple ctl_task sample where I have added a LED_task to toggle a LED. When I have toggled the LED, I have used the code "ctl_timeout_wait(ctl_get_current_time()+100);" to wait before toggling again. When the wait function is called, the code ends up in the ctl_handle_error function with e = CTL_ERROR_NO_TASKS_TO_RUN. Is the main_task created with ctl_task_init not surposed to be some sort of idle_task to run when others aren't? Or have i missed a detail in the ctl_task system?
Best regards
Casper
-
As a follow-up, the CTL_ERROR_NO_TASKS_TO_RUN error was being caused by my delay function (WaitMS) being called before threads are started. I added code to detect that and do a "manual" wait in that case:
void WaitMS(int nMS)
{
if(ctl_task_list[0].next == NULL)
{
// If no other tasks are running, need to do a manual wait
DWORD dwTicksEnd;
dwTicksEnd = GetTickCount() + nMS; // Timer ISR must be running for this to work.
while(!IsTimeoutExpired(dwTicksEnd))
ResetCPUWatchDog();
}
else
{
// Otherwise, use the CTL wait to allow other tasks to immediately run
ctl_timeout_wait(ctl_get_current_time()+nMS);
}
}That's resolved the issue, but question still stands: can I simple return ctl_handle_error() if this error occurs? Assuming, of course, the code that caused it can handle the immediate resumption of execution.
Thanks,
Paul -
Hi Michael,
Thanks for the quick reply. Based on my testing, appears the answer is yes, but I'll take a look at the sources and see. The modification of my wait function above solves the immediate issue and prevents the error from happening, so at this point it's more of an intellectual question than a practical one.
Thanks for your help!
Paul
Please sign in to leave a comment.
Comments
7 comments