From: Stephan Heinemann <zombie@cs.tu-berlin.de>
Subject: Priority Ceiling
Date: 23 Jul 2003 21:24:16 GMT
Date: 2003-07-23T21:24:16+00:00 [thread overview]
Message-ID: <bfmue0$i3l$1@news.cs.tu-berlin.de> (raw)
Please have a look at the following piece of code:
pragma Queuing_Policy(Priority_Queuing);
pragma Locking_Policy(Ceiling_Locking);
pragma Task_Dispatching_Policy(FIFO_Within_Priorities);
with System; use System;
with Ada.Dynamic_Priorities; use Ada.Dynamic_Priorities;
with Ada.Task_Identification; use Ada.Task_Identification;
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Priorities is
pragma Priority(0);
-- if not specified default priority is inherited by tasks?
P1: constant Priority := Priority'First;
P2: constant Priority := Priority'Last;
protected Ceiling_Object is
--pragma Priority(System.Priority'Last);
pragma Priority(2);
-- less than 15 raises Program_Error?
-- default priority
procedure E;
end Ceiling_Object;
protected body Ceiling_Object is
procedure E is
begin
Put_Line("E entered");
-- delay 5.0; -- should actually not be done
-- display the active priority
Put(Image(Current_Task));
Put(Get_Priority(Current_Task)); New_Line;
-- dynamic priority not raised?
Put_Line("E finished");
end E;
end Ceiling_Object;
task A is
pragma Priority(0);
end A;
task body A is
begin
Put_Line("T running");
Ceiling_Object.E;
-- should raise Program_Error only if task priority
--- higher than ceiling priority
Put_Line("T done");
exception
when Ex: others =>
Put(Image(Current_Task) & " ");
Put(Exception_Name(Ex)); New_Line;
end A;
task B is
pragma Priority(1);
end B;
task body B is
begin
Put_Line("B running");
Ceiling_Object.E;
Put_Line("B done");
exception
when Ex: others =>
Put(Image(Current_Task) & " ");
Put(Exception_Name(Ex)); New_Line;
end B;
begin
Put("P1: "); Put(P1); New_Line;
Put("P2: "); Put(P2); New_Line;
end Priorities;
Now the questions:
(1)
If I understood correctly then the task priority should be raised to the
ceiling priority of the protected object (immediate ceiling priority
protocol). However, I cannot obtain this new active priority using
"Get_Priority(Current_Task)"; the base priority is returned instead. Why?
(2)
The procedure "Priorities" would run with default priority (15) if
pragma Priority(0) was not given. But this change seems to affect the
defined tasks as well, eventhough they have their own base priorities
assigned to them. Do they inherit their priorities from the
"Priorities"-executing task, if they are assigned lower base priorities
than the latter?
Thanks in advance,
Stephan
next reply other threads:[~2003-07-23 21:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-23 21:24 Stephan Heinemann [this message]
2003-07-23 22:19 ` Priority Ceiling Robert I. Eachus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox