source: ada-examples/task_priority/task_priority.adb @ 92f495a

ada-examples-4-10-branch
Last change on this file since 92f495a was 004230a, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 17, 2009 at 6:13:39 PM

2009-09-17 Joel Sherrill <joel.sherrill@…>

  • Makefile, empty.c, task_priority.adb: Make follow standard RTEMS test output format. Add output screens where appropriate.
  • task_priority.scn: New file.
  • Property mode set to 100644
File size: 1.2 KB
Line 
1--
2--  Demonstrate Task Priority
3--
4--
5--  $Id$
6
7
8with Text_IO; use Text_IO;
9with Ada.Dynamic_Priorities; use Ada.Dynamic_Priorities;
10with System;
11with Interfaces.C;
12
13procedure Task_Priority is
14
15   procedure Put_Priority is
16     function getPriority return Interfaces.C.int;
17     pragma Import (C, getPriority, "getPriority");
18   begin
19     Put (Interfaces.C.int'Image (getPriority));
20   end Put_Priority;
21
22   -- I think 151 > 150 to Ada
23   task Low_Task is
24     pragma Priority(150);
25   end Low_Task;
26
27   task High_Task is
28     pragma Priority(151);
29   end High_Task;
30
31   task body High_Task is
32   begin
33     Put_Line ("*** Task Priority Test ***");
34     Put_Line ( "High: " & System.Any_Priority'Image (Get_Priority));
35     Put ( "HighNative: " );
36     Put_Priority;
37     New_Line;
38     loop
39       delay 1.0;
40       Put_Line ("High - Waking up");
41     end loop;
42   end High_Task;
43
44   task body Low_Task is
45     procedure empty;
46     pragma Import (C, empty, "empty");
47   begin
48     Put_Line ( "Low: " & System.Any_Priority'Image (Get_Priority));
49     Put ( "LowNative: " );
50     Put_Priority;
51     New_Line;
52     delay 0.1;
53     loop
54       empty;
55     end loop;
56   end Low_Task;
57
58begin
59   NULL;
60end Task_Priority;
Note: See TracBrowser for help on using the repository browser.