comp.lang.ada
 help / color / mirror / Atom feed
* Ada Task Priorities (Windows vs Linux)
@ 2006-04-12 15:24 AAFellow
  2006-04-12 17:08 ` Robert A Duff
  0 siblings, 1 reply; 5+ messages in thread
From: AAFellow @ 2006-04-12 15:24 UTC (permalink / raw)


Hi Everyone,

How are tasks prioritized in Ada when running on Linux (compared to
Windows).  I wrote a small test program that I ran in Windows, and it
seems that the higher the number that I set the task's priority to, the
higher the priority that is given to that task (I thought the opposite
was true?)

In Linux (using GNAT complier), how are the priorities mapped?  I know
a lower number means a higher priority, with a range of -20 to 19 and a
default of 0.  Do we just use these same numbers in the Ada code when
setting the priorities of the tasks?

Also, (so we can verify we have set the priorities correctly) does
Linux provide a way to actually see what priority the OS has given to
tasks that the Ada code has started?  Are there any tools availible
that can do this? 
  
thanks guys!

AA




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

* Re: Ada Task Priorities (Windows vs Linux)
  2006-04-12 15:24 Ada Task Priorities (Windows vs Linux) AAFellow
@ 2006-04-12 17:08 ` Robert A Duff
  2006-04-13 21:26   ` AAFellow
  0 siblings, 1 reply; 5+ messages in thread
From: Robert A Duff @ 2006-04-12 17:08 UTC (permalink / raw)


"AAFellow@hotmail.com" <AAFellow@hotmail.com> writes:

> Hi Everyone,
> 
> How are tasks prioritized in Ada when running on Linux (compared to
> Windows).  I wrote a small test program that I ran in Windows, and it
> seems that the higher the number that I set the task's priority to, the
> higher the priority that is given to that task (I thought the opposite
> was true?)

In Ada, higher numbers mean higher priority.

> In Linux (using GNAT complier), how are the priorities mapped?  I know
> a lower number means a higher priority, with a range of -20 to 19 and a
> default of 0.  Do we just use these same numbers in the Ada code when
> setting the priorities of the tasks?

No.  You use the numbers in the range System.Priority
(or sometimes, System.Interrupt_Priority).
The default is System.Default_Priority.

Look at the source code for package System to see what the numbers are.

The Ada run-time system will map these numbers to whatever the operating
system uses.  If the operating system thinks lower numbers mean higher
priority, then the Ada run-time system will take that into account.

> Also, (so we can verify we have set the priorities correctly) does
> Linux provide a way to actually see what priority the OS has given to
> tasks that the Ada code has started?  Are there any tools availible
> that can do this? 

I think the 'top' program will show such info.  Not sure.

- Bob



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

* Re: Ada Task Priorities (Windows vs Linux)
  2006-04-12 17:08 ` Robert A Duff
@ 2006-04-13 21:26   ` AAFellow
  2006-04-14  1:16     ` Robert A Duff
  0 siblings, 1 reply; 5+ messages in thread
From: AAFellow @ 2006-04-13 21:26 UTC (permalink / raw)


Hi,

Thanks for the help....

...I just ran some test code (which I also ran on windows), and it
seemed that on Linux the priorities set in the code have absolutely no
effect on how the code runs, whereas on windows, the effect is obvious.
 I'm looking into this now.




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

* Re: Ada Task Priorities (Windows vs Linux)
  2006-04-13 21:26   ` AAFellow
@ 2006-04-14  1:16     ` Robert A Duff
  2006-04-17 12:14       ` Alex R. Mosteo
  0 siblings, 1 reply; 5+ messages in thread
From: Robert A Duff @ 2006-04-14  1:16 UTC (permalink / raw)


"AAFellow@hotmail.com" <AAFellow@hotmail.com> writes:

> Hi,
> 
> Thanks for the help....

You're welcome.

> ...I just ran some test code (which I also ran on windows), and it
> seemed that on Linux the priorities set in the code have absolutely no
> effect on how the code runs, whereas on windows, the effect is obvious.
>  I'm looking into this now.

Priorities can be tricky.  You need to understand whether the Systems
Programming and/or Real Time annexes are in effect, and what the
policies are.  Read the compiler documentation.  You need to know how
many CPUs you have.  On some operating systems, you might need to run in
supervisor mode in order to get strict real-time priorities.

- Bob



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

* Re: Ada Task Priorities (Windows vs Linux)
  2006-04-14  1:16     ` Robert A Duff
@ 2006-04-17 12:14       ` Alex R. Mosteo
  0 siblings, 0 replies; 5+ messages in thread
From: Alex R. Mosteo @ 2006-04-17 12:14 UTC (permalink / raw)


Robert A Duff wrote:
> "AAFellow@hotmail.com" <AAFellow@hotmail.com> writes:
> 
> 
>>Hi,
>>
>>Thanks for the help....
> 
> 
> You're welcome.
> 
> 
>>...I just ran some test code (which I also ran on windows), and it
>>seemed that on Linux the priorities set in the code have absolutely no
>>effect on how the code runs, whereas on windows, the effect is obvious.
>> I'm looking into this now.
> 
> 
> Priorities can be tricky.  You need to understand whether the Systems
> Programming and/or Real Time annexes are in effect, and what the
> policies are.  Read the compiler documentation.  You need to know how
> many CPUs you have.  On some operating systems, you might need to run in
> supervisor mode in order to get strict real-time priorities.

Yep. Some 3.15p windows experiences of mine from the past that may be of 
use to the original poster:

You have more priorities in Gnat than in windows. This means that 
several Ada priorities are mapped to the same windows priority. (This is 
explained in some .ads file, maybe system.ads?). Furthermore, regular 
windows processes can receive priority boosts and aren't strictly FIFO 
scheduled per priority.

Adding the Ceiling_Locking pragma will cause your program to be put in 
the realtime windows class, which gives you six levels of priorities 
which follow more closely the annex D rules (IIRC). For example, no 
priority boosts happen here. Still you must take care of the Ada -> 
windows priority mapping. And since now your program is in the realtime 
class, you can easily hang your windows if you don't take care with your 
tasks. Windows processes in the realtime class have more priority than 
all other processes in the other classes (idle, normal, above_normal, 
again IIRC).

Someone said to me that in windows protected objects didn't honored the 
Ceiling_Locking policy in the sense that a task entering the monitor 
would not have its priority raised to the ceiling, so unexpected 
priority inversions could still occur. I don't tested this, so maybe it 
is fud.



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

end of thread, other threads:[~2006-04-17 12:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-12 15:24 Ada Task Priorities (Windows vs Linux) AAFellow
2006-04-12 17:08 ` Robert A Duff
2006-04-13 21:26   ` AAFellow
2006-04-14  1:16     ` Robert A Duff
2006-04-17 12:14       ` Alex R. Mosteo

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