source: ada-examples/task_priority/task_priority.adb @ 84c019f

ada-examples-4-10-branchada-examples-4-9-branch
Last change on this file since 84c019f was 84c019f, checked in by Joel Sherrill <joel.sherrill@…>, on Feb 6, 2008 at 6:09:50 PM

2008-02-06 Joel Sherrill <joel.sherrill@…>

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