1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2013. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.org/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #ifdef HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #define CONFIGURE_INIT |
---|
15 | #include "system.h" |
---|
16 | |
---|
17 | const char rtems_test_name[] = "TIME TEST 24"; |
---|
18 | |
---|
19 | uint32_t Task_count; |
---|
20 | |
---|
21 | rtems_task Tasks( |
---|
22 | rtems_task_argument argument |
---|
23 | ); |
---|
24 | |
---|
25 | rtems_task High_task( |
---|
26 | rtems_task_argument argument |
---|
27 | ); |
---|
28 | |
---|
29 | rtems_task Init( |
---|
30 | rtems_task_argument argument |
---|
31 | ) |
---|
32 | { |
---|
33 | rtems_id id; |
---|
34 | uint32_t index; |
---|
35 | rtems_status_code status; |
---|
36 | |
---|
37 | Print_Warning(); |
---|
38 | |
---|
39 | TEST_BEGIN(); |
---|
40 | |
---|
41 | status = rtems_task_create( |
---|
42 | rtems_build_name( 'H', 'I', 'G', 'H' ), |
---|
43 | 1, |
---|
44 | RTEMS_MINIMUM_STACK_SIZE, |
---|
45 | RTEMS_DEFAULT_MODES, |
---|
46 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
47 | &id |
---|
48 | ); |
---|
49 | directive_failed( status, "rtems_task_create HIGH" ); |
---|
50 | |
---|
51 | status = rtems_task_start( id, High_task, 0 ); |
---|
52 | directive_failed( status, "rtems_task_create HIGH" ); |
---|
53 | |
---|
54 | for ( index = 1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
55 | status = rtems_task_create( |
---|
56 | rtems_build_name( 'R', 'E', 'S', 'T' ), |
---|
57 | (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u, |
---|
58 | RTEMS_MINIMUM_STACK_SIZE, |
---|
59 | RTEMS_DEFAULT_MODES, |
---|
60 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
61 | &id |
---|
62 | ); |
---|
63 | directive_failed( status, "rtems_task_create LOOP" ); |
---|
64 | |
---|
65 | status = rtems_task_start( id, Tasks, 0 ); |
---|
66 | directive_failed( status, "rtems_task_start LOOP" ); |
---|
67 | } |
---|
68 | status = rtems_task_delete( RTEMS_SELF ); |
---|
69 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
70 | } |
---|
71 | |
---|
72 | rtems_task High_task( |
---|
73 | rtems_task_argument argument |
---|
74 | ) |
---|
75 | { |
---|
76 | rtems_status_code status; |
---|
77 | uint32_t index; |
---|
78 | |
---|
79 | benchmark_timer_initialize(); |
---|
80 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
81 | (void) benchmark_timer_empty_function(); |
---|
82 | overhead = benchmark_timer_read(); |
---|
83 | |
---|
84 | benchmark_timer_initialize(); |
---|
85 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
86 | (void) rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); |
---|
87 | end_time = benchmark_timer_read(); |
---|
88 | |
---|
89 | put_time( |
---|
90 | "rtems_task_wake_after: yield returns to caller", |
---|
91 | end_time, |
---|
92 | OPERATION_COUNT, |
---|
93 | overhead, |
---|
94 | 0 |
---|
95 | ); |
---|
96 | |
---|
97 | Task_count = 0; |
---|
98 | |
---|
99 | status = rtems_task_delete( RTEMS_SELF ); |
---|
100 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
101 | } |
---|
102 | |
---|
103 | rtems_task Tasks( |
---|
104 | rtems_task_argument argument |
---|
105 | ) |
---|
106 | { |
---|
107 | Task_count++; |
---|
108 | |
---|
109 | if ( Task_count == 1 ) |
---|
110 | benchmark_timer_initialize(); |
---|
111 | else if ( Task_count == OPERATION_COUNT ) { |
---|
112 | end_time = benchmark_timer_read(); |
---|
113 | |
---|
114 | put_time( |
---|
115 | "rtems_task_wake_after: yields preempts caller", |
---|
116 | end_time, |
---|
117 | OPERATION_COUNT, |
---|
118 | overhead, |
---|
119 | 0 |
---|
120 | ); |
---|
121 | |
---|
122 | TEST_END(); |
---|
123 | rtems_test_exit( 0 ); |
---|
124 | } |
---|
125 | (void) rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); |
---|
126 | } |
---|