comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Scheduling behaviour issue
Date: Thu, 23 Apr 2020 12:48:21 +0100
Date: 2020-04-23T12:48:21+01:00	[thread overview]
Message-ID: <ly4ktal8xm.fsf@pushface.org> (raw)
In-Reply-To: ly1rofhhyf.fsf@pushface.org

I've done some tests on this with GNAT CE 2019.

Test program at the end; the commented-out lines are for checks on host
machines, irrelevant for single-cpu STM32F4 boards.  The test execution
is to be under GDB, but a breakpoint on the null; in task C (line 48),
and set up this script for that breakpoint:

   command
   silent
   print As
   print Bs
   continue
   end

On macOS with 4 CPUs, both As and Bs are updated, and the user load is
~199% (i.e. two CPUs in use).

On debian stretch under VMware (1 CPU), both As and Bs are updated.

Conclusion: the macOS host RTS doesn't respect the CPU
restriction. Can't tell about macOS, but the Linux RTS behaves in the
same way as FreeRTOS.

On STM32F4, with cortex-gnat-rts, the behaviour is as I expected (both
As and Bs updated).

On STM32F4, with ravenscar-{sfp,full}-stm32f4, the behaviour is as
D.2.3(9)[3] (only As updated).

==========================================

with Ada.Real_Time;
with System;
--  with System.Multiprocessors;

package body Priority_Issue is

   type Count is mod 2 ** 64;
   As : Count := 0;
   Bs : Count := 0;

   task A
   with
     --  CPU => 1,
     Priority => System.Default_Priority;

   task B
   with
     --  CPU => 1,
     Priority => System.Default_Priority;

   task C
   with
     --  CPU => 1,
     Priority => System.Default_Priority + 1;

   use type Ada.Real_Time.Time;

   task body A is
   begin
      delay until Ada.Real_Time.Clock + Ada.Real_Time.Milliseconds (300);
      loop
         As := As + 1;
      end loop;
   end A;

   task body B is
   begin
      delay until Ada.Real_Time.Clock + Ada.Real_Time.Milliseconds (600);
      loop
         Bs := Bs + 1;
      end loop;
   end B;

   task body C is
   begin
      loop
         delay until Ada.Real_Time.Clock + Ada.Real_Time.Seconds (1);
         null;  --  break here, print As, Bs
      end loop;
   end C;

end Priority_Issue;

  parent reply	other threads:[~2020-04-23 11:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-22 11:34 Scheduling behaviour issue Simon Wright
2020-04-22 16:16 ` fabien.chouteau
2020-04-22 17:20   ` Simon Wright
2020-04-22 18:05     ` Anh Vo
2020-04-22 18:21       ` Niklas Holsti
2020-04-22 18:03 ` Niklas Holsti
2020-04-22 20:41   ` AdaMagica
2020-04-22 21:58     ` Niklas Holsti
2020-04-23  0:47       ` Jere
2020-04-23 10:56   ` Simon Wright
2020-04-23 12:38     ` Niklas Holsti
2020-04-23 12:57     ` Niklas Holsti
2020-04-23 11:48 ` Simon Wright [this message]
2020-04-23 13:18 ` Niklas Holsti
replies disabled

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