summaryrefslogtreecommitdiff
path: root/cpuuse
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-09-10 14:59:03 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-09-10 14:59:03 +0000
commit12b2266af600824b8460918bd694233b07dd3f67 (patch)
tree565cfbb286832550c168bf426ddaad6fbe1e11e8 /cpuuse
parent19e0c8f9177d08402ebaa4e5c05e6a523e3b455f (diff)
2008-09-10 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile: Add new tests. Most of these eitehr demonstrate or verify a particular functionality. * cpuuse/Makefile, cpuuse/cpuuse.adb, exception_test2/Makefile, exception_test2/exceptiontest2.adb, exception_test3/Makefile, exception_test3/exceptiontest3.adb: New files.
Diffstat (limited to 'cpuuse')
-rw-r--r--cpuuse/Makefile21
-rw-r--r--cpuuse/cpuuse.adb58
2 files changed, 79 insertions, 0 deletions
diff --git a/cpuuse/Makefile b/cpuuse/Makefile
new file mode 100644
index 0000000..e00b2a4
--- /dev/null
+++ b/cpuuse/Makefile
@@ -0,0 +1,21 @@
+#
+# Makefile for Ada Dump URL example
+#
+# See README.Makefiles in the main ada-examples directory.
+#
+
+PROGRAM=cpuuse
+
+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 =
+EXTRA_GNATFLAGS=-fstack-check
+
+include ../Makefile.shared
+
+empty.o: empty.c
diff --git a/cpuuse/cpuuse.adb b/cpuuse/cpuuse.adb
new file mode 100644
index 0000000..5683afa
--- /dev/null
+++ b/cpuuse/cpuuse.adb
@@ -0,0 +1,58 @@
+--
+-- Demonstrate CPU Usage Report
+--
+-- $Id$
+--
+
+
+with Text_IO; use Text_IO;
+with Ada.Dynamic_Priorities; use Ada.Dynamic_Priorities;
+with System;
+with Interfaces.C;
+with RTEMS;
+
+procedure CPUUSE is
+
+ 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
+ Seconds : Integer;
+ Result : RTEMS.Status_Codes;
+ begin
+ RTEMS.Object_Set_Name( RTEMS.Self, "High_Task", Result );
+ Seconds := 0;
+ loop
+ delay 1.0;
+ Seconds := Seconds + 1;
+ Put_Line ("High - waking up at " & Integer'Image(Seconds));
+ if (Seconds mod 5) = 0 then
+ RTEMS.CPU_Usage_Report;
+ end if;
+ if Seconds = 30 then
+ Put_Line ("*** End of Ada CPU Use Test ***");
+ RTEMS.Shutdown_Executive (0);
+ end if;
+ end loop;
+ end High_Task;
+
+ task body Low_Task is
+ Result : RTEMS.Status_Codes;
+ begin
+ RTEMS.Object_Set_Name( RTEMS.Self, "Low_Task", Result );
+ delay 0.1;
+ loop
+ Null;
+ end loop;
+ end Low_Task;
+
+ Result : RTEMS.Status_Codes;
+begin
+ RTEMS.Object_Set_Name( RTEMS.Self, "Ada Main", Result );
+ Put_Line ("*** Start of Ada CPU Use Test ***");
+end CPUUSE;