Re: Task API question

new topic     » goto parent     » topic index » view thread      » older message » newer message

Rob,

I think you are right, the current behavior is better. When the contrary 
behavior is needed, some simple code at the end of the top level will 
keep the top level code from ending. For example:

while 1 do
    task_kill(0)
    task_yield()
end while

the infinite loop prevents the opRETURNT from executing, but killing 
task 0 stops the loop after 1 iteration.

--  Mike Nelson

Robert Craig wrote:

>
>
>posted by: Robert Craig <rds at RapidEuphoria.com>
>
>Michael Nelson wrote:
>  
>
>>I have also noted that when the end of the top level code is reached the 
>>program terminated even if there are other task active besides task 0. 
>>Is this the desired behavior? Task 0 can be killed or suspended without 
>>terminating the program, should the code for opRETURNT be modified to 
>>check for other active tasks?
>>
>>I could argue the case either way and I can program around if quite 
>>easily with my new lib.
>>    
>>
>It's a good point.
>If the top-level code reaches the end, I think it will be
>more convenient for most people if the whole program 
>simply ends at that point. It will be the same effect as  
>executing an abort(). In the code I've worked with, you might
>have some dangling tasks, some of which are actually infinite
>tasks that wait for work to be given to them. It might
>be a bit of a bother for the top-level task to have to
>go through all these tasks and kill them. People might frequently
>forget to do this, and then be surprised that their program
>is "hanging" indefinitely (due to a task that has not died).
>If the top-level task does need to let some other tasks finish,
>it could check their status, or perhaps some global variables, 
>and not terminate until they are all done.
>
>Regards,
>   Rob Craig
>   Rapid Deployment Software
>   http://www.RapidEuphoria.com
>
>
>
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu