Re: Multitasking 2 Problem

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

Robert Craig wrote:
> 
> Al Getz wrote:
> > After trying the new release i noticed that the task id numbers keep
> > rising, even for the same task, when the task is created a second or
> > more times...
> > 
> >   taskid=task_create(..)
> > 
> > creates say taskid=1, then after the task ends normally if it is
> > created a second time taskid=2, then after that ends a third time
> > produces taskid=3, etc.
> 
> Yes. You can create thousands of tasks that all simultaneously
> run the same routine. These are all different tasks with different
> task id's.
> 
> > I dont have any problem with using different numbers each time, but
> > because they are continuously rising this means eventually the task id
> > could reach max integer and the next create would cause a crash?
> > Unless of course at some limit the numbers start over again?
> 
> When the task id reaches 1e14 (much bigger than an integer), 
> I start over at 1 again, being careful not to issue the 
> same id as one that is still in use. Task id's are atoms, 
> not just integers. Somewhere beyond 1e14 is the point where 
> adding 1 to a number gives you the same number.
> 
> To be squeaky clean, and avoid ever recycling ids, I considered 
> making task id's sequences, which would slowly grow in length, 
> so after reaching 1e14 I could just add another element to the 
> sequence and start over. This would really make it unnecessary 
> to ever recycle ids. However I often have to compare task id's 
> against an internal list, and atoms would be faster. Probably no 
> one will ever exceed 1e14, and if you do, recycling will happen, 
> not a crash. The only theoretical problem is if you are  
> checking the status of a task that died and had its id recycled
> into a new task. You might think the original task was still running.
> 
> Given a machine 1000x faster than the PC's we have today, you might
> be able to create 1e9 tasks per second if you did little else.
> Then it would take 1e5 seconds (more than a day) to reach the 
> point where recycling starts. I just tested now. I can increase 
> the limit from 1e14 to 9e15. That's 90x more capacity. You'd need more
> than 3 months. I guess I'll do that. (There's no point in 
> performing arithmetic on a task id. It's just an identifier.)
> On Linux/Unix etc. I think they start recycling process id's at
> 65000 or so.
> 
> Regards,
>    Rob Craig
>    Rapid Deployment Software
>    <a href="http://www.RapidEuphoria.com">http://www.RapidEuphoria.com</a>
> 

Hello Rob,

Sounds good, and that answered my first question which i was a little
worried about.

My second question is, why do the tasks have to be created over
again after they 'end' normally?  Why cant the task id's be
persistent until the user removes (or kills or whatever) the task?
The reason for asking this is mainly because a "task" will be
a routine (with a routine id) that will remain part of the program
until the process ends, so it would make sense that if it was
declared as a task that it would normally be used as a task until
the program ends.  The only thing that needs to change is if it
is active or not, ie if it should be called or not which i guess
would be done with task_schedule().  If the task ends there's really
no reason to have to change the id is there?  Even with 50 tasks in
a program that would only mean 50 id's issued and that would be that.
If a task 'ended' it would be taken off the active list.  This would
also mean there could never be confusion about a task id belonging
to one task or another because an id would last till programs end,
just like a routine_id.

BTW, the other aspects i've tested so far are the task list and the
task status, and both seem to work just fine.  The two meant i was 
able to eliminate the internal list that previously had to be kept
up by the program itself.  The only unusual thing that came up was
that since many of the tasks i'd be creating have to check the list
to see if any tasks are still running, and of course the task that
checks will be itself running, i was forced to create a function
that checks the list but eliminates itself as a candidate as well
as taskid=0... "AnyOtherTasksActive()".



Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

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

Search



Quick Links

User menu

Not signed in.

Misc Menu