summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-02-06 18:09:50 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-02-06 18:09:50 +0000
commit84c019f33ef0b3cfb1fda7c50e459d933f3039fe (patch)
tree216e7b2b76287894baee72d20e9ae0f43fd211ef
parent2008-02-06 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadada-examples-84c019f33ef0b3cfb1fda7c50e459d933f3039fe.tar.bz2
2008-02-06 Joel Sherrill <joel.sherrill@oarcorp.com>
* ChangeLog, Makefile, empty.c, task_priority.adb: New files.
-rw-r--r--task_priority/ChangeLog4
-rw-r--r--task_priority/Makefile21
-rw-r--r--task_priority/empty.c20
-rw-r--r--task_priority/task_priority.adb62
4 files changed, 107 insertions, 0 deletions
diff --git a/task_priority/ChangeLog b/task_priority/ChangeLog
new file mode 100644
index 0000000..fccd5ac
--- /dev/null
+++ b/task_priority/ChangeLog
@@ -0,0 +1,4 @@
+2008-02-06 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ * ChangeLog, Makefile, empty.c, task_priority.adb: New files.
+
diff --git a/task_priority/Makefile b/task_priority/Makefile
new file mode 100644
index 0000000..e4fba01
--- /dev/null
+++ b/task_priority/Makefile
@@ -0,0 +1,21 @@
+#
+# Makefile for Ada Dump URL example
+#
+# See README.Makefiles in the main ada-examples directory.
+#
+
+PROGRAM=task_priority
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/leaf.cfg
+
+# stack size for the first Ada thread
+CFLAGS +=-DGNAT_MAIN_STACKSPACE=100
+
+EXTRA_OBJS = empty.o
+EXTRA_GNATFLAGS=-fstack-check
+
+include ../Makefile.shared
+
+empty.o: empty.c
diff --git a/task_priority/empty.c b/task_priority/empty.c
new file mode 100644
index 0000000..b5413c2
--- /dev/null
+++ b/task_priority/empty.c
@@ -0,0 +1,20 @@
+#if defined(__rtems__)
+#include <rtems.h>
+#endif
+
+int getPriority()
+{
+#if defined(__rtems__)
+ printk( "ID=0x%08x\n", _Thread_Executing->Object.id );
+
+ return (int)_Thread_Executing->current_priority;
+#endif
+ return 0;
+}
+
+void empty()
+{
+ #if defined(__rtems__)
+ // printk(".");
+ #endif
+}
diff --git a/task_priority/task_priority.adb b/task_priority/task_priority.adb
new file mode 100644
index 0000000..c4c5d64
--- /dev/null
+++ b/task_priority/task_priority.adb
@@ -0,0 +1,62 @@
+--
+-- Demonstrate Task Priority
+--
+--
+--High: 17
+--HighNative: ID=0x0B010004
+-- 238
+--Low: 16
+--LowNative: ID=0x0B010003
+-- 239
+
+
+with Text_IO; use Text_IO;
+with Ada.Dynamic_Priorities; use Ada.Dynamic_Priorities;
+with System;
+with Interfaces.C;
+
+procedure Task_Priority is
+
+ procedure Put_Priority is
+ function getPriority return Interfaces.C.int;
+ pragma Import (C, getPriority, "getPriority");
+ begin
+ Put_Line (Interfaces.C.int'Image (getPriority));
+ end Put_Priority;
+
+ -- I think 16 > 17 to Ada
+ task Low_Task is
+ pragma Priority(16);
+ end Low_Task;
+
+ task High_Task is
+ pragma Priority(17);
+ end High_Task;
+
+ task body High_Task is
+ begin
+ Put_Line ( "High: " & System.Any_Priority'Image (Get_Priority));
+ Put ( "HighNative: " );
+ Put_Priority;
+ loop
+ delay 1.0;
+ Put_Line ("High - Waking up");
+ end loop;
+ end High_Task;
+
+ task body Low_Task is
+ procedure empty;
+ pragma Import (C, empty, "empty");
+ begin
+ Put_Line ( "Low: " & System.Any_Priority'Image (Get_Priority));
+ Put ( "LowNative: " );
+ Put_Priority;
+ delay 0.1;
+ loop
+ empty;
+ end loop;
+ end Low_Task;
+
+begin
+ NULL;
+end Task_Priority;