1 | /* Tasks_Periodic |
---|
2 | * |
---|
3 | * This routine serves as a test task for the EDF scheduler |
---|
4 | * implementation. |
---|
5 | * |
---|
6 | * Input parameters: |
---|
7 | * argument - task argument |
---|
8 | * |
---|
9 | * Output parameters: NONE |
---|
10 | * |
---|
11 | * The license and distribution terms for this file may be |
---|
12 | * found in the file LICENSE in this distribution or at |
---|
13 | * http://www.rtems.com/license/LICENSE. |
---|
14 | * |
---|
15 | * $Id$ |
---|
16 | */ |
---|
17 | |
---|
18 | #include "system.h" |
---|
19 | |
---|
20 | rtems_task Tasks_Periodic( |
---|
21 | rtems_task_argument argument |
---|
22 | ) |
---|
23 | { |
---|
24 | rtems_id rmid; |
---|
25 | rtems_id test_rmid; |
---|
26 | rtems_status_code status; |
---|
27 | |
---|
28 | int start, stop, now; |
---|
29 | |
---|
30 | status = rtems_rate_monotonic_create( argument, &rmid ); |
---|
31 | directive_failed( status, "rtems_rate_monotonic_create" ); |
---|
32 | put_name( Task_name[ argument ], FALSE ); |
---|
33 | printf( "- rtems_rate_monotonic_create id = 0x%08" PRIxrtems_id "\n", |
---|
34 | rmid ); |
---|
35 | |
---|
36 | status = rtems_rate_monotonic_ident( argument, &test_rmid ); |
---|
37 | directive_failed( status, "rtems_rate_monotonic_ident" ); |
---|
38 | put_name( Task_name[ argument ], FALSE ); |
---|
39 | printf( "- rtems_rate_monotonic_ident id = 0x%08" PRIxrtems_id "\n", |
---|
40 | test_rmid ); |
---|
41 | |
---|
42 | if ( rmid != test_rmid ) { |
---|
43 | printf( "RMID's DO NOT MATCH (0x%" PRIxrtems_id " and 0x%" |
---|
44 | PRIxrtems_id ")\n", rmid, test_rmid ); |
---|
45 | rtems_test_exit( 0 ); |
---|
46 | } |
---|
47 | |
---|
48 | put_name( Task_name[ argument ], FALSE ); |
---|
49 | printf( "- (0x%08" PRIxrtems_id ") period %" PRIu32 "\n", |
---|
50 | rmid, Periods[ argument ] ); |
---|
51 | |
---|
52 | status = rtems_task_wake_after( 2 + Phases[argument] ); |
---|
53 | directive_failed( status, "rtems_task_wake_after" ); |
---|
54 | |
---|
55 | while (FOREVER) { |
---|
56 | if (rtems_rate_monotonic_period(rmid, Periods[argument])==RTEMS_TIMEOUT) |
---|
57 | printf("P%" PRIdPTR " - Deadline miss\n", argument); |
---|
58 | |
---|
59 | rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start); |
---|
60 | printf("P%" PRIdPTR "-S ticks:%d\n", argument, start); |
---|
61 | if ( start >= 2*HP_LENGTH ) break; /* stop */ |
---|
62 | /* active computing */ |
---|
63 | |
---|
64 | /* using periodic statistics */ |
---|
65 | while(FOREVER) { |
---|
66 | rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &now); |
---|
67 | if (now >= start + Execution[argument]) break; |
---|
68 | } |
---|
69 | rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &stop); |
---|
70 | printf("P%" PRIdPTR "-F ticks:%d\n", argument, stop); |
---|
71 | } |
---|
72 | |
---|
73 | /* delete period and SELF */ |
---|
74 | status = rtems_rate_monotonic_delete( rmid ); |
---|
75 | if ( status != RTEMS_SUCCESSFUL ) { |
---|
76 | printf("rtems_rate_monotonic_delete failed with status of %d.\n",status); |
---|
77 | rtems_test_exit( 0 ); |
---|
78 | } |
---|
79 | fflush(stdout); |
---|
80 | puts( "*** END OF TEST EDF SCHEDULER 3 ***" ); |
---|
81 | rtems_test_exit( 0 ); |
---|
82 | } |
---|