1 | /* Tasks_Aperiodic |
---|
2 | * |
---|
3 | * This routine serves as a test task for the EDF scheduler |
---|
4 | * implementation. This is for aperiodic task execution. |
---|
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.org/license/LICENSE. |
---|
14 | */ |
---|
15 | |
---|
16 | #ifdef HAVE_CONFIG_H |
---|
17 | #include "config.h" |
---|
18 | #endif |
---|
19 | |
---|
20 | #include "system.h" |
---|
21 | |
---|
22 | rtems_task Tasks_Aperiodic( |
---|
23 | rtems_task_argument argument |
---|
24 | ) |
---|
25 | { |
---|
26 | rtems_status_code status; |
---|
27 | int start; |
---|
28 | int stop; |
---|
29 | int now; |
---|
30 | |
---|
31 | put_name( Task_name[ argument ], FALSE ); |
---|
32 | |
---|
33 | status = rtems_task_wake_after( 2 + Phases[argument] ); |
---|
34 | directive_failed( status, "rtems_task_wake_after" ); |
---|
35 | |
---|
36 | if ( argument == 6 ) { |
---|
37 | rtems_task_suspend( Task_id[5] ); |
---|
38 | rtems_task_resume( Task_id[5] ); |
---|
39 | } |
---|
40 | |
---|
41 | rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start); |
---|
42 | printf("AT%" PRIdPTR "-S ticks:%d\n", argument, start); |
---|
43 | /* active computing */ |
---|
44 | |
---|
45 | while(FOREVER) { |
---|
46 | rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &now); |
---|
47 | if (now >= start + Execution[argument]) break; |
---|
48 | } |
---|
49 | rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &stop); |
---|
50 | printf("P%" PRIdPTR "-F ticks:%d\n", argument, stop); |
---|
51 | |
---|
52 | /* delete SELF */ |
---|
53 | fflush(stdout); |
---|
54 | printf( "Killing task %" PRIdPTR "\n", argument); |
---|
55 | status = rtems_task_delete(RTEMS_SELF); |
---|
56 | directive_failed(status, "rtems_task_delete of RTEMS_SELF"); |
---|
57 | } |
---|