Skip to content

Instantly share code, notes, and snippets.

@merdmann
Last active December 20, 2015 21:58
Show Gist options
  • Save merdmann/6201405 to your computer and use it in GitHub Desktop.
Save merdmann/6201405 to your computer and use it in GitHub Desktop.
Assigning task to CPU
with Ada.Text_IO; use Ada.Text_IO;
with System.Multiprocessors; use System.Multiprocessors;
use System;
procedure main is
Nbr_Of_Threads : constant Positive := 4;
--Number_Of_Processors;
begin
Put_Line("Nbr of Threads" & Positive'Image(Nbr_Of_Threads));
declare
task type Task_Type( id : Natural ) with CPU => CPU_Range(Id) ;
type Task_Access is access all Task_Type;
task body Task_Type is
begin
while true loop
null;
end loop;
Put_Line("Terminated");
end;
TT : array(1..Nbr_Of_Threads) of Task_Access;
begin
for i in TT'Range loop
TT(i) := new Task_Type(i);
end loop;
end;
-- sync point
Put_Line("All Tasks terminated");
end;
~
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment