with Ada.Real_Time; use Ada.Real_Time;
with System; use System;
package Name is
Start_Time : Time := ... ;
Period : Time_Span := ... ;
Thread_Priority : Priority := ... ;
pragma Elaborate_Body (Name);
end Name;
No hay operaciones visibles
– Elaborate_Body indica que el
paquete tiene cuerpo
Atributos temporales
– Start_Time
– Period
– Thread_Priority
No se detecta si se excede el plazo
de ejecución o el tiempo de cómputo
with Ada.Real_Time; use Ada.Real_Time;
-- other context clauses
package body Name is
task Thread is
pragma Priority (Thread_Priority);
end Thread;
task body Thread is
Next_Time : Time := Start_Time ;
begin
-- thread initialization
loop
delay until Next_Time;
OPCS.Periodic_Activity;
Next_Time := Next_Time + Period;
end loop;
end Thread;
begin
-- package initialization
end Name;
with System; use System;
package Name is
Thread_Priority : Priority := ... ;
procedure Start;
end Name;
La única operación visible es la
operación de arranque (Start)
El OBCS se realiza con un objeto de
suspensión
No se vigila el cumplimiento de la
separación mínima entre sucesos
No se detecta si se excede el plazo
de ejecución o el tiempo de cómputo
with Ada.Synchronous_Task_Control;
use Ada.Synchronous_Task_Control;
-- other context clauses
package body Name is
task Thread is
pragma Priority (Thread_Priority);
end Thread;
Control : Suspension_Object;
task body Thread is
begin
-- thread initialization
loop
Suspend_Until_True(Control);
OPCS.Sporadic_Activity;
end loop;
end Thread;
procedure Start is
begin
Set_True (Control);
end Start;
begin
-- package initialization
end Name;
private
protected OBCS is
pragma Priority (Control_Priority);
procedure Start;
entry Wait;
private
Started : Boolean := False;
end OBCS;
procedure Start
renames OBCS.Start;
end Name;
El objeto de sincronización se sustituye por un objeto protegido
Funcionalmente es equivalente, aunque menos eficiente
Es fácil de extender para tener en cuenta la separación mínima entre sucesos
Permite poner parámetros en las operaciones
14/11/07
Esquemas de tareas de tiempo real
7
Componente esporádico:
Sincronización con objeto protegido (2)
with System; use System;
package body Name is
task Thread is
pragma Priority (Thread_Priority);
end Thread;
task body Thread is
begin
-- thread initialization
loop
OBCS.Wait;
OPVS.Sporadic_Activity;
end loop;
end Thread;
protected body OBCS is
procedure Start is
begin
Started := True;
end Start;
entry Wait when Started is
begin
Started := False;
end Wait;
end OBCS;
begin
-- package initialization
end Name;
with Ada.Real_Time; use Ada.Real_Time;
with System; use System;
package Name is
Separation : Time_Span := ... ;
Thread_Priority : Priority := ... ;
Control_Priority: Priority := ... ;
procedure Start;
private
protected OBCS is
pragma Priority (Control_Priority);
procedure Start;
entry Wait(Start_Time : out Time);
private
Started : Boolean := False;
Event_Time : Time;
end OBCS;
procedure Start
renames OBCS.Start;
end Name;
El objeto OBCS registra el tiempo en que se hace Start
(no es necesariamente el mismo en que se ejecuta la acción esporádica)
14/11/07
Esquemas de tareas de tiempo real
9
Componente esporádico:
Separación mínima (2)
with Ada.Real_Time; use Ada.Real_Time;
with System; use System;
package body Name is
task Thread is
pragma Priority (Thread_Priority);
end Thread;
task body Thread is
Start_Time : Time;
begin
-- thread initialization
loop
OBCS.Wait (Start_Time);
OPCS.Sporadic_Activity;
delay until
Start_Time + Separation;
end loop;
end Thread;
protected body OBCS is
procedure Start is
begin
Started := True;
Event_Time := Ada.Real_Time.Clock;
end Start;
entry Wait
(Start_Time : out Time)
when Started is
begin
Started := False;
end Wait;
end OBCS;
begin
-- package initialization
end Name;
Start_Time := Event_Time;
Inconveniente: dos cambios de contexto
– si se está seguro de la separación mínima es mejor el esquema anterior
Comentarios de: Esquemas de tareas de tiempo real (0)
No hay comentarios