]> rtime.felk.cvut.cz Git - rtems-pluggable-edf.git/blob - src/test_edf/task.c
Test_CBS: test updated for testing a basic part of reps_lib API
[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
24 void test_loop ( unsigned int id, rtems_name name, unsigned int period_length, unsigned int max_j)
25 {
26   rtems_id period;
27   rtems_status_code status;
28   char output1[50];
29   char output2[50];
30   unsigned int start, stop, max_i;
31   unsigned int i,j,k;
32   void *mem;
33   
34   status = rtems_rate_monotonic_create( name, &period );
35   
36   if ( status != RTEMS_SUCCESSFUL ) {
37         printf( "rtems_monotonic_create failed with status of %d.\n", status);
38             exit( 1 );
39   }
40   
41   max_i = 1000; 
42   edf_deadline_init(name, &period);
43   while ( 1 ) {
44           if (edf_next_period(period,period_length, 0))
45                      printf("P%u - Deadline miss", id);
46           
47           rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start);
48           sprintf(output1,"P%u-S  ticks:%u  prio:%u", id,start, (unsigned int) _Per_CPU_Information.executing->current_priority);
49           puts(output1);
50           
51           if ( start >= TEST_DURATION ) break;
52           
53           /* active computing */ 
54           for ( i = 1 ; i < max_i; i++) 
55           { 
56                   j =  i/12 ; j++;
57                   for ( j = 1; j < max_j; j++) 
58                   {
59                           k = j/ 3; 
60                           k++;                    
61                           mem = _Workspace_Allocate (4);
62                           _Workspace_Free(mem);
63                  }
64           }
65          
66           rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &stop);
67           sprintf(output2,"P%u-F  ticks:%u",id, stop);
68           puts(output2);
69   }
70   
71   /* missed period so delete period and SELF */
72   status = edf_deadline_cancel(period);
73   if ( status != RTEMS_SUCCESSFUL ) {
74           printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
75           exit( 0 );
76   }
77   
78   puts( "*** END OF TEST - edf***" );
79   exit( 0 );    
80 }
81
82
83
84 rtems_task Task_1(
85   rtems_task_argument argument
86 )
87 {
88         rtems_name name;
89         name = rtems_build_name( 'P', 'E', 'R', 'A' );
90         test_loop(1, name, T1_PER,T1_DUR);
91 }
92
93
94 rtems_task Task_2(
95   rtems_task_argument argument
96 )
97 {
98         rtems_name name;
99         name = rtems_build_name( 'P', 'E', 'R', 'B' );
100         test_loop(2, name, T2_PER,T2_DUR);
101
102 }
103