comp.lang.ada
 help / color / mirror / Atom feed
* tasks in queue
@ 2014-10-09 11:57 Stribor40
  2014-10-09 12:14 ` Björn Lundin
  0 siblings, 1 reply; 2+ messages in thread
From: Stribor40 @ 2014-10-09 11:57 UTC (permalink / raw)


In this tutorial http://www.infres.enst.fr/~pautet/Ada95/e_c27_p3.ada

it basically say that tasks are served by FIFO 

"Considering all that we have said so far about tasking, you should understand that all three of these tasks begin execution at the same time and Bill and John both request a hot dog immediately. Since there is only one entry point, only one can be served at a time, and the Ada definition does not specify which will be serviced first. It does specify that both will ultimately be served, so there is an implicit queue at the entry point where requests can be stored until they can be serviced in turn. All requests are serviced on a First In First Out (FIFO) basis with no concern for priority of tasks (to be defined later). This queue is a "hidden" queue as far as you, the programmer, are concerned because you have no access to it. You cannot therefore, sort through the entries and redefine the order of execution of the various entry requests. The attribute named COUNT is available which will return the number of requests pending on any entry queue. Its use will be illustrated in the program named e_c29_p6.ada in chapter 29 of this tutorial."

But this explanation says also "the Ada definition does not specify which will be serviced first".

also if in the main you have something like....

calling .....First_Task
calling..... Second_Task
calling......Third_Task

since this is sequentially executed doesn't that guarantee First_Task will run first?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: tasks in queue
  2014-10-09 11:57 tasks in queue Stribor40
@ 2014-10-09 12:14 ` Björn Lundin
  0 siblings, 0 replies; 2+ messages in thread
From: Björn Lundin @ 2014-10-09 12:14 UTC (permalink / raw)


On 2014-10-09 13:57, Stribor40 wrote:
> 
> But this explanation says also "the Ada definition does not specify which will be serviced first".
> also if in the main you have something like....
> 
> calling .....First_Task
> calling..... Second_Task
> calling......Third_Task
> 
> since this is sequentially executed doesn't that guarantee First_Task will run first?
> 

Well First_Task will be first to start, I think.
But imagine that the scheduler (on a single core machine) stops
First_Task, just after it started, and then gives
Second_Task enough time to complete a full
get-me-food circle.

Then the scheduler changes to the third task and lets it
complete a full circle.

Then First_Task is given attention again, so it could complete its cycle.

You then get Second, Third, and First.


-- 
--
Björn


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-10-09 12:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-09 11:57 tasks in queue Stribor40
2014-10-09 12:14 ` Björn Lundin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox