Download System Configuration Guide

Transcript
System Configuration Guide
-- using a suspension object called Interrupt_Occurred.
-- Note that if the task is already waiting (the usual case) when the
-- interrupt occurs, Interrupt_Occurred is only set to True momentarily;
-- Suspend_Until_True automatically resets it to False. If the task is
-- not waiting, then the True state will be remembered, and when the
-- task gets around to waiting, it will reset it to False and proceed
-- immediately.
-- Note that only one task can wait on a given suspension object; it’s
-- sort of like a protected object with an entry queue of length one,
-- which allows it to be implemented more efficiently. This means that
-- the programmer using suspension objects has to know which task will
-- do the waiting; it’s as if that task has a kind of ownership of that
-- particular suspension object.
---------------------------------------------------------------with Ada.Interrupts.Names; use Ada.Interrupts.Names;
with Ada_Magic.DBG; use Ada_Magic.DBG;
package Suspension_Objects_Test is
-- Empty.
end Suspension_Objects_Test;
---------------------------------------------------------------with Ada.Synchronous_Task_Control; use Ada.Synchronous_Task_Control;
package Suspension_Objects_Test.Handlers is
pragma Elaborate_Body;
protected Handler_PO is
procedure Handler; -- The interrupt handler.
pragma Attach_Handler(Handler, SFT0I);
end Handler_PO;
Interrupt_Occurred: Suspension_Object;
-- Default-initialized to False.
-- Set to True for each interrupt.
end Suspension_Objects_Test.Handlers;
---------------------------------------------------------------package body Suspension_Objects_Test.Handlers is
protected body Handler_PO is
procedure Handler is
69