On Windows, the 'Count attribute was very slow in "Annex D" mode. This patch
fixes that efficiency problem. "Annex D" mode is invoked if there is a pragma
Task_Dispatching_Policy (FIFO_Within_Priorities).

Tested on i686-pc-mingw, committed on trunk

2011-12-12  Bob Duff  <d...@adacore.com>

        * s-taprop-mingw.adb (Yield): Do not delay 1 millisecond in Annex D
        mode.

Index: s-taprop-mingw.adb
===================================================================
--- s-taprop-mingw.adb  (revision 182223)
+++ s-taprop-mingw.adb  (working copy)
@@ -126,9 +126,6 @@
    Foreign_Task_Elaborated : aliased Boolean := True;
    --  Used to identified fake tasks (i.e., non-Ada Threads)
 
-   Annex_D : Boolean := False;
-   --  Set to True if running with Annex-D semantics
-
    Null_Thread_Id : constant Thread_Id := 0;
    --  Constant to indicate that the thread identifier has not yet been
    --  initialized.
@@ -700,20 +697,9 @@
    -----------
 
    procedure Yield (Do_Yield : Boolean := True) is
+      pragma Unreferenced (Do_Yield);
    begin
-      if Do_Yield then
-         SwitchToThread;
-
-      elsif Annex_D then
-         --  If running with Annex-D semantics we need a delay
-         --  above 0 milliseconds here otherwise processes give
-         --  enough time to the other tasks to have a chance to
-         --  run.
-         --
-         --  This makes cxd8002 ACATS pass on Windows.
-
-         Sleep (1);
-      end if;
+      SwitchToThread;
    end Yield;
 
    ------------------
@@ -1076,8 +1062,6 @@
 
          Discard := OS_Interface.SetPriorityClass
                       (GetCurrentProcess, Realtime_Priority_Class);
-
-         Annex_D := True;
       end if;
 
       TlsIndex := TlsAlloc;

Reply via email to