source: ada-examples/task_priority/task_priority.adb @ 6e8632f

ada-examples-4-10-branchada-examples-4-9-branch
Last change on this file since 6e8632f was 6e8632f, checked in by Joel Sherrill <joel.sherrill@…>, on Jul 23, 2008 at 4:05:13 PM

2008-07-23 Joel Sherrill <joel.sherrill@…>

  • empty.c, task_priority.adb: Switch to 150/151. Clean up output.
  • Property mode set to 100644
File size: 1.3 KB
Line 
1--
2--  Demonstrate Task Priority
3--
4--
5-- Expected Output:
6--    High:  151
7--    HighNative: ID=0x0B010004  104
8--    Low:  150
9--    LowNative: ID=0x0B010003  105
10--    High - Waking up
11--    High - Waking up
12--     ....
13--
14--  $Id$
15
16
17with Text_IO; use Text_IO;
18with Ada.Dynamic_Priorities; use Ada.Dynamic_Priorities;
19with System;
20with Interfaces.C;
21
22procedure Task_Priority is
23
24   procedure Put_Priority is
25     function getPriority return Interfaces.C.int;
26     pragma Import (C, getPriority, "getPriority");
27   begin
28     Put (Interfaces.C.int'Image (getPriority));
29   end Put_Priority;
30
31   -- I think 151 > 150 to Ada
32   task Low_Task is
33     pragma Priority(150);
34   end Low_Task;
35
36   task High_Task is
37     pragma Priority(151);
38   end High_Task;
39
40   task body High_Task is
41   begin
42     Put_Line ( "High: " & System.Any_Priority'Image (Get_Priority));
43     Put ( "HighNative: " );
44     Put_Priority;
45     New_Line;
46     loop
47       delay 1.0;
48       Put_Line ("High - Waking up");
49     end loop;
50   end High_Task;
51
52   task body Low_Task is
53     procedure empty;
54     pragma Import (C, empty, "empty");
55   begin
56     Put_Line ( "Low: " & System.Any_Priority'Image (Get_Priority));
57     Put ( "LowNative: " );
58     Put_Priority;
59     New_Line;
60     delay 0.1;
61     loop
62       empty;
63     end loop;
64   end Low_Task;
65
66begin
67   NULL;
68end Task_Priority;
Note: See TracBrowser for help on using the repository browser.