TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Classic View

Use Monospaced Font
Show HTML Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender: "Team Ada: Ada Programming Language Advocacy (83 & 95)" <[log in to unmask]>
Date: Thu, 12 May 2005 14:57:39 +0800
Content-Disposition: inline
Reply-To: Rick Duley <[log in to unmask]>
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=ISO-8859-1
From: Rick Duley <[log in to unmask]>
Parts/Attachments: text/plain (87 lines)
Hi Teamers

I recently asked for help to lower the priority of my batchfile project so that
interactive applications could work unrestrained in the foreground.  For the
record (and for those interested) ...

Suggestions centred around two courses of action, one using Win32 and the other
Ada.Dynamic_Priorities from Annex D.5.  I was using Gnat 3.15p and found that

with Win32.Winbase; use Win32.Winbase;
procedure Foo is

   Priority_Set : Win32.Bool := SetPriorityClass(GetCurrentProcess,

begin  -- Foo

   . . .

end Foo;

works.  The priority of the program is shown by Windows Task Manager as "Low"
and User-oriented interactive applications work unhindered in the foreground
while the batch work continues as CPU is available.  The trick was that I was
using an Integer as the second Actual Parameter - I had to use the Constant. 
However ...   Unfortunately, this:

with Ada.Dynamic_Priorities; use Ada.Dynamic_Priorities;
with System;                 use System;
procedure Foo is
begin  -- Foo
   Set_Priority(Priority => Any_Priority'First);

   . . .

end Foo;

does not work and (working from Annex D.1) neither does:

procedure Foo is

   pragma Priority(1);

begin  -- Foo

   . . .

end Foo;

Both of these leave the priority of the application set to "Normal" and the
application interferes with foreground activity despite a liberal sprinkling of
"delay 0.0;" statements.

I must have something wrong in my coding for the use of Annex D because I
believe that prioritisation was always supported by the Gnat Ada Compilers. 
However, trying the same experiments with the new Gnat compiler (GAP 1.1.0)
produced the same results.  If anyone can tell me where the SNAFU is I'd
appreciate it.  I certainly can't find it.

BTW: You just have to have the Win32 stuff saved when you change to the new

Keep the faith
"Professional qualitative judgement
   consists in knowing the rules
     for using (or occasionally breaking)
       the rules."
                            D. Royce Sadler
Rick Duley
Murdoch University
School of Engineering Science
Perth, Western Australia
aussie : 040 910 6049                .-_|\
o'seas : + 61 40 910 6049           /     \
                              perth *_.-._/