* dynamically create tasks @ 2014-10-11 1:49 compguy45 2014-10-11 2:20 ` Shark8 ` (2 more replies) 0 siblings, 3 replies; 9+ messages in thread From: compguy45 @ 2014-10-11 1:49 UTC (permalink / raw) If you have one task body and would like to create 5 of these tasks since there is one task body there will only be one task created plus main task....how would you create 20 tasks with same body? is there way to do this? ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: dynamically create tasks 2014-10-11 1:49 dynamically create tasks compguy45 @ 2014-10-11 2:20 ` Shark8 2014-10-11 5:53 ` Niklas Holsti 2014-10-11 6:01 ` Simon Wright 2 siblings, 0 replies; 9+ messages in thread From: Shark8 @ 2014-10-11 2:20 UTC (permalink / raw) On 10/10/2014 7:49 PM, compguy45@gmail.com wrote: > If you have one task body and would like to create 5 of these > tasks since there is one task body there will only be one > task created plus main task....how would you create 20 tasks > with same body? > > is there way to do this? Yes; it's essentially what I do in my solution to the No-Connection puzzle on Rosetta-code. ( See: http://rosettacode.org/wiki/Solve_the_no_connection_puzzle#Ada ) The Idea is that the tasks are fed a list of possible numbers and a state (usu. inherited from prior tasks which create them dynamically) -- if the given state cannot be a solution, its task simply ends otherwise there are two options (1) the state is a complete board [that is, the puzzle is solved], OR (2) the task creates a task for every possible number which can be in the next position. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: dynamically create tasks 2014-10-11 1:49 dynamically create tasks compguy45 2014-10-11 2:20 ` Shark8 @ 2014-10-11 5:53 ` Niklas Holsti 2014-10-11 13:02 ` compguy45 2014-10-11 6:01 ` Simon Wright 2 siblings, 1 reply; 9+ messages in thread From: Niklas Holsti @ 2014-10-11 5:53 UTC (permalink / raw) On 14-10-11 04:49 , compguy45@gmail.com wrote: > If you have one task body and would like to create 5 of these > tasks since there is one task body there will only be one task > created plus main task....how would you create 20 tasks with same body? > is there way to do this? > Use task types. Instead of saying task My_Own_Task is ... end My_Own_Task; say task type My_Own_Task is ... end My_Own_Task; The "task body" part stays the same. Then you can create as many tasks as you like, of this type, using what looks like a normal variable declaration: Thinker, Doer, Builder, Painter : My_Own_Task; and now all these tasks are running. You can also create arrays of tasks in the normal way, " ... array ( ... ) of My_Own_Task", you can have access types for tasks and use "new My_Own_Task", and so on. (However, I would suffix task-type names with "_T", just as I do for other types, so I would write My_Own_Task_T for the task-type name.) Note that when you use a task type and have several tasks with the same body, there must be some way for each task to know what *it* should do; all tasks should of course not do exactly the same thing. One way is to add an entry to each task and call these entries to give different parameters to each task; another way is for each task to call some central task or protected object to get their different parameters. You can also give the task type discriminants that tell each task what to do; that may be useful if you create tasks dynamically (wth "new"). -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ . ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: dynamically create tasks 2014-10-11 5:53 ` Niklas Holsti @ 2014-10-11 13:02 ` compguy45 2014-10-11 14:51 ` Dmitry A. Kazakov 0 siblings, 1 reply; 9+ messages in thread From: compguy45 @ 2014-10-11 13:02 UTC (permalink / raw) Yes thats what i am confused about lots of tasks same body ? I have to dinamucally create tasks and then first tasks will get called by main. Then first tasks will call that same entry on tasks 2. Then task 2 will call same entry on task 3. Then when last task is called task n then it will go all the wayback to task 1 (which waited all this time) which will now know thats all tasks have been notified ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: dynamically create tasks 2014-10-11 13:02 ` compguy45 @ 2014-10-11 14:51 ` Dmitry A. Kazakov 2014-10-11 16:34 ` compguy45 0 siblings, 1 reply; 9+ messages in thread From: Dmitry A. Kazakov @ 2014-10-11 14:51 UTC (permalink / raw) On Sat, 11 Oct 2014 06:02:07 -0700 (PDT), compguy45@gmail.com wrote: > Yes thats what i am confused about lots of tasks same body ? I have to > dinamucally create tasks and then first tasks will get called by main. > Then first tasks will call that same entry on tasks 2. Then task 2 will > call same entry on task 3. Then when last task is called task n then it > will go all the wayback to task 1 (which waited all this time) which will > now know thats all tasks have been notified Or you signal a pulse event to notify all tasks at once. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: dynamically create tasks 2014-10-11 14:51 ` Dmitry A. Kazakov @ 2014-10-11 16:34 ` compguy45 2014-10-11 17:29 ` Ludovic Brenta 2014-10-11 18:52 ` Brad Moore 0 siblings, 2 replies; 9+ messages in thread From: compguy45 @ 2014-10-11 16:34 UTC (permalink / raw) I cant. I have to sync it using entries. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: dynamically create tasks 2014-10-11 16:34 ` compguy45 @ 2014-10-11 17:29 ` Ludovic Brenta 2014-10-11 18:52 ` Brad Moore 1 sibling, 0 replies; 9+ messages in thread From: Ludovic Brenta @ 2014-10-11 17:29 UTC (permalink / raw) compguy45@gmail.com writes: > I cant. I have to sync it using entries. Sounds like homework assignment. -- Ludovic Brenta. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: dynamically create tasks 2014-10-11 16:34 ` compguy45 2014-10-11 17:29 ` Ludovic Brenta @ 2014-10-11 18:52 ` Brad Moore 1 sibling, 0 replies; 9+ messages in thread From: Brad Moore @ 2014-10-11 18:52 UTC (permalink / raw) On 14-10-11 10:34 AM, compguy45@gmail.com wrote: > I cant. I have to sync it using entries. > There are a number of unknown requirements here. Are the tasks to be dynamically created on the stack, or on the heap? Can the sync be by task entries, or by protected object entries? How does a task determine which one is the next to be signalled? Can the tasks be in an array, and an incrementing array index be used to determine the next one, or does the task need to be linked more dynamically, such as by a linked list of tasks? I presume this is a homework assignment, and that the exercise is to involve only task entry calls, and that otherwise the other details are left to the student. An interesting solution would be one that lets you arbitrarily hook individual tasks together that are created either dynamically on the stack (as a task declaration), or dynamically from the heap (via the new keyword). For this, I'd suggest having a Connect task entry that accepts an access type for the task as a parameter. entry Connect (Next_Task : T_Access); This can be used to connect the tasks together in a circular list. Then another entry to Signal a task, and another that the main task can call to wait for the initial Signalled task to accept once the initially signalled task has signalled by the previous task in the task ring. eg. entry Signal; entry Wait_For_All_Tasks; Good luck. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: dynamically create tasks 2014-10-11 1:49 dynamically create tasks compguy45 2014-10-11 2:20 ` Shark8 2014-10-11 5:53 ` Niklas Holsti @ 2014-10-11 6:01 ` Simon Wright 2 siblings, 0 replies; 9+ messages in thread From: Simon Wright @ 2014-10-11 6:01 UTC (permalink / raw) compguy45@gmail.com writes: > If you have one task body and would like to create 5 of these tasks > since there is one task body there will only be one task created plus > main task....how would you create 20 tasks with same body? is there > way to do this? task type T is ... end T; Tasks : array (1 .. 20) of T; ... task body T is ... end T; See ARM 9.1(2), vs single_task_declaration, (3). ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-10-11 18:52 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-10-11 1:49 dynamically create tasks compguy45 2014-10-11 2:20 ` Shark8 2014-10-11 5:53 ` Niklas Holsti 2014-10-11 13:02 ` compguy45 2014-10-11 14:51 ` Dmitry A. Kazakov 2014-10-11 16:34 ` compguy45 2014-10-11 17:29 ` Ludovic Brenta 2014-10-11 18:52 ` Brad Moore 2014-10-11 6:01 ` Simon Wright
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox