]> rtime.felk.cvut.cz Git - rtems-pluggable-edf.git/blob - src/test_edf/task.c
22bffe8aff779952febb86aa0e09bfc43047c828
[rtems-pluggable-edf.git] / src / test_edf / task.c
1 #include <system_def.h>
2 #include "system.h"
3 #include "app_def.h"
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <rtems/untar.h>
7 #include <rtems/error.h>
8 #include <rtems/mw_uid.h>
9 #include <errno.h>
10 #include <stdint.h>
11 #include <rtems/score/wkspace.h>
12
13
14
15 #define TEST_DURATION 130
16
17 //utilization setup: T1 3/7, T2 5/10
18
19 #define T1_DUR 300
20 #define T2_DUR 500
21 #define T1_PER 7
22 #define T2_PER 10
23 #define T1_SERVER 0
24 #define T2_SERVER 0
25
26 void test_loop (  rtems_name name, unsigned int period_length, unsigned int max_j, uint32_t server)
27 {
28   rtems_id period;
29   rtems_status_code status;
30   char output1[50];
31   char output2[50];
32   unsigned int start, stop, max_i;
33   unsigned int i,j,k;
34   void *mem;
35   
36   status = rtems_rate_monotonic_create( name, &period );
37   
38   if ( status != RTEMS_SUCCESSFUL ) {
39         printf( "rtems_monotonic_create failed with status of %d.\n", status);
40             exit( 1 );
41   }
42   
43   max_i = 1000; 
44   edf_deadline_init(period_length, server, NULL);
45   while ( 1 ) {
46           edf_next_period();
47           if (rtems_rate_monotonic_period(period,period_length)==RTEMS_TIMEOUT)
48                      puts("P1 - Deadline miss");
49           
50           rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start);
51           sprintf(output1,"P1-S  ticks:%u  prio:%u",start, (unsigned int) _Per_CPU_Information.executing->current_priority);
52           puts(output1);
53           
54           if ( start >= TEST_DURATION ) break;
55           
56           /* active computing */ 
57           for ( i = 1 ; i < max_i; i++) 
58           { 
59                   j =  i/12 ; j++;
60                   for ( j = 1; j < max_j; j++) 
61                   {
62                           k = j/ 3; 
63                           k++;                    
64                           mem = _Workspace_Allocate (4);
65                           _Workspace_Free(mem);
66                  }
67           }
68          
69           rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &stop);
70           sprintf(output2,"P1-F  ticks:%u",stop);
71           puts(output2);
72   }
73   
74   /* missed period so delete period and SELF */
75   status = rtems_rate_monotonic_delete( period );
76   edf_deadline_cancel();
77   if ( status != RTEMS_SUCCESSFUL ) {
78           printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
79           exit( 0 );
80   }
81   
82   puts( "*** END OF TEST - edf***" );
83   exit( 0 );    
84 }
85
86
87
88 rtems_task Task_1(
89   rtems_task_argument argument
90 )
91 {
92         rtems_name name;
93         name = rtems_build_name( 'P', 'E', 'R', 'A' );
94         test_loop(name, T1_PER,T1_DUR,T1_SERVER);
95 }
96
97
98 rtems_task Task_2(
99   rtems_task_argument argument
100 )
101 {
102         rtems_name name;
103         name = rtems_build_name( 'P', 'E', 'R', 'B' );
104         test_loop(name, T2_PER,T2_DUR,T2_SERVER);
105
106 }
107