]> rtime.felk.cvut.cz Git - rtems-pluggable-edf.git/blobdiff - src/test_edf/task.c
test_edf updated, running, but not properly in the emulator
[rtems-pluggable-edf.git] / src / test_edf / task.c
index 7152ca4b093d8908fb19b7a610944ae83204f888..27a10ebcfc416d6e6112c809f388452032df2229 100644 (file)
@@ -1,4 +1,21 @@
+#include <system_def.h>
 #include "system.h"
+#include "app_def.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <rtems/untar.h>
+#include <rtems/error.h>
+#include <rtems/mw_uid.h>
+#include <errno.h>
+#include <stdint.h>
+
+
+#define TEST_DURATION 130
+
+#define T1_DUR 400000000
+#define T2_DUR 600000000
+#define T1_PER 7
+#define T2_PER 10
 
 rtems_task Task_1(
   rtems_task_argument argument
@@ -9,27 +26,29 @@ rtems_task Task_1(
   rtems_status_code status;
   char output1[50];
   char output2[50];
-  unsigned32 start, stop, period_length, max_i, max_j;
-  unsigned32 i,j,k,l;
+  unsigned int start, stop, period_length, max_i, max_j;
+  unsigned int i,j,k;
   
   name = rtems_build_name( 'P', 'E', 'R', 'A' );
   status = rtems_rate_monotonic_create( name, &period );
+  
   if ( status != RTEMS_SUCCESSFUL ) {
         printf( "rtems_monotonic_create failed with status of %d.\n", status);
            exit( 1 );
   }
   
-  period_length = 7;
-  max_i = 10000; max_j = 4000;
+  period_length = T1_PER; // duration 3 ticks
+  max_i = 10000; max_j = T1_DUR;
+  edf_deadline_init(period_length);
   while ( 1 ) {
          if (rtems_rate_monotonic_period(period,period_length)==RTEMS_TIMEOUT)
                     puts("P1 - Deadline miss");
-
+         edf_next_period();
          rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start);
-         sprintf(output1,"P1-S  ticks:%d",start);
+         sprintf(output1,"P1-S  ticks:%u",start);
          puts(output1);
          
-         if ( start >= 30 ) break;
+         if ( start >= TEST_DURATION ) break;
           
          /* active computing */ 
          for ( i = 1 ; i < max_i; i++) 
@@ -43,21 +62,25 @@ rtems_task Task_1(
          }
         
          rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &stop);
-         sprintf(output2,"P1-F  ticks:%d",stop);
+         sprintf(output2,"P1-F  ticks:%u",stop);
          puts(output2);
   }
   
   /* missed period so delete period and SELF */
   status = rtems_rate_monotonic_delete( period );
+  edf_deadline_cancel();
   if ( status != RTEMS_SUCCESSFUL ) {
          printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
-         rtems_test_exit( 0 );
+         exit( 0 );
   }
   
   puts( "*** END OF TEST - edf***" );
-  rtems_test_exit( 0 );
+  exit( 0 );
 }
 
+
+
+
 rtems_task Task_2(
   rtems_task_argument argument
 )
@@ -67,8 +90,8 @@ rtems_task Task_2(
   rtems_status_code status;
   char output1[50];
   char output2[50];
-  unsigned32 start, stop, period_length, max_i, max_j;
-  unsigned32 i,j,k,l;
+  unsigned int start, stop, period_length, max_i, max_j;
+  unsigned int i,j,k;
          
   name = rtems_build_name( 'P', 'E', 'R', 'B' );
   status = rtems_rate_monotonic_create( name, &period );
@@ -77,17 +100,18 @@ rtems_task Task_2(
            exit( 1 );
   }
   
-  period_length = 10;
-  max_i = 10000; max_j = 6000;
+  period_length = T2_PER; // duration 5 ticks
+  max_i = 10000; max_j = T2_DUR;
+  edf_deadline_init(period_length);
   while ( 1 ) {
          if (rtems_rate_monotonic_period(period,period_length)==RTEMS_TIMEOUT)
                  puts("P2 - Deadline miss");
-        
+         edf_next_period();
          rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start);
-         sprintf(output1,"P2-S  ticks:%d",start);
+         sprintf(output1,"P2-S  ticks:%u",start);
          puts(output1);
          
-         if ( _Watchdog_Ticks_since_boot >= 30 ) {
+         if ( _Watchdog_Ticks_since_boot >= TEST_DURATION ) {
                  break;
          }
   
@@ -104,17 +128,19 @@ rtems_task Task_2(
          }
          
          rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &stop);
-         sprintf(output2,"P2-F  ticks:%d",stop);
+         sprintf(output2,"P2-F  ticks:%u",stop);
          puts(output2); 
   }
 
   /* missed period so delete period and SELF */
   status = rtems_rate_monotonic_delete( period );
+  edf_deadline_cancel();
   if ( status != RTEMS_SUCCESSFUL ) {
          printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
-         rtems_test_exit( 0 );
+         exit( 0 );
   }
   
   puts( "*** END OF TEST - edf***" );
-  rtems_test_exit( 0 );
+  exit( 0 );
 }
+