next up previous contents index
Next: Summary Up: Time and Clocks Previous: Ada Time and Clocks   Contents   Index

Subsections

GNAT Implementation


Delay and Delay Until Statements

The GNARL subprograms which implement these Ada statements are placed in child packages of the corresponding standard Ada packages: Ada.Calendar.Delays and Ada.Real_Time.Delays. The GNAT compiler translates the delay statement into a call to the corresponding GNARL subprogram.

Figure 5.1: GNARL Subprograms for the Delay Statement.
\begin{figure}\centerline{\psfig{figure=figures/05-clocks_delays/01-delay.eps,
width=11.0cm}}\end{figure}

GNARL provides two implementations of the delay statements: one for the case of an Ada program without tasks and the other for an Ada program with tasks. A link is used to access the proper subprogram (Timed_Delay5.1).

When the program has tasks, the GNARL procedure Timed_Delay performs the following actions.


Timed Entry Call

The timed task entry call is handled by the GNAT compiler in a similar way to the simple mode entry call (described in section [*]). The compiler generates a call to the GNARL subprogram Timed_Task_Entry_Call5.8. Basically this procedure carries out the same actions described in the simple mode entry call (section [*]). However, if the entry can not be immediately accepted, it does not simply block the caller; it calls another GNARL subprogram to arm a timer and block the caller until the timeout expires. Figure [*] shows the GNARL and GNULL subprograms involved in this action. If the entry call is accepted before this timer expires, the timer is un-armed; otherwise the entry call is removed from the queue.

Figure 5.4: GNARL Subprograms for Timed Entry Call.
\begin{figure}\centerline{\psfig{figure=figures/05-clocks_delays/04-timed_entry_call.eps,
width=13.0cm}}\end{figure}

The GNAT implementation of the timed protected entry call follows the same scheme described above. However, the only difference is that the compiler generates a call to the GNARL procedure Timed_Protected_Entry_Call5.9.


Timed Selective Accept

The timed task entry call is handled by the GNAT compiler in a similar way to the selective accept (described in section [*]). The compiler generates a call to the GNARL subprogram Timed_Selective_Wait5.10. Basically this procedure carries out the same actions described in case of the selective wait (section [*]). However, if there is no entry call that can be immediately accepted, it does not simply block the caller; it calls another GNARL subprogram to program a timer and block the caller until this timeout expires. Figure [*] shows the GNARL and GNULL subprograms involved in this action. If some entry call is received before this timer expires, the timer is un-armed; otherwise the statements after the delay sentence are executed.

Figure 5.5: GNARL Subprograms for Timed Selective Accept.
\begin{figure}\centerline{\psfig{figure=figures/05-clocks_delays/05-timed_selective_accept.eps,
width=13.0cm}}\end{figure}



Footnotes

...Timed_Delay5.1
System.Soft_Links.Timed_Delay.
... Time_Delay_NT5.2
Ada.Calendar.Delays.Time_Delay_NT
... Timed_Delay5.3
System.OS_Primitives.Timed_Delay
... Timed_Delay_T5.4
System.Task_Initialization.Timed_Delay_T
... Timed_Delay5.5
System.Task_Primitives.Operations.Timed_Delay
... Timed_Delay5.6
System.Task_Primitives.Operations.Timed_Delay
... clock5.7
Ada.Calendar.Clock or Ada.Real_Time.Clock.
...Timed_Task_Entry_Call5.8
System.Tasking.Rendezvous.Timed_Task_Entry_Call
...Timed_Protected_Entry_Call5.9
System.Tasking.Protected_Objects.Operations.Timed_Protected_Entry_Call
...Timed_Selective_Wait5.10
System.Tasking.Rendezvous.Timed_Selective_Wait

next up previous contents index
Next: Summary Up: Time and Clocks Previous: Ada Time and Clocks   Contents   Index
(c) Javier Miranda. Canary Islands (Spain), 2002. Version 1.0