comp.lang.ada
 help / color / mirror / Atom feed
* Policies In Ada
@ 1997-05-07  0:00 Stephen Cox
  1997-05-08  0:00 ` Robert Dewar
  1997-05-19  0:00 ` scott
  0 siblings, 2 replies; 5+ messages in thread
From: Stephen Cox @ 1997-05-07  0:00 UTC (permalink / raw)



Hello!

Does anybody have any small examples of implementing a policy system in
Ada?

Also, I have implemented two tasks with the same priority i.e. they both
have pragma priority(0); in their declaration yet only the first task seems
to execute. Any ideas?

Thanks,

Stephen Cox




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

* Re: Policies In Ada
  1997-05-07  0:00 Policies In Ada Stephen Cox
@ 1997-05-08  0:00 ` Robert Dewar
  1997-05-19  0:00 ` scott
  1 sibling, 0 replies; 5+ messages in thread
From: Robert Dewar @ 1997-05-08  0:00 UTC (permalink / raw)



Stephen Cox says

<<Also, I have implemented two tasks with the same priority i.e. they both
have pragma priority(0); in their declaration yet only the first task seems
to execute. Any ideas?>>

yes, I have an idea. My idea is that your Ada compiler is working exactly
as expected. The required dispatching policy FIFO_Within_PRiorities is
required to run-till-blocked. It is permissible, but certainly not required
that the default dispatching policy behave the same way.

if you are expecting time slicing, then (a) your expectation may simply
not be implemented on the compiler you are using, since it is not required
and (b) your application is significantly non-portable!





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

* Re: Policies In Ada
  1997-05-07  0:00 Policies In Ada Stephen Cox
  1997-05-08  0:00 ` Robert Dewar
@ 1997-05-19  0:00 ` scott
  1997-05-20  0:00   ` Samuel A. Mize
  1 sibling, 1 reply; 5+ messages in thread
From: scott @ 1997-05-19  0:00 UTC (permalink / raw)



In article 190000c2@Stephen.ers.ie, "Stephen Cox" <stephen@ers.ie> () writes:
>Also, I have implemented two tasks with the same priority i.e. they both
>have pragma priority(0); in their declaration yet only the first task seems
>to execute. Any ideas?

This could be a feature of your OS.
I know that VxWorks has same-priority tasks execute until
suspended [ie. no multi-tasking with like-priority tasks]
unless Round-Robin scheduling has explicitly been turned
on [via kernelTimeSlice() routine].

Scott

---
Hughes Aircraft Co./Raytheon/whatever/?		voice:	(310) 616-1059
Sensors and Communications Systems Segment
PO Box 902, EO/E01/A172, El Segundo, Ca. 90245





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

* Re: Policies In Ada
  1997-05-19  0:00 ` scott
@ 1997-05-20  0:00   ` Samuel A. Mize
  1997-05-25  0:00     ` Robert Dewar
  0 siblings, 1 reply; 5+ messages in thread
From: Samuel A. Mize @ 1997-05-20  0:00 UTC (permalink / raw)
  To: scott


scott@tcville.es.hac.com wrote:
> 
> In article 190000c2@Stephen.ers.ie, "Stephen Cox" <stephen@ers.ie> () writes:
> >Also, I have implemented two tasks with the same priority i.e. they both
> >have pragma priority(0); in their declaration yet only the first task seems
> >to execute. Any ideas?
> 
> This could be a feature of your OS.

This depends on whether Stephen is using Ada 83 or 95, and
if Ada 95 on whether it supports Annex D.

** Assuming Stephen is using Ada 95 with support for Annex D **
it's a feature of the default task dispatching policy
("FIFO_Within_Priorities").  Tasks run until they hit a
"task dispatching point" -- a same-priority task CAN'T
interrupt the current task.  To get time-slicing, you must
use a Task_Dispatching_Policy pragma (AND the compiler
must support a time-slicing policy, which is not required).

Task dispatching points include delay statements (including a
delay 0.0), completion of an accept statement, when a
higher-priority task becomes ready -- these are examples,
there are others.  If your tasks are loops, you can put a
"delay 0.0" into both loops, and they should both get to run.

But don't just take this as a cookbook approach -- read and
understand ARM section D.2.

** If it's an Ada 95 compiler but doesn't support Annex D **
you get pot luck for task dispatching policy.  However,
FIFO_Within_Priorities is still likely because it's easier
to build than time-slicing.

** For Ada 83 **
I don't remember the rules for same-priority tasks (if any).

Samuel Mize

--
-- Samuel Mize           (817) 619-8622               "Team Ada"
-- Hughes Training Inc.  PO Box 6171 m/s 400, Arlington TX 76005




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

* Re: Policies In Ada
  1997-05-20  0:00   ` Samuel A. Mize
@ 1997-05-25  0:00     ` Robert Dewar
  0 siblings, 0 replies; 5+ messages in thread
From: Robert Dewar @ 1997-05-25  0:00 UTC (permalink / raw)



Samuel said

  <<it's a feature of the default task dispatching policy
  ("FIFO_Within_Priorities").  Tasks run until they hit a
  "task dispatching point">>

That's wrong. The default dispatching policy is not specified
by the RM. You only get the above behavior if you specify
pragma Dispatching_Policy (FIFO_Within_Priorities), and
your compiler supports this pragma.

  <<-- a same-priority task CAN'T
  interrupt the current task.  To get time-slicing, you must
  use a Task_Dispatching_Policy pragma (AND the compiler
  must support a time-slicing policy, which is not required).>>

That's potentially misleading, since it implies that another
equal priority task cannot execute -- that's of course not
true on multi-processors. What is true is that a priority X
task will not get preempted by another priority X task.

  <<you get pot luck for task dispatching policy.  However,
  FIFO_Within_Priorities is still likely because it's easier
  to build than time-slicing.>>

That's likely wrong. Most Ada runtime systems are likely to be
built over the underlying threads, and typically these OS
level threads *do* support time slicing, so I would say
that time slicing is more likely if you are using a general
purpose compiler in default mode on top of an OS. 

The new version of GNAT on Solaris for example will give system
threads and time slicing as the default dispatching policy, but
if you use FIFO_Within_Priorities, then we use our own completely
Annex_D accurate threads package which does not give time slicing

  <<** For Ada 83 **
  I don't remember the rules for same-priority tasks (if any).>>

Not surprising, there are no rules governing this in Ada 83, i.e.
the behavior in Ada 83 is equivalent to Ada 95 in the absence of
a Dispatching_Policy pragma -- undefined.





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

end of thread, other threads:[~1997-05-25  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-05-07  0:00 Policies In Ada Stephen Cox
1997-05-08  0:00 ` Robert Dewar
1997-05-19  0:00 ` scott
1997-05-20  0:00   ` Samuel A. Mize
1997-05-25  0:00     ` Robert Dewar

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