I am trying to write a parallel, tasking version of a computationally expensive algorithm. I aim to do this
by introducing 3 tasks within a block statement that appears
in a procedure body.
On macOS, the program runs but crashes (killed with SIGKILL from the OS) because it seems to exhaust the OS's supply of
"Ports" - which are some kind of IPC resource used in the Mach/Darwin kernel. It runs fine on Intel/Linux.
Running that on Intel/macOS (Sonoma 14.0) with GNAT 13.1.0 yields:
RodPro2:tests rchapman$ ./tt
Killed: 9
I get the same results on Apple M1 Pro with macOS Ventura 13.5.2 and GNAT 13.1.0.
I attach a screenshot of the "top" utility running. You can see the "#PORTS" column has reached 221557. I think the OS kills the process at 262144 ports (2**18).
So.. some sort of resource leak in the runtime-library perhaps?
Here's the code:
with Ada.Text_IO; use Ada.Text_IO;
with Interfaces; use Interfaces;
procedure TT
is
A, B, C : Unsigned_32 := 0;
D : Unsigned_32;
procedure P
is
begin
declare
task CA;
task CB;
task CC;
task body CA is
begin
A := A + 1;
end CA;
task body CB is
begin
B := B + 1;
end CB;
task body CC is
begin
C := C + 1;
end CC;
begin
null;
end;
D := (A + B + C) / 5;
end P;
begin
for I in 1 .. 1_000_000 loop
P;
end loop;
Put_Line (D'Img);
end TT;

I am trying to write a parallel, tasking version of a computationally expensive algorithm. I aim to do this
by introducing 3 tasks within a block statement that appears
in a procedure body.
On macOS, the program runs but crashes (killed with SIGKILL from the OS) because it seems to exhaust the OS's supply of
"Ports" - which are some kind of IPC resource used in the Mach/Darwin kernel. It runs fine on Intel/Linux.
Running that on Intel/macOS (Sonoma 14.0) with GNAT 13.1.0 yields:
RodPro2:tests rchapman$ ./tt
Killed: 9
I get the same results on Apple M1 Pro with macOS Ventura 13.5.2 and GNAT 13.1.0.
I attach a screenshot of the "top" utility running. You can see the "#PORTS" column has reached 221557. I think the OS kills the process at 262144 ports (2**18).
So.. some sort of resource leak in the runtime-library perhaps?
Here's the code: