First of all lets get this out of the way. I am a beginner in Ada, and the reason that I want to be able to do this is because I would like to program a Priority Inversion.
I have included,
with Ada.Task_Identification;
I have also made a task type:
task type tasktype1 is
pragma PRIORITY (20);
entry gotosleep;
end tasktype1;
and I have declared a task:
High : tasktype1;
Now I would like to change the priority of the task "High" to some other priority.
I have tried writing:
High.Prority(1);
where I would put it in the main's begin block.
and declared a Task_ID.
A : Task_Id;
then tried to fetch the current task with A := Current_Task;
and then put Priority(3,A);
in the mains begin instead.
Here is all of my code for reference:
with Ada.Text_IO, Ada.Integer_Text_IO, System, Ada.Task_Identification;
use Ada.Text_IO, Ada.Integer_Text_IO;
procedure Main is
task type tasktype1 is
pragma PRIORITY (20);
entry gotosleep;
end tasktype1;
pragma PRIORITY (3); -- This is the priority for the main program
High : tasktype1;
A : Task_Id;
task body tasktype1 is
begin
accept gotosleep do
Put("Cow is not sleeping");
end gotosleep;
end tasktype1;
begin
A := Current_Task;
Priority(3, A);
Put_Line("This is an example of use of a task type");
Put_Line("This is an example of use of a task type");
Put_Line("This is an example of use of a task type");
Put_Line("This is an example of use of a task type");
Put_Line("This is an example of use of a task type");
end Main;