Tasking
Display Service
Goal: create a simple service that displays messages to the user.
Steps:
Implement the
Display_Services
package.
Declare the task type
Display_Service
.Implement the
Display
entry for strings.Implement the
Display
entry for integers.
Requirements:
Task type
Display_Service
uses theDisplay
entry to display messages to the user.There are two versions of the
Display
entry:
One that receives messages as a string parameter.
One that receives messages as an
Integer
parameter.When a message is received via a
Display
entry, it must be displayed immediately to the user.
Event Manager
Goal: implement a simple event manager.
Steps:
Implement the
Event_Managers
package.
Declare the task type
Event_Manager
.Implement the
Start
entry.Implement the
Event
entry.
Requirements:
The event manager has a similar behavior as an alarm
The sole purpose of this event manager is to display the event ID at the correct time.
After the event ID is displayed, the task must finish.
The event manager (
Event_Manager
type) must have two entries:
Start
, which starts the event manager with an event ID;
Event
, which delays the task until a certain time and then displays the event ID as a user message.The format of the user message displayed by the event manager is
Event #<event_id>
.
You should use
Natural'Image
to display the ID (as indicated in the body of theEvent_Managers
package below).
Remarks:
In the
Start
entry, you can use theNatural
type for the ID.In the
Event
entry, you should use theTime
type from theAda.Real_Time
package for the time parameter.Note that the test application below creates an array of event managers with different delays.
Generic Protected Queue
Goal: create a queue container using a protected type.
Steps:
Implement the generic package
Gen_Queues
.
Declare the protected type
Queue
.Implement the
Empty
function.Implement the
Full
function.Implement the
Push
entry.Implement the
Pop
entry.
Requirements:
These are the formal parameters for the generic package
Gen_Queues
:
a formal modular type;
This modular type should be used by the
Queue
to declare an array that stores the elements of the queue.The modulus of the modular type must correspond to the maximum number of elements of the queue.
the data type of the elements of the queue.
Select a formal parameter that allows you to store elements of any data type in the queue.
These are the operations of the
Queue
type:
Function
Empty
indicates whether the queue is empty.Function
Full
indicates whether the queue is full.Entry
Push
stores an element in the queue.Entry
Pop
removes an element from the queue and returns the element via output parameter.
Remarks:
In this exercise, we create a queue container by declaring and implementing a protected type (
Queue
) as part of a generic package (Gen_Queues
).As a bonus exercise, you can analyze the body of the
Queue_Tests
package and understand how theQueue
type is used there.
In particular, the procedure
Concurrent_Test
implements two tasks:T_Producer
andT_Consumer
. They make use of the queue concurrently.