Can anyone supply me with simple working examples which illustrate the use of pragmas in Ada 2005 ? I understand that pragmas are used to priorities processes, just that I have not come across working examples !
Much appreciated !
Can anyone supply me with simple working examples which illustrate the use of pragmas in Ada 2005 ? I understand that pragmas are used to priorities processes, just that I have not come across working examples !
Much appreciated !
An Ada pragma is a language feature that allows adjusting or fine-tuning the behavior of an Ada program. A number of pragmas are defined by the Ada language standard, but compiler vendors can also define their own.
The subject of pragmas cover far more than just process [tasking] priorities, here's a list of standard and vendor-provided pragmas to check out.
What exactly are you trying to do with the aid of pragmas? Set task priorities?
-- Not compile checked:
with System; use System;
task Prioritized_Task is
pragma Priority(System.Default_Priority + 1);
entry Start;
end Prioritized_Task;
As with much of Ada, I think the best answer here is really to consult the LRM. The section on managing task priorities is actually very readable, for a language standard definition anyway.
Note that you can also set the priority of a task at runtime without use of a pragma. This makes use of the package Ada.Dynamic_Priorities
. This is what I typically do these days, unless for some weird reason the desired priority is known at compile time, and I don't mind hard-coding it.
I highly suggest that advanced users such as yourself poke through the LRM to see what all the language provides you. Pay particular attention to the annexes (the sections starting with a letter), as that is where most of the good stuff is documented. In your case, you will probably be particularly interested in the Real-Time annex (Annex D).
A search of comp.lang.ada
for recent discussions about priorities
has several interesting examples. This one seems particularly apropos to your question.
Addendum: Two other exemplary sources are the Rationale for Ada 95 and Rationale for Ada 2005