Re: Tasks problem

From: Steve (nospam_steved94_at_comcast.net)
Date: 12/20/03


Date: Sat, 20 Dec 2003 03:07:24 GMT

I would probably take a slightly different approach. I would use a
protected object to keep track of the highest number checked.

The tasks would be declared as an array inside of a procedure (after the
protected object).

Each task would get the next number to evaluate from a protected procedure
inside the protected object. The protected procedure would return a number
to evaluate and a flag indicating when all evaluations are done. The tasks
would terminate when there are no new numbers to check. The containing
procedure would return automagically when all tasks in the array are
terminated.

This technique does not use a task to "manage" each of the n tasks, they
essentially manage themselves.

Steve
(The Duck)

"Ratson Janiv" <janiv@013.net.il> wrote in message
news:3fe32ff4$1@news.barak.net.il...
> Hi,
> I have a task T_Check that checks if a number is a prime one.
> I have a task T_Manager that manages the checks.
> In T_Manager I have an array of T_Check(1..N).
>
> Now, lets say I want the T_Manager task to check the numbers 1..100 if
they
> are prime.
> I have only 8 T_Checks tasks (N=6).
> How do I manage the tasks allocations ?
> I thought about T_Manager getting a notification from T_Check when it
> finishes checking, and when T_Manager is notified it shold recall the
Check
> entry in the T_CHeck task that notified it.
> The problem is that I dont know how to know which task (T_Check) amongst
the
> Nth tasks has notified me.
> Is there any solution in ADA?
> Maybe my solution is not so good (Hellllllloooooooooo?), what is the
> solution U may suggest me ?
>
> Thanks a lot,
> Janiv Ratson.
>
>
>



Relevant Pages

  • Re: Differences with/without .all
    ... -- Prefix of protected procedure or entry call must be variable ... Safe, but not an access to procedure. ... S'Result points to a protected object and procedure ... another compiler is fine with the above. ...
    (comp.lang.ada)
  • Re: Ada and (SIGTERM?)
    ... signal and terminate gracefully: did you look at RM C.3? ... me you could set up an interrupt handler to catch SIGTERM and have it ... the variable), then instead of an "infinite" loop, make the loop ... could set a Boolean in the protected object that controls a protected ...
    (comp.lang.ada)
  • Re: array for all tasks
    ... > The first entry set an array size: ... > The other 2 tasks need to use this array. ... But do read about protected object before continuing. ...
    (comp.lang.ada)