Last active
December 20, 2015 21:58
-
-
Save merdmann/6201405 to your computer and use it in GitHub Desktop.
Assigning task to CPU
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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