Mercurial > ecos
annotate packages/kernel/current/tests/tm_basic.cxx @ 3292:7f8e529b4d82 default tip
Fix FREESCALE_EDMA_NBYTES_MLOFFYES_MLOFF() so it works with negative offsets.
| author | vae |
|---|---|
| date | Wed, 29 Apr 2015 23:31:48 +0000 |
| parents | 4839eca9f0c7 |
| children |
| rev | line source |
|---|---|
| 0 | 1 //========================================================================== |
| 2 // | |
| 3 // tm_basic.cxx | |
| 4 // | |
| 5 // Basic timing test / scaffolding | |
| 6 // | |
| 7 //========================================================================== | |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
8 // ####ECOSGPLCOPYRIGHTBEGIN#### |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
9 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
10 // This file is part of eCos, the Embedded Configurable Operating System. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
177
diff
changeset
|
12 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
13 // eCos is free software; you can redistribute it and/or modify it under |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
14 // the terms of the GNU General Public License as published by the Free |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
15 // Software Foundation; either version 2 or (at your option) any later |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
16 // version. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
177
diff
changeset
|
17 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
18 // eCos is distributed in the hope that it will be useful, but WITHOUT |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
21 // for more details. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
177
diff
changeset
|
22 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
23 // You should have received a copy of the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
24 // along with eCos; if not, write to the Free Software Foundation, Inc., |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
177
diff
changeset
|
26 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
27 // As a special exception, if other files instantiate templates or use |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
28 // macros or inline functions from this file, or you compile this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
29 // and link it with other works to produce a work based on this file, |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
30 // this file does not by itself cause the resulting work to be covered by |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
31 // the GNU General Public License. However the source code for this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
32 // must still be made available in accordance with section (3) of the GNU |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
33 // General Public License v2. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
177
diff
changeset
|
34 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
35 // This exception does not invalidate any other reasons why a work based |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
36 // on this file might be covered by the GNU General Public License. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
37 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2691
diff
changeset
|
38 // ####ECOSGPLCOPYRIGHTEND#### |
| 0 | 39 //========================================================================== |
| 40 //#####DESCRIPTIONBEGIN#### | |
| 41 // | |
| 42 // Author(s): gthomas | |
| 43 // Contributors: gthomas | |
| 44 // Date: 1998-10-19 | |
| 2 | 45 // Description: Very simple kernel timing test |
| 0 | 46 //####DESCRIPTIONEND#### |
| 47 | |
| 48 #include <pkgconf/kernel.h> | |
|
56
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
49 #include <pkgconf/hal.h> |
| 0 | 50 |
| 51 #include <cyg/kernel/sched.hxx> | |
| 52 #include <cyg/kernel/thread.hxx> | |
| 53 #include <cyg/kernel/thread.inl> | |
| 54 #include <cyg/kernel/mutex.hxx> | |
| 55 #include <cyg/kernel/sema.hxx> | |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
56 #include <cyg/kernel/flag.hxx> |
| 0 | 57 #include <cyg/kernel/sched.inl> |
| 58 #include <cyg/kernel/clock.hxx> | |
| 59 #include <cyg/kernel/clock.inl> | |
| 60 #include <cyg/kernel/kapi.h> | |
| 61 | |
| 62 #include <cyg/infra/testcase.h> | |
|
394
7ca632b46393
* tests/tm_basic.cxx: Include infra/diag.h and removed the
asl
parents:
210
diff
changeset
|
63 #include <cyg/infra/diag.h> |
| 2 | 64 |
|
10
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
8
diff
changeset
|
65 #include <cyg/kernel/test/stackmon.h> |
|
56
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
66 #include CYGHWR_MEMORY_LAYOUT_H |
|
8
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
4
diff
changeset
|
67 |
| 2 | 68 // Define this to see the statistics with the first sample datum removed. |
| 69 // This can expose the effects of caches on the speed of operations. | |
| 70 #undef STATS_WITHOUT_FIRST_SAMPLE | |
| 71 | |
| 72 #if defined(CYGFUN_KERNEL_API_C) && \ | |
| 73 defined(CYGSEM_KERNEL_SCHED_MLQUEUE) && \ | |
| 74 defined(CYGVAR_KERNEL_COUNTERS_CLOCK) && \ | |
|
76
435cced73e2f
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
jlarmour
parents:
66
diff
changeset
|
75 !defined(CYGDBG_INFRA_DIAG_USE_DEVICE) && \ |
| 2 | 76 (CYGNUM_KERNEL_SCHED_PRIORITIES > 12) |
| 77 | |
| 0 | 78 #define NTHREADS 1 |
| 79 #include "testaux.hxx" | |
| 80 | |
| 81 // Structure used to keep track of times | |
| 82 typedef struct fun_times { | |
| 83 cyg_uint32 start; | |
| 84 cyg_uint32 end; | |
| 85 } fun_times; | |
| 86 | |
|
2691
7b7441a92f97
* tests/tm_basic.cxx (STACK_SIZE): Revert accidental change of
jlarmour
parents:
2635
diff
changeset
|
87 #define STACK_SIZE CYGNUM_HAL_STACK_SIZE_MINIMUM |
|
56
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
88 |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
89 #ifdef CYGMEM_REGION_ram_SIZE |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
90 #define CYG_THREAD_OVERHEAD (STACK_SIZE+sizeof(cyg_thread)+(sizeof(fun_times)*2)) |
| 3043 | 91 #define NTEST_THREADS_AVAIL ((CYGMEM_REGION_ram_SIZE/16)/CYG_THREAD_OVERHEAD) |
| 92 #define NTEST_THREADS (2>(NTEST_THREADS_AVAIL)?2:(NTEST_THREADS_AVAIL)) | |
|
56
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
93 #define CYG_MUTEX_OVERHEAD (sizeof(cyg_mutex_t)+sizeof(fun_times)) |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
94 #define NMUTEXES ((CYGMEM_REGION_ram_SIZE/16)/CYG_MUTEX_OVERHEAD) |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
95 #define CYG_MBOX_OVERHEAD (sizeof(cyg_mbox)+sizeof(fun_times)) |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
96 #define NMBOXES ((CYGMEM_REGION_ram_SIZE/24)/CYG_MBOX_OVERHEAD) |
|
56
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
97 #define CYG_SEMAPHORE_OVERHEAD (sizeof(cyg_sem_t)+sizeof(fun_times)) |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
98 #define NSEMAPHORES ((CYGMEM_REGION_ram_SIZE/16)/CYG_SEMAPHORE_OVERHEAD) |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
99 #define CYG_COUNTER_OVERHEAD (sizeof(cyg_counter)+sizeof(fun_times)) |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
100 #define NCOUNTERS ((CYGMEM_REGION_ram_SIZE/24)/CYG_COUNTER_OVERHEAD) |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
101 #define CYG_FLAG_OVERHEAD (sizeof(cyg_flag_t)+sizeof(fun_times)) |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
102 #define NFLAGS ((CYGMEM_REGION_ram_SIZE/24)/CYG_FLAG_OVERHEAD) |
|
56
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
103 #define CYG_ALARM_OVERHEAD (sizeof(cyg_alarm)+sizeof(fun_times)) |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
104 #define NALARMS ((CYGMEM_REGION_ram_SIZE/16)/CYG_ALARM_OVERHEAD) |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
105 #else |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
106 // Defaults |
|
4
1d7f19c9e4d1
Merge from eCos master repository on 1999-05-11-21:11:10-BST
jlarmour
parents:
2
diff
changeset
|
107 #define NTEST_THREADS 16 |
| 0 | 108 #define NMUTEXES 32 |
| 109 #define NMBOXES 32 | |
| 110 #define NSEMAPHORES 32 | |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
111 #define NFLAGS 32 |
| 0 | 112 #define NCOUNTERS 32 |
| 113 #define NALARMS 32 | |
|
56
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
114 #endif |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
115 |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
116 #define NSAMPLES 32 |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
117 #define NTHREAD_SWITCHES 128 |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
118 #define NSCHEDS 128 |
| 0 | 119 |
| 2 | 120 #define NSAMPLES_SIM 2 |
| 121 #define NTEST_THREADS_SIM 2 | |
| 122 #define NTHREAD_SWITCHES_SIM 4 | |
| 123 #define NMUTEXES_SIM 2 | |
| 124 #define NMBOXES_SIM 2 | |
| 125 #define NSEMAPHORES_SIM 2 | |
| 126 #define NSCHEDS_SIM 4 | |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
127 #define NFLAGS_SIM 2 |
| 2 | 128 #define NCOUNTERS_SIM 2 |
| 129 #define NALARMS_SIM 2 | |
| 130 | |
| 131 static int nsamples; | |
| 132 static int ntest_threads; | |
| 133 static int nthread_switches; | |
| 134 static int nmutexes; | |
| 135 static int nmboxes; | |
| 136 static int nsemaphores; | |
| 137 static int nscheds; | |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
138 static int nflags; |
| 2 | 139 static int ncounters; |
| 140 static int nalarms; | |
| 141 | |
| 0 | 142 static char stacks[NTEST_THREADS][STACK_SIZE]; |
| 143 static cyg_thread test_threads[NTEST_THREADS]; | |
| 144 static cyg_handle_t threads[NTEST_THREADS]; | |
| 145 static int overhead; | |
| 146 static cyg_sem_t synchro; | |
| 147 static fun_times thread_ft[NTEST_THREADS]; | |
| 148 | |
| 149 static fun_times test2_ft[NTHREAD_SWITCHES]; | |
| 150 | |
| 151 static cyg_mutex_t test_mutexes[NMUTEXES]; | |
| 152 static fun_times mutex_ft[NMUTEXES]; | |
| 153 static cyg_thread mutex_test_thread; | |
| 154 static cyg_handle_t mutex_test_thread_handle; | |
| 155 | |
| 156 static cyg_mbox test_mboxes[NMBOXES]; | |
| 157 static cyg_handle_t test_mbox_handles[NMBOXES]; | |
| 158 static fun_times mbox_ft[NMBOXES]; | |
|
210
d2c90368aeef
Merge from eCos master repository on 2002-05-23-21:39:14-BST
jlarmour
parents:
208
diff
changeset
|
159 #ifdef CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT |
| 0 | 160 static cyg_thread mbox_test_thread; |
| 161 static cyg_handle_t mbox_test_thread_handle; | |
|
210
d2c90368aeef
Merge from eCos master repository on 2002-05-23-21:39:14-BST
jlarmour
parents:
208
diff
changeset
|
162 #endif |
| 0 | 163 |
| 164 static cyg_sem_t test_semaphores[NSEMAPHORES]; | |
| 165 static fun_times semaphore_ft[NSEMAPHORES]; | |
| 166 static cyg_thread semaphore_test_thread; | |
| 167 static cyg_handle_t semaphore_test_thread_handle; | |
| 168 | |
| 169 static fun_times sched_ft[NSCHEDS]; | |
| 170 | |
| 171 static cyg_counter test_counters[NCOUNTERS]; | |
| 172 static cyg_handle_t counters[NCOUNTERS]; | |
| 173 static fun_times counter_ft[NCOUNTERS]; | |
| 174 | |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
175 static cyg_flag_t test_flags[NFLAGS]; |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
176 static fun_times flag_ft[NFLAGS]; |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
177 |
| 0 | 178 static cyg_alarm test_alarms[NALARMS]; |
| 179 static cyg_handle_t alarms[NALARMS]; | |
| 180 static fun_times alarm_ft[NALARMS]; | |
| 181 | |
| 2 | 182 static long rtc_resolution[] = CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION; |
| 183 static long ns_per_system_clock; | |
| 184 | |
|
210
d2c90368aeef
Merge from eCos master repository on 2002-05-23-21:39:14-BST
jlarmour
parents:
208
diff
changeset
|
185 #if defined(CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY) && defined(HAL_CLOCK_LATENCY) |
| 2 | 186 // Data kept by kernel real time clock measuring clock interrupt latency |
| 187 extern cyg_tick_count total_clock_latency, total_clock_interrupts; | |
| 188 extern cyg_int32 min_clock_latency, max_clock_latency; | |
| 189 extern bool measure_clock_latency; | |
| 190 #endif | |
| 191 | |
|
210
d2c90368aeef
Merge from eCos master repository on 2002-05-23-21:39:14-BST
jlarmour
parents:
208
diff
changeset
|
192 #if defined(CYGVAR_KERNEL_COUNTERS_CLOCK_DSR_LATENCY) && defined(HAL_CLOCK_LATENCY) |
|
34
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
193 extern cyg_tick_count total_clock_dsr_latency, total_clock_dsr_calls; |
|
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
194 extern cyg_int32 min_clock_dsr_latency, max_clock_dsr_latency; |
|
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
195 extern bool measure_clock_latency; |
|
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
196 #endif |
|
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
197 |
| 0 | 198 void run_sched_tests(void); |
| 199 void run_thread_tests(void); | |
| 200 void run_thread_switch_test(void); | |
| 201 void run_mutex_tests(void); | |
| 202 void run_mutex_circuit_test(void); | |
| 203 void run_mbox_tests(void); | |
| 204 void run_mbox_circuit_test(void); | |
| 205 void run_semaphore_tests(void); | |
| 206 void run_semaphore_circuit_test(void); | |
| 207 void run_counter_tests(void); | |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
208 void run_flag_tests(void); |
| 0 | 209 void run_alarm_tests(void); |
| 210 | |
|
2635
8f706d6bdc35
* tests/tm_basic.cxx (max): Actually the meaning was right before,
jlarmour
parents:
2624
diff
changeset
|
211 #ifndef min |
|
8f706d6bdc35
* tests/tm_basic.cxx (max): Actually the meaning was right before,
jlarmour
parents:
2624
diff
changeset
|
212 #define min(X,Y) ((X) < (Y) ? (X) : (Y)) |
|
56
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
213 #endif |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
214 |
| 0 | 215 // Wait until a clock tick [real time clock] has passed. This should keep it |
| 216 // from happening again during a measurement, thus minimizing any fluctuations | |
| 217 void | |
| 218 wait_for_tick(void) | |
| 219 { | |
| 2 | 220 cyg_tick_count_t tv0, tv1; |
| 221 tv0 = cyg_current_time(); | |
| 0 | 222 while (true) { |
| 2 | 223 tv1 = cyg_current_time(); |
| 224 if (tv1 != tv0) break; | |
| 225 } | |
| 226 } | |
| 227 | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
228 #ifdef HAL_CLOCK_READ_NS |
|
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
229 #define READ_CLOCK(__x) HAL_CLOCK_READ_NS(__x) |
|
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
230 #define NSTICK (1) |
|
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
231 #else |
|
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
232 #define READ_CLOCK(__x) HAL_CLOCK_READ(__x) |
|
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
233 #define NSTICK (1000) |
|
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
234 #endif |
| 2 | 235 // Display a number of ticks as microseconds |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
236 // Note: for improved calculation significance, values are kept in ticks*NSTICK |
| 2 | 237 void |
| 238 show_ticks_in_us(cyg_uint32 ticks) | |
| 239 { | |
| 240 long long ns; | |
| 241 ns = (ns_per_system_clock * (long long)ticks) / CYGNUM_KERNEL_COUNTERS_RTC_PERIOD; | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
242 #ifdef HAL_CLOCK_READ_NS |
|
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
243 diag_printf("%4d.%03d", (int)(ns/1000), (int)(ns%1000)); |
|
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
244 #else |
| 2 | 245 ns += 5; // for rounding to .01us |
| 246 diag_printf("%5d.%02d", (int)(ns/1000), (int)((ns%1000)/10)); | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
247 #endif |
| 2 | 248 } |
| 249 | |
| 250 // | |
| 251 // If the kernel is instrumented to measure clock interrupt latency, these | |
| 252 // measurements can be drastically perturbed by printing via "diag_printf()" | |
| 253 // since that code may run with interrupts disabled for long periods. | |
| 254 // | |
| 255 // In order to get accurate/reasonable latency figures _for the kernel | |
| 256 // primitive functions beint tested_, the kernel's latency measurements | |
| 257 // are suspended while the printing actually takes place. | |
| 258 // | |
| 259 // The measurements are reenabled after the printing, thus allowing for | |
| 260 // fair measurements of the kernel primitives, which are not distorted | |
| 261 // by the printing mechanisms. | |
| 262 | |
|
34
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
263 #if defined(CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY) && defined(HAL_CLOCK_LATENCY) |
| 2 | 264 void |
| 265 disable_clock_latency_measurement(void) | |
| 266 { | |
| 267 wait_for_tick(); | |
| 268 measure_clock_latency = false; | |
| 269 } | |
| 270 | |
| 271 void | |
| 272 enable_clock_latency_measurement(void) | |
| 273 { | |
| 274 wait_for_tick(); | |
| 275 measure_clock_latency = true; | |
| 276 } | |
| 277 | |
| 278 // Ensure that the measurements are reasonable (no startup anomalies) | |
| 279 void | |
| 280 reset_clock_latency_measurement(void) | |
| 281 { | |
| 282 disable_clock_latency_measurement(); | |
| 283 total_clock_latency = 0; | |
| 284 total_clock_interrupts = 0; | |
| 285 min_clock_latency = 0x7FFFFFFF; | |
| 286 max_clock_latency = 0; | |
|
210
d2c90368aeef
Merge from eCos master repository on 2002-05-23-21:39:14-BST
jlarmour
parents:
208
diff
changeset
|
287 #if defined(CYGVAR_KERNEL_COUNTERS_CLOCK_DSR_LATENCY) && defined(HAL_CLOCK_LATENCY) |
|
34
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
288 total_clock_dsr_latency = 0; |
|
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
289 total_clock_dsr_calls = 0; |
|
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
290 min_clock_dsr_latency = 0x7FFFFFFF; |
|
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
291 max_clock_dsr_latency = 0; |
|
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
292 #endif |
| 2 | 293 enable_clock_latency_measurement(); |
|
34
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
294 |
| 2 | 295 } |
| 296 #else | |
| 297 #define disable_clock_latency_measurement() | |
| 298 #define enable_clock_latency_measurement() | |
| 299 #define reset_clock_latency_measurement() | |
| 300 #endif | |
| 301 | |
| 302 void | |
| 303 show_times_hdr(void) | |
| 304 { | |
| 305 disable_clock_latency_measurement(); | |
| 306 diag_printf("\n"); | |
| 307 diag_printf(" Confidence\n"); | |
| 308 diag_printf(" Ave Min Max Var Ave Min Function\n"); | |
| 309 diag_printf(" ====== ====== ====== ====== ========== ========\n"); | |
| 310 enable_clock_latency_measurement(); | |
| 311 } | |
| 312 | |
| 313 void | |
| 314 show_times_detail(fun_times ft[], int nsamples, char *title, bool ignore_first) | |
| 315 { | |
| 316 int i, delta, min, max, con_ave, con_min, ave_dev; | |
| 317 int start_sample, total_samples; | |
| 318 cyg_int32 total, ave; | |
| 319 | |
| 320 if (ignore_first) { | |
| 321 start_sample = 1; | |
| 322 total_samples = nsamples-1; | |
| 323 } else { | |
| 324 start_sample = 0; | |
| 325 total_samples = nsamples; | |
| 0 | 326 } |
| 2 | 327 total = 0; |
| 328 min = 0x7FFFFFFF; | |
| 329 max = 0; | |
| 330 for (i = start_sample; i < nsamples; i++) { | |
| 331 if (ft[i].end < ft[i].start) { | |
| 332 // Clock wrapped around (timer tick) | |
| 333 delta = (ft[i].end+CYGNUM_KERNEL_COUNTERS_RTC_PERIOD) - ft[i].start; | |
| 334 } else { | |
| 335 delta = ft[i].end - ft[i].start; | |
| 336 } | |
| 337 delta -= overhead; | |
| 338 if (delta < 0) delta = 0; | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
339 delta *= NSTICK; |
| 2 | 340 total += delta; |
| 341 if (delta < min) min = delta; | |
| 342 if (delta > max) max = delta; | |
| 343 } | |
| 344 ave = total / total_samples; | |
| 345 total = 0; | |
| 346 ave_dev = 0; | |
| 347 for (i = start_sample; i < nsamples; i++) { | |
| 348 if (ft[i].end < ft[i].start) { | |
| 349 // Clock wrapped around (timer tick) | |
| 350 delta = (ft[i].end+CYGNUM_KERNEL_COUNTERS_RTC_PERIOD) - ft[i].start; | |
| 351 } else { | |
| 352 delta = ft[i].end - ft[i].start; | |
| 353 } | |
| 354 delta -= overhead; | |
| 355 if (delta < 0) delta = 0; | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
356 delta *= NSTICK; |
| 2 | 357 delta = delta - ave; |
| 358 if (delta < 0) delta = -delta; | |
| 359 ave_dev += delta; | |
| 360 } | |
| 361 ave_dev /= total_samples; | |
| 362 con_ave = 0; | |
| 363 con_min = 0; | |
| 364 for (i = start_sample; i < nsamples; i++) { | |
| 365 if (ft[i].end < ft[i].start) { | |
| 366 // Clock wrapped around (timer tick) | |
| 367 delta = (ft[i].end+CYGNUM_KERNEL_COUNTERS_RTC_PERIOD) - ft[i].start; | |
| 368 } else { | |
| 369 delta = ft[i].end - ft[i].start; | |
| 370 } | |
| 371 delta -= overhead; | |
| 372 if (delta < 0) delta = 0; | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
373 delta *= NSTICK; |
| 2 | 374 if ((delta <= (ave+ave_dev)) && (delta >= (ave-ave_dev))) con_ave++; |
| 375 if ((delta <= (min+ave_dev)) && (delta >= (min-ave_dev))) con_min++; | |
| 376 } | |
| 377 con_ave = (con_ave * 100) / total_samples; | |
| 378 con_min = (con_min * 100) / total_samples; | |
| 379 show_ticks_in_us(ave); | |
| 380 show_ticks_in_us(min); | |
| 381 show_ticks_in_us(max); | |
| 382 show_ticks_in_us(ave_dev); | |
| 383 disable_clock_latency_measurement(); | |
| 384 diag_printf(" %3d%% %3d%%", con_ave, con_min); | |
| 385 diag_printf(" %s\n", title); | |
| 386 enable_clock_latency_measurement(); | |
| 387 } | |
| 388 | |
| 389 void | |
| 390 show_times(fun_times ft[], int nsamples, char *title) | |
| 391 { | |
| 392 show_times_detail(ft, nsamples, title, false); | |
| 393 #ifdef STATS_WITHOUT_FIRST_SAMPLE | |
| 394 show_times_detail(ft, nsamples, "", true); | |
| 395 #endif | |
| 396 } | |
| 397 | |
| 398 void | |
| 399 show_test_parameters(void) | |
| 400 { | |
| 401 disable_clock_latency_measurement(); | |
| 402 diag_printf("\nTesting parameters:\n"); | |
|
56
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
403 diag_printf(" Clock samples: %5d\n", nsamples); |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
404 diag_printf(" Threads: %5d\n", ntest_threads); |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
405 diag_printf(" Thread switches: %5d\n", nthread_switches); |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
406 diag_printf(" Mutexes: %5d\n", nmutexes); |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
407 diag_printf(" Mailboxes: %5d\n", nmboxes); |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
408 diag_printf(" Semaphores: %5d\n", nsemaphores); |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
409 diag_printf(" Scheduler operations: %5d\n", nscheds); |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
410 diag_printf(" Counters: %5d\n", ncounters); |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
411 diag_printf(" Flags: %5d\n", nflags); |
|
56
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
412 diag_printf(" Alarms: %5d\n", nalarms); |
| 2 | 413 diag_printf("\n"); |
| 414 enable_clock_latency_measurement(); | |
| 415 } | |
| 416 | |
| 417 void | |
| 418 end_of_test_group(void) | |
| 419 { | |
| 420 disable_clock_latency_measurement(); | |
| 421 diag_printf("\n"); | |
| 422 enable_clock_latency_measurement(); | |
| 0 | 423 } |
| 424 | |
| 425 // Compute a name for a thread | |
| 426 char * | |
| 427 thread_name(char *basename, int indx) { | |
| 428 return "<<NULL>>"; // Not currently used | |
| 429 } | |
| 430 | |
| 431 // test0 - null test, never executed | |
| 432 void | |
| 433 test0(cyg_uint32 indx) | |
| 434 { | |
|
177
4c750ce71ae3
Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents:
161
diff
changeset
|
435 #ifndef CYGPKG_KERNEL_SMP_SUPPORT |
|
4c750ce71ae3
Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents:
161
diff
changeset
|
436 // In SMP, somw of these threads will execute |
| 0 | 437 diag_printf("test0.%d executed?\n", indx); |
|
177
4c750ce71ae3
Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents:
161
diff
changeset
|
438 #endif |
| 0 | 439 cyg_thread_exit(); |
| 440 } | |
| 441 | |
| 442 // test1 - empty test, simply exit. Last thread signals parent. | |
| 443 void | |
| 444 test1(cyg_uint32 indx) | |
| 445 { | |
| 2 | 446 if (indx == (cyg_uint32)(ntest_threads-1)) { |
| 0 | 447 cyg_semaphore_post(&synchro); // Signal that last thread is dying |
| 448 } | |
| 449 cyg_thread_exit(); | |
| 450 } | |
| 451 | |
| 452 // test2 - measure thread switch times | |
| 453 void | |
| 454 test2(cyg_uint32 indx) | |
| 455 { | |
| 456 int i; | |
| 2 | 457 for (i = 0; i < nthread_switches; i++) { |
| 0 | 458 if (indx == 0) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
459 READ_CLOCK(&test2_ft[i].start); |
| 0 | 460 } else { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
461 READ_CLOCK(&test2_ft[i].end); |
| 0 | 462 } |
| 463 cyg_thread_yield(); | |
| 464 } | |
| 465 if (indx == 1) { | |
| 466 cyg_semaphore_post(&synchro); | |
| 467 } | |
| 468 cyg_thread_exit(); | |
| 469 } | |
| 470 | |
| 471 // Full-circuit mutex unlock/lock test | |
| 472 void | |
| 473 mutex_test(cyg_uint32 indx) | |
| 474 { | |
| 475 int i; | |
| 476 cyg_mutex_lock(&test_mutexes[0]); | |
| 2 | 477 for (i = 0; i < nmutexes; i++) { |
| 0 | 478 cyg_semaphore_wait(&synchro); |
| 479 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
480 READ_CLOCK(&mutex_ft[i].start); |
| 0 | 481 cyg_mutex_unlock(&test_mutexes[0]); |
| 482 cyg_mutex_lock(&test_mutexes[0]); | |
| 483 cyg_semaphore_post(&synchro); | |
| 484 } | |
| 485 cyg_thread_exit(); | |
| 486 } | |
| 487 | |
| 488 // Full-circuit mbox put/get test | |
| 489 void | |
| 490 mbox_test(cyg_uint32 indx) | |
| 491 { | |
| 492 void *item; | |
| 493 do { | |
| 494 item = cyg_mbox_get(test_mbox_handles[0]); | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
495 READ_CLOCK(&mbox_ft[(int)item].end); |
| 0 | 496 cyg_semaphore_post(&synchro); |
| 2 | 497 } while ((int)item != (nmboxes-1)); |
| 0 | 498 cyg_thread_exit(); |
| 499 } | |
| 500 | |
| 501 // Full-circuit semaphore post/wait test | |
| 502 void | |
| 503 semaphore_test(cyg_uint32 indx) | |
| 504 { | |
| 505 int i; | |
| 2 | 506 for (i = 0; i < nsemaphores; i++) { |
| 0 | 507 cyg_semaphore_wait(&test_semaphores[0]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
508 READ_CLOCK(&semaphore_ft[i].end); |
| 0 | 509 cyg_semaphore_post(&synchro); |
| 510 } | |
| 511 cyg_thread_exit(); | |
| 512 } | |
| 513 | |
| 2 | 514 // |
| 515 // This set of tests is used to measure kernel primitives that deal with threads | |
| 516 // | |
| 0 | 517 void |
| 518 run_thread_tests(void) | |
| 519 { | |
| 520 int i; | |
| 521 | |
| 522 // Set my priority higher than any I plan to create | |
| 523 cyg_thread_set_priority(cyg_thread_self(), 2); | |
| 524 | |
| 525 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 526 for (i = 0; i < ntest_threads; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
527 READ_CLOCK(&thread_ft[i].start); |
| 0 | 528 cyg_thread_create(10, // Priority - just a number |
| 529 test0, // entry | |
| 530 i, // index | |
| 531 thread_name("thread", i), // Name | |
| 532 &stacks[i][0], // Stack | |
| 533 STACK_SIZE, // Size | |
| 534 &threads[i], // Handle | |
| 535 &test_threads[i] // Thread data structure | |
| 536 ); | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
537 READ_CLOCK(&thread_ft[i].end); |
| 0 | 538 } |
| 2 | 539 show_times(thread_ft, ntest_threads, "Create thread"); |
| 0 | 540 |
| 541 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 542 for (i = 0; i < ntest_threads; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
543 READ_CLOCK(&thread_ft[i].start); |
| 0 | 544 cyg_thread_yield(); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
545 READ_CLOCK(&thread_ft[i].end); |
| 0 | 546 } |
| 2 | 547 show_times(thread_ft, ntest_threads, "Yield thread [all suspended]"); |
| 0 | 548 |
| 549 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 550 for (i = 0; i < ntest_threads; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
551 READ_CLOCK(&thread_ft[i].start); |
| 0 | 552 cyg_thread_suspend(threads[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
553 READ_CLOCK(&thread_ft[i].end); |
| 0 | 554 } |
| 2 | 555 show_times(thread_ft, ntest_threads, "Suspend [suspended] thread"); |
| 0 | 556 |
| 557 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 558 for (i = 0; i < ntest_threads; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
559 READ_CLOCK(&thread_ft[i].start); |
| 0 | 560 cyg_thread_resume(threads[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
561 READ_CLOCK(&thread_ft[i].end); |
| 0 | 562 } |
| 2 | 563 show_times(thread_ft, ntest_threads, "Resume thread"); |
| 0 | 564 |
| 565 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 566 for (i = 0; i < ntest_threads; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
567 READ_CLOCK(&thread_ft[i].start); |
| 0 | 568 cyg_thread_set_priority(threads[i], 11); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
569 READ_CLOCK(&thread_ft[i].end); |
| 0 | 570 } |
| 2 | 571 show_times(thread_ft, ntest_threads, "Set priority"); |
| 0 | 572 |
| 573 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 574 for (i = 0; i < ntest_threads; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
575 READ_CLOCK(&thread_ft[i].start); |
|
3132
80f232caf539
* tests/except1.cxx (cause_exception): Fix compiler warning about
sergeig
parents:
3043
diff
changeset
|
576 cyg_thread_get_priority(threads[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
577 READ_CLOCK(&thread_ft[i].end); |
| 0 | 578 } |
| 2 | 579 show_times(thread_ft, ntest_threads, "Get priority"); |
| 0 | 580 |
| 581 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 582 for (i = 0; i < ntest_threads; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
583 READ_CLOCK(&thread_ft[i].start); |
| 0 | 584 cyg_thread_kill(threads[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
585 READ_CLOCK(&thread_ft[i].end); |
| 0 | 586 } |
| 2 | 587 show_times(thread_ft, ntest_threads, "Kill [suspended] thread"); |
| 0 | 588 |
| 589 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 590 for (i = 0; i < ntest_threads; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
591 READ_CLOCK(&thread_ft[i].start); |
| 0 | 592 cyg_thread_yield(); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
593 READ_CLOCK(&thread_ft[i].end); |
| 0 | 594 } |
| 2 | 595 show_times(thread_ft, ntest_threads, "Yield [no other] thread"); |
| 0 | 596 |
| 597 // Set my priority higher than any I plan to create | |
| 598 cyg_thread_set_priority(cyg_thread_self(), 2); | |
| 599 | |
| 600 // Recreate the test set | |
| 2 | 601 for (i = 0; i < ntest_threads; i++) { |
| 0 | 602 cyg_thread_create(10, // Priority - just a number |
| 603 test0, // entry | |
| 604 i, // index | |
| 605 thread_name("thread", i), // Name | |
| 606 &stacks[i][0], // Stack | |
| 607 STACK_SIZE, // Size | |
| 608 &threads[i], // Handle | |
| 609 &test_threads[i] // Thread data structure | |
| 610 ); | |
| 611 } | |
| 612 | |
| 613 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 614 for (i = 0; i < ntest_threads; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
615 READ_CLOCK(&thread_ft[i].start); |
| 2 | 616 cyg_thread_resume(threads[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
617 READ_CLOCK(&thread_ft[i].end); |
| 2 | 618 } |
| 619 show_times(thread_ft, ntest_threads, "Resume [suspended low prio] thread"); | |
| 620 | |
| 621 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 622 for (i = 0; i < ntest_threads; i++) { | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
623 READ_CLOCK(&thread_ft[i].start); |
| 0 | 624 cyg_thread_resume(threads[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
625 READ_CLOCK(&thread_ft[i].end); |
| 0 | 626 } |
| 2 | 627 show_times(thread_ft, ntest_threads, "Resume [runnable low prio] thread"); |
| 0 | 628 |
| 629 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 630 for (i = 0; i < ntest_threads; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
631 READ_CLOCK(&thread_ft[i].start); |
| 2 | 632 cyg_thread_suspend(threads[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
633 READ_CLOCK(&thread_ft[i].end); |
| 0 | 634 } |
| 2 | 635 show_times(thread_ft, ntest_threads, "Suspend [runnable] thread"); |
| 636 | |
| 0 | 637 |
| 638 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 639 for (i = 0; i < ntest_threads; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
640 READ_CLOCK(&thread_ft[i].start); |
| 2 | 641 cyg_thread_yield(); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
642 READ_CLOCK(&thread_ft[i].end); |
| 2 | 643 } |
| 644 show_times(thread_ft, ntest_threads, "Yield [only low prio] thread"); | |
| 645 | |
| 646 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 647 for (i = 0; i < ntest_threads; i++) { | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
648 READ_CLOCK(&thread_ft[i].start); |
| 0 | 649 cyg_thread_suspend(threads[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
650 READ_CLOCK(&thread_ft[i].end); |
| 0 | 651 } |
| 2 | 652 show_times(thread_ft, ntest_threads, "Suspend [runnable->not runnable]"); |
| 653 for (i = 0; i < ntest_threads; i++) { | |
| 0 | 654 cyg_thread_resume(threads[i]); |
| 655 } | |
| 656 | |
| 657 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 658 for (i = 0; i < ntest_threads; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
659 READ_CLOCK(&thread_ft[i].start); |
| 0 | 660 cyg_thread_kill(threads[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
661 READ_CLOCK(&thread_ft[i].end); |
| 0 | 662 } |
| 2 | 663 show_times(thread_ft, ntest_threads, "Kill [runnable] thread"); |
| 664 | |
| 665 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 666 for (i = 0; i < ntest_threads; i++) { | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
667 READ_CLOCK(&thread_ft[i].start); |
| 2 | 668 cyg_thread_delete(threads[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
669 READ_CLOCK(&thread_ft[i].end); |
| 2 | 670 } |
| 671 show_times(thread_ft, ntest_threads, "Destroy [dead] thread"); | |
| 672 | |
| 673 // Recreate the test set | |
| 674 for (i = 0; i < ntest_threads; i++) { | |
| 675 cyg_thread_create(10, // Priority - just a number | |
| 676 test0, // entry | |
| 677 i, // index | |
| 678 thread_name("thread", i), // Name | |
| 679 &stacks[i][0], // Stack | |
| 680 STACK_SIZE, // Size | |
| 681 &threads[i], // Handle | |
| 682 &test_threads[i] // Thread data structure | |
| 683 ); | |
| 684 cyg_thread_resume(threads[i]); | |
| 685 } | |
| 686 | |
| 687 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 688 for (i = 0; i < ntest_threads; i++) { | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
689 READ_CLOCK(&thread_ft[i].start); |
| 2 | 690 cyg_thread_delete(threads[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
691 READ_CLOCK(&thread_ft[i].end); |
| 2 | 692 } |
| 693 show_times(thread_ft, ntest_threads, "Destroy [runnable] thread"); | |
| 694 | |
| 0 | 695 // Set my priority lower than any I plan to create |
| 696 cyg_thread_set_priority(cyg_thread_self(), 3); | |
| 697 | |
| 698 // Set up the end-of-threads synchronizer | |
| 699 cyg_semaphore_init(&synchro, 0); | |
| 700 | |
| 701 // Recreate the test set | |
| 2 | 702 for (i = 0; i < ntest_threads; i++) { |
| 0 | 703 cyg_thread_create(2, // Priority - just a number |
| 704 test1, // entry | |
| 705 i, // index | |
| 706 thread_name("thread", i), // Name | |
| 707 &stacks[i][0], // Stack | |
| 708 STACK_SIZE, // Size | |
| 709 &threads[i], // Handle | |
| 710 &test_threads[i] // Thread data structure | |
| 711 ); | |
| 712 } | |
| 713 | |
| 714 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 715 for (i = 0; i < ntest_threads; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
716 READ_CLOCK(&thread_ft[i].start); |
| 0 | 717 cyg_thread_resume(threads[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
718 READ_CLOCK(&thread_ft[i].end); |
| 0 | 719 } |
| 2 | 720 show_times(thread_ft, ntest_threads, "Resume [high priority] thread"); |
| 0 | 721 cyg_semaphore_wait(&synchro); // Wait for all threads to finish |
| 722 // Make sure they are all dead | |
| 2 | 723 for (i = 0; i < ntest_threads; i++) { |
| 724 cyg_thread_delete(threads[i]); | |
| 0 | 725 } |
| 726 | |
| 727 run_thread_switch_test(); | |
| 2 | 728 end_of_test_group(); |
| 0 | 729 } |
| 730 | |
| 731 void | |
| 732 run_thread_switch_test(void) | |
| 733 { | |
| 734 int i; | |
| 735 | |
| 736 // Set up for thread context switch | |
| 737 for (i = 0; i < 2; i++) { | |
| 738 cyg_thread_create(10, // Priority - just a number | |
| 739 test2, // entry | |
| 740 i, // index | |
| 741 thread_name("thread", i), // Name | |
| 742 &stacks[i][0], // Stack | |
| 743 STACK_SIZE, // Size | |
| 744 &threads[i], // Handle | |
| 745 &test_threads[i] // Thread data structure | |
| 746 ); | |
| 747 cyg_thread_resume(threads[i]); | |
| 748 } | |
| 749 // Set up the end-of-threads synchronizer | |
| 750 cyg_semaphore_init(&synchro, 0); | |
| 751 cyg_semaphore_wait(&synchro); | |
| 752 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 753 show_times(test2_ft, nthread_switches, "Thread switch"); |
| 0 | 754 // Clean up |
| 755 for (i = 0; i < 2; i++) { | |
| 2 | 756 cyg_thread_delete(threads[i]); |
| 0 | 757 } |
| 758 } | |
| 759 | |
| 760 void | |
| 761 run_mutex_tests(void) | |
| 762 { | |
| 763 int i; | |
| 764 | |
| 765 // Mutex primitives | |
| 766 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 767 for (i = 0; i < nmutexes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
768 READ_CLOCK(&mutex_ft[i].start); |
| 0 | 769 cyg_mutex_init(&test_mutexes[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
770 READ_CLOCK(&mutex_ft[i].end); |
| 0 | 771 } |
| 2 | 772 show_times(mutex_ft, nmutexes, "Init mutex"); |
| 0 | 773 |
| 774 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 775 for (i = 0; i < nmutexes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
776 READ_CLOCK(&mutex_ft[i].start); |
| 0 | 777 cyg_mutex_lock(&test_mutexes[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
778 READ_CLOCK(&mutex_ft[i].end); |
| 0 | 779 } |
| 2 | 780 show_times(mutex_ft, nmutexes, "Lock [unlocked] mutex"); |
| 0 | 781 |
| 782 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 783 for (i = 0; i < nmutexes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
784 READ_CLOCK(&mutex_ft[i].start); |
| 0 | 785 cyg_mutex_unlock(&test_mutexes[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
786 READ_CLOCK(&mutex_ft[i].end); |
| 0 | 787 } |
| 2 | 788 show_times(mutex_ft, nmutexes, "Unlock [locked] mutex"); |
| 0 | 789 |
| 790 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 791 for (i = 0; i < nmutexes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
792 READ_CLOCK(&mutex_ft[i].start); |
| 0 | 793 cyg_mutex_trylock(&test_mutexes[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
794 READ_CLOCK(&mutex_ft[i].end); |
| 0 | 795 } |
| 2 | 796 show_times(mutex_ft, nmutexes, "Trylock [unlocked] mutex"); |
| 0 | 797 |
| 798 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 799 for (i = 0; i < nmutexes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
800 READ_CLOCK(&mutex_ft[i].start); |
| 0 | 801 cyg_mutex_trylock(&test_mutexes[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
802 READ_CLOCK(&mutex_ft[i].end); |
| 0 | 803 } |
| 2 | 804 show_times(mutex_ft, nmutexes, "Trylock [locked] mutex"); |
| 0 | 805 |
|
38
e7ba79f6d3a8
Merge from eCos master repository on 1999-09-23-20:10:25-BST
jlarmour
parents:
34
diff
changeset
|
806 // Must unlock mutices before destroying them. |
|
e7ba79f6d3a8
Merge from eCos master repository on 1999-09-23-20:10:25-BST
jlarmour
parents:
34
diff
changeset
|
807 for (i = 0; i < nmutexes; i++) { |
|
e7ba79f6d3a8
Merge from eCos master repository on 1999-09-23-20:10:25-BST
jlarmour
parents:
34
diff
changeset
|
808 cyg_mutex_unlock(&test_mutexes[i]); |
|
e7ba79f6d3a8
Merge from eCos master repository on 1999-09-23-20:10:25-BST
jlarmour
parents:
34
diff
changeset
|
809 } |
|
e7ba79f6d3a8
Merge from eCos master repository on 1999-09-23-20:10:25-BST
jlarmour
parents:
34
diff
changeset
|
810 |
| 0 | 811 wait_for_tick(); // Wait until the next clock tick to minimize aberations |
| 2 | 812 for (i = 0; i < nmutexes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
813 READ_CLOCK(&mutex_ft[i].start); |
| 0 | 814 cyg_mutex_destroy(&test_mutexes[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
815 READ_CLOCK(&mutex_ft[i].end); |
| 0 | 816 } |
| 2 | 817 show_times(mutex_ft, nmutexes, "Destroy mutex"); |
| 0 | 818 run_mutex_circuit_test(); |
| 2 | 819 end_of_test_group(); |
| 0 | 820 } |
| 821 | |
| 822 void | |
| 823 run_mutex_circuit_test(void) | |
| 824 { | |
| 825 int i; | |
| 826 // Set my priority lower than any I plan to create | |
| 827 cyg_thread_set_priority(cyg_thread_self(), 4); | |
| 828 // Set up for full mutex unlock/lock test | |
| 829 cyg_mutex_init(&test_mutexes[0]); | |
| 830 cyg_semaphore_init(&synchro, 0); | |
| 831 cyg_thread_create(3, // Priority - just a number | |
| 832 mutex_test, // entry | |
| 833 0, // index | |
| 834 thread_name("thread", 0), // Name | |
| 835 &stacks[0][0], // Stack | |
| 836 STACK_SIZE, // Size | |
| 837 &mutex_test_thread_handle, // Handle | |
| 838 &mutex_test_thread // Thread data structure | |
| 839 ); | |
| 840 cyg_thread_resume(mutex_test_thread_handle); | |
| 841 // Need to raise priority so that this thread will block on the "lock" | |
| 842 cyg_thread_set_priority(cyg_thread_self(), 2); | |
| 2 | 843 for (i = 0; i < nmutexes; i++) { |
| 0 | 844 cyg_semaphore_post(&synchro); |
| 845 cyg_mutex_lock(&test_mutexes[0]); | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
846 READ_CLOCK(&mutex_ft[i].end); |
| 0 | 847 cyg_mutex_unlock(&test_mutexes[0]); |
| 848 cyg_semaphore_wait(&synchro); | |
| 849 } | |
| 2 | 850 cyg_thread_delete(mutex_test_thread_handle); |
| 851 show_times(mutex_ft, nmutexes, "Unlock/Lock mutex"); | |
| 0 | 852 } |
| 853 | |
| 854 void | |
| 855 run_mbox_tests(void) | |
| 856 { | |
|
3132
80f232caf539
* tests/except1.cxx (cause_exception): Fix compiler warning about
sergeig
parents:
3043
diff
changeset
|
857 int i; |
| 0 | 858 // Mailbox primitives |
| 859 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 860 for (i = 0; i < nmboxes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
861 READ_CLOCK(&mbox_ft[i].start); |
| 0 | 862 cyg_mbox_create(&test_mbox_handles[i], &test_mboxes[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
863 READ_CLOCK(&mbox_ft[i].end); |
| 0 | 864 } |
| 2 | 865 show_times(mbox_ft, nmboxes, "Create mbox"); |
| 0 | 866 |
| 867 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 868 for (i = 0; i < nmboxes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
869 READ_CLOCK(&mbox_ft[i].start); |
|
3132
80f232caf539
* tests/except1.cxx (cause_exception): Fix compiler warning about
sergeig
parents:
3043
diff
changeset
|
870 cyg_mbox_peek(test_mbox_handles[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
871 READ_CLOCK(&mbox_ft[i].end); |
| 0 | 872 } |
| 2 | 873 show_times(mbox_ft, nmboxes, "Peek [empty] mbox"); |
| 0 | 874 |
| 2 | 875 #ifdef CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT |
| 0 | 876 wait_for_tick(); // Wait until the next clock tick to minimize aberations |
| 2 | 877 for (i = 0; i < nmboxes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
878 READ_CLOCK(&mbox_ft[i].start); |
| 0 | 879 cyg_mbox_put(test_mbox_handles[i], (void *)i); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
880 READ_CLOCK(&mbox_ft[i].end); |
| 0 | 881 } |
| 2 | 882 show_times(mbox_ft, nmboxes, "Put [first] mbox"); |
| 0 | 883 |
| 884 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 885 for (i = 0; i < nmboxes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
886 READ_CLOCK(&mbox_ft[i].start); |
|
3132
80f232caf539
* tests/except1.cxx (cause_exception): Fix compiler warning about
sergeig
parents:
3043
diff
changeset
|
887 cyg_mbox_peek(test_mbox_handles[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
888 READ_CLOCK(&mbox_ft[i].end); |
| 0 | 889 } |
| 2 | 890 show_times(mbox_ft, nmboxes, "Peek [1 msg] mbox"); |
| 0 | 891 |
| 892 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 893 for (i = 0; i < nmboxes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
894 READ_CLOCK(&mbox_ft[i].start); |
| 2 | 895 cyg_mbox_put(test_mbox_handles[i], (void *)i); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
896 READ_CLOCK(&mbox_ft[i].end); |
| 2 | 897 } |
| 898 show_times(mbox_ft, nmboxes, "Put [second] mbox"); | |
| 899 | |
| 900 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 901 for (i = 0; i < nmboxes; i++) { | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
902 READ_CLOCK(&mbox_ft[i].start); |
|
3132
80f232caf539
* tests/except1.cxx (cause_exception): Fix compiler warning about
sergeig
parents:
3043
diff
changeset
|
903 cyg_mbox_peek(test_mbox_handles[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
904 READ_CLOCK(&mbox_ft[i].end); |
| 2 | 905 } |
| 906 show_times(mbox_ft, nmboxes, "Peek [2 msgs] mbox"); | |
| 907 | |
| 908 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 909 for (i = 0; i < nmboxes; i++) { | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
910 READ_CLOCK(&mbox_ft[i].start); |
|
3132
80f232caf539
* tests/except1.cxx (cause_exception): Fix compiler warning about
sergeig
parents:
3043
diff
changeset
|
911 cyg_mbox_get(test_mbox_handles[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
912 READ_CLOCK(&mbox_ft[i].end); |
| 0 | 913 } |
| 2 | 914 show_times(mbox_ft, nmboxes, "Get [first] mbox"); |
| 0 | 915 |
| 916 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 917 for (i = 0; i < nmboxes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
918 READ_CLOCK(&mbox_ft[i].start); |
|
3132
80f232caf539
* tests/except1.cxx (cause_exception): Fix compiler warning about
sergeig
parents:
3043
diff
changeset
|
919 cyg_mbox_get(test_mbox_handles[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
920 READ_CLOCK(&mbox_ft[i].end); |
| 0 | 921 } |
| 2 | 922 show_times(mbox_ft, nmboxes, "Get [second] mbox"); |
| 923 #endif // ifdef CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT | |
| 0 | 924 |
| 925 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 926 for (i = 0; i < nmboxes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
927 READ_CLOCK(&mbox_ft[i].start); |
| 0 | 928 cyg_mbox_tryput(test_mbox_handles[i], (void *)i); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
929 READ_CLOCK(&mbox_ft[i].end); |
| 0 | 930 } |
| 2 | 931 show_times(mbox_ft, nmboxes, "Tryput [first] mbox"); |
| 0 | 932 |
| 933 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 934 for (i = 0; i < nmboxes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
935 READ_CLOCK(&mbox_ft[i].start); |
|
3132
80f232caf539
* tests/except1.cxx (cause_exception): Fix compiler warning about
sergeig
parents:
3043
diff
changeset
|
936 cyg_mbox_peek_item(test_mbox_handles[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
937 READ_CLOCK(&mbox_ft[i].end); |
| 0 | 938 } |
| 2 | 939 show_times(mbox_ft, nmboxes, "Peek item [non-empty] mbox"); |
| 0 | 940 |
| 941 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 942 for (i = 0; i < nmboxes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
943 READ_CLOCK(&mbox_ft[i].start); |
|
3132
80f232caf539
* tests/except1.cxx (cause_exception): Fix compiler warning about
sergeig
parents:
3043
diff
changeset
|
944 cyg_mbox_tryget(test_mbox_handles[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
945 READ_CLOCK(&mbox_ft[i].end); |
| 0 | 946 } |
| 2 | 947 show_times(mbox_ft, nmboxes, "Tryget [non-empty] mbox"); |
| 0 | 948 |
| 949 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 950 for (i = 0; i < nmboxes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
951 READ_CLOCK(&mbox_ft[i].start); |
|
3132
80f232caf539
* tests/except1.cxx (cause_exception): Fix compiler warning about
sergeig
parents:
3043
diff
changeset
|
952 cyg_mbox_peek_item(test_mbox_handles[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
953 READ_CLOCK(&mbox_ft[i].end); |
| 0 | 954 } |
| 2 | 955 show_times(mbox_ft, nmboxes, "Peek item [empty] mbox"); |
| 0 | 956 |
| 957 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 958 for (i = 0; i < nmboxes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
959 READ_CLOCK(&mbox_ft[i].start); |
|
3132
80f232caf539
* tests/except1.cxx (cause_exception): Fix compiler warning about
sergeig
parents:
3043
diff
changeset
|
960 cyg_mbox_tryget(test_mbox_handles[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
961 READ_CLOCK(&mbox_ft[i].end); |
| 0 | 962 } |
| 2 | 963 show_times(mbox_ft, nmboxes, "Tryget [empty] mbox"); |
| 0 | 964 |
| 965 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 966 for (i = 0; i < nmboxes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
967 READ_CLOCK(&mbox_ft[i].start); |
| 0 | 968 cyg_mbox_waiting_to_get(test_mbox_handles[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
969 READ_CLOCK(&mbox_ft[i].end); |
| 0 | 970 } |
| 2 | 971 show_times(mbox_ft, nmboxes, "Waiting to get mbox"); |
| 0 | 972 |
| 973 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 974 for (i = 0; i < nmboxes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
975 READ_CLOCK(&mbox_ft[i].start); |
| 0 | 976 cyg_mbox_waiting_to_put(test_mbox_handles[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
977 READ_CLOCK(&mbox_ft[i].end); |
| 0 | 978 } |
| 2 | 979 show_times(mbox_ft, nmboxes, "Waiting to put mbox"); |
| 0 | 980 |
| 981 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 982 for (i = 0; i < nmboxes; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
983 READ_CLOCK(&mbox_ft[i].start); |
| 0 | 984 cyg_mbox_delete(test_mbox_handles[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
985 READ_CLOCK(&mbox_ft[i].end); |
| 0 | 986 } |
| 2 | 987 show_times(mbox_ft, nmboxes, "Delete mbox"); |
| 0 | 988 |
| 989 run_mbox_circuit_test(); | |
| 2 | 990 end_of_test_group(); |
| 0 | 991 } |
| 992 | |
| 993 void | |
| 994 run_mbox_circuit_test(void) | |
| 995 { | |
| 2 | 996 #ifdef CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT |
| 0 | 997 int i; |
| 998 // Set my priority lower than any I plan to create | |
| 999 cyg_thread_set_priority(cyg_thread_self(), 3); | |
| 1000 // Set up for full mbox put/get test | |
| 1001 cyg_mbox_create(&test_mbox_handles[0], &test_mboxes[0]); | |
| 1002 cyg_semaphore_init(&synchro, 0); | |
| 1003 cyg_thread_create(2, // Priority - just a number | |
| 1004 mbox_test, // entry | |
| 1005 0, // index | |
| 1006 thread_name("thread", 0), // Name | |
| 1007 &stacks[0][0], // Stack | |
| 1008 STACK_SIZE, // Size | |
| 1009 &mbox_test_thread_handle, // Handle | |
| 1010 &mbox_test_thread // Thread data structure | |
| 1011 ); | |
| 1012 cyg_thread_resume(mbox_test_thread_handle); | |
| 2 | 1013 for (i = 0; i < nmboxes; i++) { |
| 0 | 1014 wait_for_tick(); // Wait until the next clock tick to minimize aberations |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1015 READ_CLOCK(&mbox_ft[i].start); |
| 0 | 1016 cyg_mbox_put(test_mbox_handles[0], (void *)i); |
| 1017 cyg_semaphore_wait(&synchro); | |
| 1018 } | |
| 2 | 1019 cyg_thread_delete(mbox_test_thread_handle); |
| 1020 show_times(mbox_ft, nmboxes, "Put/Get mbox"); | |
| 1021 #endif | |
| 0 | 1022 } |
| 1023 | |
| 1024 void | |
| 1025 run_semaphore_tests(void) | |
| 1026 { | |
| 1027 int i; | |
| 2 | 1028 cyg_count32 sem_val; |
| 0 | 1029 // Semaphore primitives |
| 1030 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1031 for (i = 0; i < nsemaphores; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1032 READ_CLOCK(&semaphore_ft[i].start); |
| 0 | 1033 cyg_semaphore_init(&test_semaphores[i], 0); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1034 READ_CLOCK(&semaphore_ft[i].end); |
| 0 | 1035 } |
| 2 | 1036 show_times(semaphore_ft, nsemaphores, "Init semaphore"); |
| 0 | 1037 |
| 1038 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1039 for (i = 0; i < nsemaphores; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1040 READ_CLOCK(&semaphore_ft[i].start); |
| 0 | 1041 cyg_semaphore_post(&test_semaphores[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1042 READ_CLOCK(&semaphore_ft[i].end); |
| 0 | 1043 } |
| 2 | 1044 show_times(semaphore_ft, nsemaphores, "Post [0] semaphore"); |
| 0 | 1045 |
| 1046 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1047 for (i = 0; i < nsemaphores; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1048 READ_CLOCK(&semaphore_ft[i].start); |
| 0 | 1049 cyg_semaphore_wait(&test_semaphores[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1050 READ_CLOCK(&semaphore_ft[i].end); |
| 0 | 1051 } |
| 2 | 1052 show_times(semaphore_ft, nsemaphores, "Wait [1] semaphore"); |
| 0 | 1053 |
| 1054 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1055 for (i = 0; i < nsemaphores; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1056 READ_CLOCK(&semaphore_ft[i].start); |
| 0 | 1057 cyg_semaphore_trywait(&test_semaphores[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1058 READ_CLOCK(&semaphore_ft[i].end); |
| 0 | 1059 } |
| 2 | 1060 show_times(semaphore_ft, nsemaphores, "Trywait [0] semaphore"); |
| 0 | 1061 |
| 1062 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1063 for (i = 0; i < nsemaphores; i++) { |
| 0 | 1064 cyg_semaphore_post(&test_semaphores[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1065 READ_CLOCK(&semaphore_ft[i].start); |
| 0 | 1066 cyg_semaphore_trywait(&test_semaphores[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1067 READ_CLOCK(&semaphore_ft[i].end); |
| 0 | 1068 } |
| 2 | 1069 show_times(semaphore_ft, nsemaphores, "Trywait [1] semaphore"); |
| 0 | 1070 |
| 1071 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1072 for (i = 0; i < nsemaphores; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1073 READ_CLOCK(&semaphore_ft[i].start); |
| 0 | 1074 cyg_semaphore_peek(&test_semaphores[i], &sem_val); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1075 READ_CLOCK(&semaphore_ft[i].end); |
| 0 | 1076 } |
| 2 | 1077 show_times(semaphore_ft, nsemaphores, "Peek semaphore"); |
| 0 | 1078 |
| 1079 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1080 for (i = 0; i < nsemaphores; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1081 READ_CLOCK(&semaphore_ft[i].start); |
| 0 | 1082 cyg_semaphore_destroy(&test_semaphores[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1083 READ_CLOCK(&semaphore_ft[i].end); |
| 0 | 1084 } |
| 2 | 1085 show_times(semaphore_ft, nsemaphores, "Destroy semaphore"); |
| 0 | 1086 |
| 1087 run_semaphore_circuit_test(); | |
| 2 | 1088 end_of_test_group(); |
| 0 | 1089 } |
| 1090 | |
| 1091 void | |
| 1092 run_semaphore_circuit_test(void) | |
| 1093 { | |
| 1094 int i; | |
| 1095 // Set my priority lower than any I plan to create | |
| 1096 cyg_thread_set_priority(cyg_thread_self(), 3); | |
| 1097 // Set up for full semaphore post/wait test | |
| 1098 cyg_semaphore_init(&test_semaphores[0], 0); | |
| 1099 cyg_semaphore_init(&synchro, 0); | |
| 1100 cyg_thread_create(2, // Priority - just a number | |
| 1101 semaphore_test, // entry | |
| 1102 0, // index | |
| 1103 thread_name("thread", 0), // Name | |
| 1104 &stacks[0][0], // Stack | |
| 1105 STACK_SIZE, // Size | |
| 1106 &semaphore_test_thread_handle, // Handle | |
| 1107 &semaphore_test_thread // Thread data structure | |
| 1108 ); | |
| 1109 cyg_thread_resume(semaphore_test_thread_handle); | |
| 2 | 1110 for (i = 0; i < nsemaphores; i++) { |
| 0 | 1111 wait_for_tick(); // Wait until the next clock tick to minimize aberations |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1112 READ_CLOCK(&semaphore_ft[i].start); |
| 0 | 1113 cyg_semaphore_post(&test_semaphores[0]); |
| 1114 cyg_semaphore_wait(&synchro); | |
| 1115 } | |
| 2 | 1116 cyg_thread_delete(semaphore_test_thread_handle); |
| 1117 show_times(semaphore_ft, nsemaphores, "Post/Wait semaphore"); | |
| 0 | 1118 } |
| 1119 | |
| 1120 void | |
| 1121 run_counter_tests(void) | |
| 1122 { | |
| 1123 int i; | |
| 2 | 1124 cyg_tick_count_t val=0; |
| 0 | 1125 |
| 1126 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1127 for (i = 0; i < ncounters; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1128 READ_CLOCK(&counter_ft[i].start); |
| 0 | 1129 cyg_counter_create(&counters[i], &test_counters[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1130 READ_CLOCK(&counter_ft[i].end); |
| 0 | 1131 } |
| 2 | 1132 show_times(counter_ft, ncounters, "Create counter"); |
| 0 | 1133 |
| 1134 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1135 for (i = 0; i < ncounters; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1136 READ_CLOCK(&counter_ft[i].start); |
| 0 | 1137 val = cyg_counter_current_value(counters[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1138 READ_CLOCK(&counter_ft[i].end); |
| 0 | 1139 } |
| 2 | 1140 show_times(counter_ft, ncounters, "Get counter value"); |
| 0 | 1141 |
| 1142 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1143 for (i = 0; i < ncounters; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1144 READ_CLOCK(&counter_ft[i].start); |
| 0 | 1145 cyg_counter_set_value(counters[i], val); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1146 READ_CLOCK(&counter_ft[i].end); |
| 0 | 1147 } |
| 2 | 1148 show_times(counter_ft, ncounters, "Set counter value"); |
| 0 | 1149 |
| 1150 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1151 for (i = 0; i < ncounters; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1152 READ_CLOCK(&counter_ft[i].start); |
| 0 | 1153 cyg_counter_tick(counters[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1154 READ_CLOCK(&counter_ft[i].end); |
| 0 | 1155 } |
| 2 | 1156 show_times(counter_ft, ncounters, "Tick counter"); |
| 0 | 1157 |
| 1158 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1159 for (i = 0; i < ncounters; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1160 READ_CLOCK(&counter_ft[i].start); |
| 0 | 1161 cyg_counter_delete(counters[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1162 READ_CLOCK(&counter_ft[i].end); |
| 0 | 1163 } |
| 2 | 1164 show_times(counter_ft, ncounters, "Delete counter"); |
| 1165 end_of_test_group(); | |
| 0 | 1166 } |
| 1167 | |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1168 void |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1169 run_flag_tests(void) |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1170 { |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1171 int i; |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1172 |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1173 wait_for_tick(); // Wait until the next clock tick to minimize aberations |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1174 for (i = 0; i < nflags; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1175 READ_CLOCK(&flag_ft[i].start); |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1176 cyg_flag_init(&test_flags[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1177 READ_CLOCK(&flag_ft[i].end); |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1178 } |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1179 show_times(flag_ft, nflags, "Init flag"); |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1180 |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1181 wait_for_tick(); // Wait until the next clock tick to minimize aberations |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1182 for (i = 0; i < nflags; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1183 READ_CLOCK(&flag_ft[i].start); |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1184 cyg_flag_destroy(&test_flags[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1185 READ_CLOCK(&flag_ft[i].end); |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1186 } |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1187 show_times(flag_ft, nflags, "Destroy flag"); |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1188 |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1189 // Recreate the flags - reused in the remaining tests |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1190 for (i = 0; i < nflags; i++) { |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1191 cyg_flag_init(&test_flags[i]); |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1192 } |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1193 |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1194 wait_for_tick(); // Wait until the next clock tick to minimize aberations |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1195 for (i = 0; i < nflags; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1196 READ_CLOCK(&flag_ft[i].start); |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1197 cyg_flag_maskbits(&test_flags[i], 0); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1198 READ_CLOCK(&flag_ft[i].end); |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1199 } |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1200 show_times(flag_ft, nflags, "Mask bits in flag"); |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1201 |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1202 wait_for_tick(); // Wait until the next clock tick to minimize aberations |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1203 for (i = 0; i < nflags; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1204 READ_CLOCK(&flag_ft[i].start); |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1205 cyg_flag_setbits(&test_flags[i], 0x11); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1206 READ_CLOCK(&flag_ft[i].end); |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1207 } |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1208 show_times(flag_ft, nflags, "Set bits in flag [no waiters]"); |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1209 |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1210 wait_for_tick(); // Wait until the next clock tick to minimize aberations |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1211 for (i = 0; i < nflags; i++) { |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1212 cyg_flag_setbits(&test_flags[i], 0x11); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1213 READ_CLOCK(&flag_ft[i].start); |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1214 cyg_flag_wait(&test_flags[i], 0x11, CYG_FLAG_WAITMODE_AND); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1215 READ_CLOCK(&flag_ft[i].end); |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1216 } |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1217 show_times(flag_ft, nflags, "Wait for flag [AND]"); |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1218 |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1219 wait_for_tick(); // Wait until the next clock tick to minimize aberations |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1220 for (i = 0; i < nflags; i++) { |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1221 cyg_flag_setbits(&test_flags[i], 0x11); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1222 READ_CLOCK(&flag_ft[i].start); |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1223 cyg_flag_wait(&test_flags[i], 0x11, CYG_FLAG_WAITMODE_OR); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1224 READ_CLOCK(&flag_ft[i].end); |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1225 } |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1226 show_times(flag_ft, nflags, "Wait for flag [OR]"); |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1227 |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1228 wait_for_tick(); // Wait until the next clock tick to minimize aberations |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1229 for (i = 0; i < nflags; i++) { |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1230 cyg_flag_setbits(&test_flags[i], 0x11); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1231 READ_CLOCK(&flag_ft[i].start); |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1232 cyg_flag_wait(&test_flags[i], 0x11, CYG_FLAG_WAITMODE_AND|CYG_FLAG_WAITMODE_CLR); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1233 READ_CLOCK(&flag_ft[i].end); |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1234 } |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1235 show_times(flag_ft, nflags, "Wait for flag [AND/CLR]"); |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1236 |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1237 wait_for_tick(); // Wait until the next clock tick to minimize aberations |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1238 for (i = 0; i < nflags; i++) { |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1239 cyg_flag_setbits(&test_flags[i], 0x11); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1240 READ_CLOCK(&flag_ft[i].start); |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1241 cyg_flag_wait(&test_flags[i], 0x11, CYG_FLAG_WAITMODE_OR|CYG_FLAG_WAITMODE_CLR); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1242 READ_CLOCK(&flag_ft[i].end); |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1243 } |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1244 show_times(flag_ft, nflags, "Wait for flag [OR/CLR]"); |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1245 |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1246 wait_for_tick(); // Wait until the next clock tick to minimize aberations |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1247 for (i = 0; i < nflags; i++) { |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1248 cyg_flag_setbits(&test_flags[i], 0x11); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1249 READ_CLOCK(&flag_ft[i].start); |
|
3132
80f232caf539
* tests/except1.cxx (cause_exception): Fix compiler warning about
sergeig
parents:
3043
diff
changeset
|
1250 cyg_flag_peek(&test_flags[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1251 READ_CLOCK(&flag_ft[i].end); |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1252 } |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1253 show_times(flag_ft, nflags, "Peek on flag"); |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1254 |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1255 // Destroy flags - no longer needed |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1256 for (i = 0; i < nflags; i++) { |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1257 cyg_flag_destroy(&test_flags[i]); |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1258 } |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1259 end_of_test_group(); |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1260 } |
|
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1261 |
| 0 | 1262 // Alarm callback function |
| 1263 void | |
| 1264 alarm_cb(cyg_handle_t alarm, cyg_addrword_t val) | |
| 1265 { | |
| 1266 // empty call back | |
| 1267 } | |
| 1268 | |
| 1269 // Callback used to test determinancy | |
| 1270 static volatile int alarm_cnt; | |
| 1271 void | |
| 1272 alarm_cb2(cyg_handle_t alarm, cyg_addrword_t indx) | |
| 1273 { | |
| 2 | 1274 if (alarm_cnt == nscheds) return; |
| 0 | 1275 sched_ft[alarm_cnt].start = 0; |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1276 READ_CLOCK(&sched_ft[alarm_cnt++].end); |
| 2 | 1277 if (alarm_cnt == nscheds) { |
| 0 | 1278 cyg_semaphore_post(&synchro); |
| 1279 } | |
| 1280 } | |
| 1281 | |
|
60
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1282 static void |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1283 alarm_cb3(cyg_handle_t alarm, cyg_addrword_t indx) |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1284 { |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1285 if (alarm_cnt == nscheds) { |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1286 cyg_semaphore_post(&synchro); |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1287 } else { |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1288 sched_ft[alarm_cnt].start = 0; |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1289 cyg_thread_resume((cyg_handle_t)indx); |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1290 } |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1291 } |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1292 |
| 0 | 1293 // Null thread, used to keep scheduler busy |
| 1294 void | |
| 1295 alarm_test(cyg_uint32 id) | |
| 1296 { | |
| 1297 while (true) { | |
| 1298 cyg_thread_yield(); | |
| 1299 } | |
| 1300 } | |
| 1301 | |
|
60
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1302 // Thread that suspends itself at the first opportunity |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1303 void |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1304 alarm_test2(cyg_uint32 id) |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1305 { |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1306 cyg_handle_t me = cyg_thread_self(); |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1307 while (true) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1308 READ_CLOCK(&sched_ft[alarm_cnt++].end); |
|
60
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1309 cyg_thread_suspend(me); |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1310 } |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1311 } |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1312 |
| 0 | 1313 void |
| 1314 run_alarm_tests(void) | |
| 1315 { | |
| 1316 int i; | |
| 1317 cyg_tick_count_t init_val, step_val; | |
| 1318 cyg_handle_t rtc_handle; | |
| 1319 | |
| 1320 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1321 for (i = 0; i < ncounters; i++) { |
| 0 | 1322 cyg_counter_create(&counters[i], &test_counters[i]); |
| 1323 } | |
| 2 | 1324 for (i = 0; i < nalarms; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1325 READ_CLOCK(&alarm_ft[i].start); |
| 0 | 1326 cyg_alarm_create(counters[0], alarm_cb, 0, &alarms[i], &test_alarms[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1327 READ_CLOCK(&alarm_ft[i].end); |
| 0 | 1328 } |
| 2 | 1329 show_times(alarm_ft, nalarms, "Create alarm"); |
| 0 | 1330 |
| 1331 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 1332 init_val = 0; step_val = 0; | |
| 2 | 1333 for (i = 0; i < nalarms; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1334 READ_CLOCK(&alarm_ft[i].start); |
| 0 | 1335 cyg_alarm_initialize(alarms[i], init_val, step_val); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1336 READ_CLOCK(&alarm_ft[i].end); |
| 0 | 1337 } |
| 2 | 1338 show_times(alarm_ft, nalarms, "Initialize alarm"); |
| 0 | 1339 |
| 1340 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 1341 init_val = 0; step_val = 0; | |
| 2 | 1342 for (i = 0; i < nalarms; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1343 READ_CLOCK(&alarm_ft[i].start); |
| 0 | 1344 cyg_alarm_disable(alarms[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1345 READ_CLOCK(&alarm_ft[i].end); |
| 0 | 1346 } |
| 2 | 1347 show_times(alarm_ft, nalarms, "Disable alarm"); |
| 0 | 1348 |
| 1349 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 1350 init_val = 0; step_val = 0; | |
| 2 | 1351 for (i = 0; i < nalarms; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1352 READ_CLOCK(&alarm_ft[i].start); |
| 0 | 1353 cyg_alarm_enable(alarms[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1354 READ_CLOCK(&alarm_ft[i].end); |
| 0 | 1355 } |
| 2 | 1356 show_times(alarm_ft, nalarms, "Enable alarm"); |
| 0 | 1357 |
| 1358 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1359 for (i = 0; i < nalarms; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1360 READ_CLOCK(&alarm_ft[i].start); |
| 0 | 1361 cyg_alarm_delete(alarms[i]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1362 READ_CLOCK(&alarm_ft[i].end); |
| 0 | 1363 } |
| 2 | 1364 show_times(alarm_ft, nalarms, "Delete alarm"); |
| 0 | 1365 |
| 1366 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 1367 cyg_counter_create(&counters[0], &test_counters[0]); | |
| 1368 cyg_alarm_create(counters[0], alarm_cb, 0, &alarms[0], &test_alarms[0]); | |
| 1369 init_val = 9999; step_val = 9999; | |
| 1370 cyg_alarm_initialize(alarms[0], init_val, step_val); | |
| 1371 cyg_alarm_enable(alarms[0]); | |
| 2 | 1372 for (i = 0; i < ncounters; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1373 READ_CLOCK(&counter_ft[i].start); |
| 0 | 1374 cyg_counter_tick(counters[0]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1375 READ_CLOCK(&counter_ft[i].end); |
| 0 | 1376 } |
| 2 | 1377 show_times(counter_ft, ncounters, "Tick counter [1 alarm]"); |
| 0 | 1378 |
| 1379 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 1380 cyg_counter_create(&counters[0], &test_counters[0]); | |
| 2 | 1381 for (i = 0; i < nalarms; i++) { |
| 0 | 1382 cyg_alarm_create(counters[0], alarm_cb, 0, &alarms[i], &test_alarms[i]); |
| 1383 init_val = 9999; step_val = 9999; | |
| 1384 cyg_alarm_initialize(alarms[i], init_val, step_val); | |
| 1385 cyg_alarm_enable(alarms[i]); | |
| 1386 } | |
| 2 | 1387 for (i = 0; i < ncounters; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1388 READ_CLOCK(&counter_ft[i].start); |
| 0 | 1389 cyg_counter_tick(counters[0]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1390 READ_CLOCK(&counter_ft[i].end); |
| 0 | 1391 } |
| 2 | 1392 show_times(counter_ft, ncounters, "Tick counter [many alarms]"); |
| 0 | 1393 |
| 1394 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 1395 cyg_counter_create(&counters[0], &test_counters[0]); | |
| 1396 cyg_alarm_create(counters[0], alarm_cb, 0, &alarms[0], &test_alarms[0]); | |
| 1397 init_val = 1; step_val = 1; | |
| 1398 cyg_alarm_initialize(alarms[0], init_val, step_val); | |
| 1399 cyg_alarm_enable(alarms[0]); | |
| 2 | 1400 for (i = 0; i < ncounters; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1401 READ_CLOCK(&counter_ft[i].start); |
| 0 | 1402 cyg_counter_tick(counters[0]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1403 READ_CLOCK(&counter_ft[i].end); |
| 0 | 1404 } |
| 2 | 1405 show_times(counter_ft, ncounters, "Tick & fire counter [1 alarm]"); |
| 0 | 1406 |
| 1407 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 1408 cyg_counter_create(&counters[0], &test_counters[0]); | |
| 2 | 1409 for (i = 0; i < nalarms; i++) { |
| 0 | 1410 cyg_alarm_create(counters[0], alarm_cb, i, &alarms[i], &test_alarms[i]); |
| 1411 init_val = 1; step_val = 1; | |
| 1412 cyg_alarm_initialize(alarms[i], init_val, step_val); | |
| 1413 cyg_alarm_enable(alarms[i]); | |
| 1414 } | |
| 2 | 1415 for (i = 0; i < nalarms; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1416 READ_CLOCK(&alarm_ft[i].start); |
| 0 | 1417 cyg_counter_tick(counters[0]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1418 READ_CLOCK(&alarm_ft[i].end); |
| 0 | 1419 } |
| 2 | 1420 for (i = 0; i < nalarms; i++) { |
| 0 | 1421 cyg_alarm_delete(alarms[i]); |
| 1422 } | |
| 2 | 1423 show_times(alarm_ft, nalarms, "Tick & fire counters [>1 together]"); |
| 1424 | |
| 1425 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 1426 cyg_counter_create(&counters[0], &test_counters[0]); | |
| 1427 for (i = 0; i < nalarms; i++) { | |
| 1428 cyg_alarm_create(counters[0], alarm_cb, i, &alarms[i], &test_alarms[i]); | |
| 1429 init_val = i+1; step_val = nalarms+1; | |
| 1430 cyg_alarm_initialize(alarms[i], init_val, step_val); | |
| 1431 cyg_alarm_enable(alarms[i]); | |
| 1432 } | |
| 1433 for (i = 0; i < nalarms; i++) { | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1434 READ_CLOCK(&alarm_ft[i].start); |
| 2 | 1435 cyg_counter_tick(counters[0]); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1436 READ_CLOCK(&alarm_ft[i].end); |
| 2 | 1437 } |
| 1438 for (i = 0; i < nalarms; i++) { | |
| 1439 cyg_alarm_delete(alarms[i]); | |
| 1440 } | |
| 1441 show_times(alarm_ft, nalarms, "Tick & fire counters [>1 separately]"); | |
| 0 | 1442 |
| 1443 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 1444 cyg_clock_to_counter(cyg_real_time_clock(), &rtc_handle); | |
| 1445 cyg_alarm_create(rtc_handle, alarm_cb2, 0, &alarms[0], &test_alarms[0]); | |
| 1446 init_val = 5; step_val = 5; alarm_cnt = 0; | |
| 1447 cyg_alarm_initialize(alarms[0], init_val, step_val); | |
| 1448 cyg_semaphore_init(&synchro, 0); | |
| 1449 cyg_alarm_enable(alarms[0]); | |
| 1450 cyg_semaphore_wait(&synchro); | |
| 1451 cyg_alarm_disable(alarms[0]); | |
| 1452 cyg_alarm_delete(alarms[0]); | |
| 2 | 1453 show_times(sched_ft, nscheds, "Alarm latency [0 threads]"); |
| 0 | 1454 |
| 1455 // Set my priority higher than any I plan to create | |
| 1456 cyg_thread_set_priority(cyg_thread_self(), 2); | |
| 1457 for (i = 0; i < 2; i++) { | |
| 1458 cyg_thread_create(10, // Priority - just a number | |
| 1459 alarm_test, // entry | |
| 1460 i, // index | |
| 1461 thread_name("thread", i), // Name | |
| 1462 &stacks[i][0], // Stack | |
| 1463 STACK_SIZE, // Size | |
| 1464 &threads[i], // Handle | |
| 1465 &test_threads[i] // Thread data structure | |
| 1466 ); | |
| 1467 cyg_thread_resume(threads[i]); | |
| 1468 } | |
| 1469 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 1470 cyg_clock_to_counter(cyg_real_time_clock(), &rtc_handle); | |
| 1471 cyg_alarm_create(rtc_handle, alarm_cb2, 0, &alarms[0], &test_alarms[0]); | |
| 1472 init_val = 5; step_val = 5; alarm_cnt = 0; | |
| 1473 cyg_alarm_initialize(alarms[0], init_val, step_val); | |
| 1474 cyg_semaphore_init(&synchro, 0); | |
| 1475 cyg_alarm_enable(alarms[0]); | |
| 1476 cyg_semaphore_wait(&synchro); | |
| 1477 cyg_alarm_disable(alarms[0]); | |
| 1478 cyg_alarm_delete(alarms[0]); | |
| 2 | 1479 show_times(sched_ft, nscheds, "Alarm latency [2 threads]"); |
| 0 | 1480 for (i = 0; i < 2; i++) { |
| 1481 cyg_thread_suspend(threads[i]); | |
| 2 | 1482 cyg_thread_delete(threads[i]); |
| 0 | 1483 } |
| 1484 | |
| 1485 // Set my priority higher than any I plan to create | |
| 1486 cyg_thread_set_priority(cyg_thread_self(), 2); | |
| 2 | 1487 for (i = 0; i < ntest_threads; i++) { |
| 0 | 1488 cyg_thread_create(10, // Priority - just a number |
| 1489 alarm_test, // entry | |
| 1490 i, // index | |
| 1491 thread_name("thread", i), // Name | |
| 1492 &stacks[i][0], // Stack | |
| 1493 STACK_SIZE, // Size | |
| 1494 &threads[i], // Handle | |
| 1495 &test_threads[i] // Thread data structure | |
| 1496 ); | |
| 1497 cyg_thread_resume(threads[i]); | |
| 1498 } | |
| 1499 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 1500 cyg_clock_to_counter(cyg_real_time_clock(), &rtc_handle); | |
| 1501 cyg_alarm_create(rtc_handle, alarm_cb2, 0, &alarms[0], &test_alarms[0]); | |
| 1502 init_val = 5; step_val = 5; alarm_cnt = 0; | |
| 1503 cyg_alarm_initialize(alarms[0], init_val, step_val); | |
| 1504 cyg_semaphore_init(&synchro, 0); | |
| 1505 cyg_alarm_enable(alarms[0]); | |
| 1506 cyg_semaphore_wait(&synchro); | |
| 1507 cyg_alarm_disable(alarms[0]); | |
| 1508 cyg_alarm_delete(alarms[0]); | |
| 2 | 1509 show_times(sched_ft, nscheds, "Alarm latency [many threads]"); |
| 1510 for (i = 0; i < ntest_threads; i++) { | |
| 0 | 1511 cyg_thread_suspend(threads[i]); |
| 2 | 1512 cyg_thread_delete(threads[i]); |
| 0 | 1513 } |
|
60
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1514 |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1515 // Set my priority higher than any I plan to create |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1516 cyg_thread_set_priority(cyg_thread_self(), 2); |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1517 cyg_thread_create(10, // Priority - just a number |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1518 alarm_test2, // entry |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1519 i, // index |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1520 thread_name("thread", 0), // Name |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1521 &stacks[0][0], // Stack |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1522 STACK_SIZE, // Size |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1523 &threads[0], // Handle |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1524 &test_threads[0] // Thread data structure |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1525 ); |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1526 wait_for_tick(); // Wait until the next clock tick to minimize aberations |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1527 cyg_clock_to_counter(cyg_real_time_clock(), &rtc_handle); |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1528 cyg_alarm_create(rtc_handle, alarm_cb3, threads[0], &alarms[0], |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1529 &test_alarms[0]); |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1530 init_val = 5; step_val = 5; alarm_cnt = 0; |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1531 cyg_alarm_initialize(alarms[0], init_val, step_val); |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1532 cyg_semaphore_init(&synchro, 0); |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1533 cyg_alarm_enable(alarms[0]); |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1534 cyg_semaphore_wait(&synchro); |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1535 cyg_alarm_disable(alarms[0]); |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1536 cyg_alarm_delete(alarms[0]); |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1537 show_times(sched_ft, nscheds, "Alarm -> thread resume latency"); |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1538 cyg_thread_suspend(threads[0]); |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1539 cyg_thread_delete(threads[0]); |
|
3836136e7743
Merge from eCos master repository on 1999-12-17-19:44:58-GMT
jlarmour
parents:
56
diff
changeset
|
1540 |
| 2 | 1541 end_of_test_group(); |
| 0 | 1542 } |
| 1543 | |
| 1544 void | |
| 1545 run_sched_tests(void) | |
| 1546 { | |
| 1547 int i; | |
| 1548 | |
| 1549 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1550 for (i = 0; i < nscheds; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1551 READ_CLOCK(&sched_ft[i].start); |
| 0 | 1552 cyg_scheduler_lock(); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1553 READ_CLOCK(&sched_ft[i].end); |
| 0 | 1554 cyg_scheduler_unlock(); |
| 1555 } | |
| 2 | 1556 show_times(sched_ft, nscheds, "Scheduler lock"); |
| 0 | 1557 |
| 1558 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1559 for (i = 0; i < nscheds; i++) { |
| 0 | 1560 cyg_scheduler_lock(); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1561 READ_CLOCK(&sched_ft[i].start); |
| 0 | 1562 cyg_scheduler_unlock(); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1563 READ_CLOCK(&sched_ft[i].end); |
| 0 | 1564 } |
| 2 | 1565 show_times(sched_ft, nscheds, "Scheduler unlock [0 threads]"); |
| 0 | 1566 |
| 1567 // Set my priority higher than any I plan to create | |
| 1568 cyg_thread_set_priority(cyg_thread_self(), 2); | |
| 1569 for (i = 0; i < 1; i++) { | |
| 1570 cyg_thread_create(10, // Priority - just a number | |
| 1571 test0, // entry | |
| 1572 i, // index | |
| 1573 thread_name("thread", i), // Name | |
| 1574 &stacks[i][0], // Stack | |
| 1575 STACK_SIZE, // Size | |
| 1576 &threads[i], // Handle | |
| 1577 &test_threads[i] // Thread data structure | |
| 1578 ); | |
| 1579 } | |
| 1580 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1581 for (i = 0; i < nscheds; i++) { |
| 0 | 1582 cyg_scheduler_lock(); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1583 READ_CLOCK(&sched_ft[i].start); |
| 0 | 1584 cyg_scheduler_unlock(); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1585 READ_CLOCK(&sched_ft[i].end); |
| 0 | 1586 } |
| 2 | 1587 show_times(sched_ft, nscheds, "Scheduler unlock [1 suspended]"); |
| 0 | 1588 for (i = 0; i < 1; i++) { |
| 2 | 1589 cyg_thread_delete(threads[i]); |
| 0 | 1590 } |
| 1591 | |
| 1592 // Set my priority higher than any I plan to create | |
| 1593 cyg_thread_set_priority(cyg_thread_self(), 2); | |
| 2 | 1594 for (i = 0; i < ntest_threads; i++) { |
| 0 | 1595 cyg_thread_create(10, // Priority - just a number |
| 1596 test0, // entry | |
| 1597 i, // index | |
| 1598 thread_name("thread", i), // Name | |
| 1599 &stacks[i][0], // Stack | |
| 1600 STACK_SIZE, // Size | |
| 1601 &threads[i], // Handle | |
| 1602 &test_threads[i] // Thread data structure | |
| 1603 ); | |
| 1604 } | |
| 1605 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1606 for (i = 0; i < nscheds; i++) { |
| 0 | 1607 cyg_scheduler_lock(); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1608 READ_CLOCK(&sched_ft[i].start); |
| 0 | 1609 cyg_scheduler_unlock(); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1610 READ_CLOCK(&sched_ft[i].end); |
| 0 | 1611 } |
| 2 | 1612 show_times(sched_ft, nscheds, "Scheduler unlock [many suspended]"); |
| 1613 for (i = 0; i < ntest_threads; i++) { | |
| 1614 cyg_thread_delete(threads[i]); | |
| 0 | 1615 } |
| 1616 | |
| 1617 // Set my priority higher than any I plan to create | |
| 1618 cyg_thread_set_priority(cyg_thread_self(), 2); | |
| 2 | 1619 for (i = 0; i < ntest_threads; i++) { |
| 0 | 1620 cyg_thread_create(10, // Priority - just a number |
| 1621 test0, // entry | |
| 1622 i, // index | |
| 1623 thread_name("thread", i), // Name | |
| 1624 &stacks[i][0], // Stack | |
| 1625 STACK_SIZE, // Size | |
| 1626 &threads[i], // Handle | |
| 1627 &test_threads[i] // Thread data structure | |
| 1628 ); | |
| 1629 cyg_thread_resume(threads[i]); | |
| 1630 } | |
| 1631 wait_for_tick(); // Wait until the next clock tick to minimize aberations | |
| 2 | 1632 for (i = 0; i < nscheds; i++) { |
| 0 | 1633 cyg_scheduler_lock(); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1634 READ_CLOCK(&sched_ft[i].start); |
| 0 | 1635 cyg_scheduler_unlock(); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1636 READ_CLOCK(&sched_ft[i].end); |
| 0 | 1637 } |
| 2 | 1638 show_times(sched_ft, nscheds, "Scheduler unlock [many low prio]"); |
| 1639 for (i = 0; i < ntest_threads; i++) { | |
| 1640 cyg_thread_delete(threads[i]); | |
| 0 | 1641 } |
| 2 | 1642 end_of_test_group(); |
| 0 | 1643 } |
| 1644 | |
| 1001 | 1645 static void |
| 1646 _run_all_tests(CYG_ADDRESS id) | |
| 0 | 1647 { |
| 2 | 1648 int i, j; |
| 1649 cyg_uint32 tv[nsamples], tv0, tv1; | |
| 1650 cyg_uint32 min_stack, max_stack, total_stack, actual_stack; | |
| 1651 cyg_tick_count_t ticks, tick0, tick1; | |
| 0 | 1652 #ifdef CYG_SCHEDULER_LOCK_TIMINGS |
| 1653 cyg_uint32 lock_ave, lock_max; | |
| 1654 #endif | |
|
34
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
1655 #if defined(CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY) && defined(HAL_CLOCK_LATENCY) |
| 0 | 1656 cyg_int32 clock_ave; |
| 1657 #endif | |
| 1658 | |
| 2 | 1659 disable_clock_latency_measurement(); |
|
8
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
4
diff
changeset
|
1660 |
|
177
4c750ce71ae3
Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents:
161
diff
changeset
|
1661 #ifndef CYGPKG_KERNEL_SMP_SUPPORT |
|
8
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
4
diff
changeset
|
1662 cyg_test_dump_thread_stack_stats( "Startup, main stack", thread[0] ); |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
4
diff
changeset
|
1663 cyg_test_dump_interrupt_stack_stats( "Startup" ); |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
4
diff
changeset
|
1664 cyg_test_dump_idlethread_stack_stats( "Startup" ); |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
4
diff
changeset
|
1665 cyg_test_clear_interrupt_stack(); |
|
177
4c750ce71ae3
Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents:
161
diff
changeset
|
1666 #endif |
|
4c750ce71ae3
Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents:
161
diff
changeset
|
1667 |
| 2 | 1668 diag_printf("\neCos Kernel Timings\n"); |
| 1669 diag_printf("Notes: all times are in microseconds (.000001) unless otherwise stated\n"); | |
| 1670 #ifdef STATS_WITHOUT_FIRST_SAMPLE | |
| 1671 diag_printf(" second line of results have first sample removed\n"); | |
| 1672 #endif | |
| 1673 | |
| 1674 cyg_thread_delay(2); // Make sure the clock is actually running | |
| 1675 | |
| 1676 ns_per_system_clock = 1000000/rtc_resolution[1]; | |
| 1677 | |
|
177
4c750ce71ae3
Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents:
161
diff
changeset
|
1678 wait_for_tick(); |
| 2 | 1679 for (i = 0; i < nsamples; i++) { |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1680 READ_CLOCK(&tv[i]); |
| 0 | 1681 } |
| 1682 tv0 = 0; | |
| 2 | 1683 for (i = 1; i < nsamples; i++) { |
| 1684 tv0 += tv[i] - tv[i-1]; | |
| 0 | 1685 } |
| 2 | 1686 end_of_test_group(); |
| 0 | 1687 |
| 2 | 1688 overhead = tv0 / (nsamples-1); |
| 1689 diag_printf("Reading the hardware clock takes %d 'ticks' overhead\n", overhead); | |
| 1690 diag_printf("... this value will be factored out of all other measurements\n"); | |
| 0 | 1691 |
| 1692 // Try and measure how long the clock interrupt handling takes | |
| 2 | 1693 for (i = 0; i < nsamples; i++) { |
| 1694 tick0 = cyg_current_time(); | |
| 1695 while (true) { | |
| 1696 tick1 = cyg_current_time(); | |
| 1697 if (tick0 != tick1) break; | |
| 1698 } | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1699 READ_CLOCK(&tv[i]); |
| 0 | 1700 } |
| 2 | 1701 tv1 = 0; |
| 1702 for (i = 0; i < nsamples; i++) { | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1703 tv1 += tv[i] * NSTICK; |
| 2 | 1704 } |
| 1705 tv1 = tv1 / nsamples; | |
| 0 | 1706 tv1 -= overhead; // Adjust out the cost of getting the timer value |
| 2 | 1707 diag_printf("Clock interrupt took"); |
| 1708 show_ticks_in_us(tv1); | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1709 diag_printf(" microseconds (%d raw clock ticks)\n", tv1/NSTICK); |
| 2 | 1710 enable_clock_latency_measurement(); |
| 0 | 1711 |
| 1712 ticks = cyg_current_time(); | |
| 1713 | |
| 1714 show_test_parameters(); | |
| 1715 show_times_hdr(); | |
| 1716 | |
| 2 | 1717 reset_clock_latency_measurement(); |
| 1718 | |
| 0 | 1719 run_thread_tests(); |
| 1720 run_sched_tests(); | |
| 1721 run_mutex_tests(); | |
| 1722 run_mbox_tests(); | |
| 1723 run_semaphore_tests(); | |
| 1724 run_counter_tests(); | |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1725 run_flag_tests(); |
| 0 | 1726 run_alarm_tests(); |
| 1727 | |
| 1728 #ifdef CYG_SCHEDULER_LOCK_TIMINGS | |
| 1729 Cyg_Scheduler::get_lock_times(&lock_ave, &lock_max); | |
| 2 | 1730 diag_printf("\nMax lock:"); |
| 1731 show_ticks_in_us(lock_max); | |
| 1732 diag_printf(", Ave lock:"); | |
| 1733 show_ticks_in_us(lock_ave); | |
| 1734 diag_printf("\n"); | |
| 0 | 1735 #endif |
| 1736 | |
|
34
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
1737 #if defined(CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY) && defined(HAL_CLOCK_LATENCY) |
| 2 | 1738 // Display latency figures in same format as all other numbers |
| 1739 disable_clock_latency_measurement(); | |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1740 clock_ave = (total_clock_latency*NSTICK) / total_clock_interrupts; |
| 2 | 1741 show_ticks_in_us(clock_ave); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1742 show_ticks_in_us(min_clock_latency*NSTICK); |
|
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1743 show_ticks_in_us(max_clock_latency*NSTICK); |
| 2 | 1744 show_ticks_in_us(0); |
| 1745 diag_printf(" Clock/interrupt latency\n\n"); | |
|
34
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
1746 enable_clock_latency_measurement(); |
|
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
1747 #endif |
|
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
1748 |
|
210
d2c90368aeef
Merge from eCos master repository on 2002-05-23-21:39:14-BST
jlarmour
parents:
208
diff
changeset
|
1749 #if defined(CYGVAR_KERNEL_COUNTERS_CLOCK_DSR_LATENCY) && defined(HAL_CLOCK_LATENCY) |
|
34
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
1750 disable_clock_latency_measurement(); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1751 clock_ave = (total_clock_dsr_latency*NSTICK) / total_clock_dsr_calls; |
|
34
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
1752 show_ticks_in_us(clock_ave); |
|
3284
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1753 show_ticks_in_us(min_clock_dsr_latency*NSTICK); |
|
4839eca9f0c7
Increase resolution of time measurement for platforms featuring HAL_CLOCK_READ_NS. [Bugzilla 1001958]
vae
parents:
3132
diff
changeset
|
1754 show_ticks_in_us(max_clock_dsr_latency*NSTICK); |
|
34
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
1755 show_ticks_in_us(0); |
|
29bc183297e1
Merge from eCos master repository on 1999-09-02-16:26:10-BST
jlarmour
parents:
10
diff
changeset
|
1756 diag_printf(" Clock DSR latency\n\n"); |
| 2 | 1757 enable_clock_latency_measurement(); |
| 0 | 1758 #endif |
| 1759 | |
|
177
4c750ce71ae3
Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents:
161
diff
changeset
|
1760 #ifndef CYGPKG_KERNEL_SMP_SUPPORT |
| 2 | 1761 disable_clock_latency_measurement(); |
| 1762 min_stack = STACK_SIZE; | |
| 1763 max_stack = 0; | |
| 1764 total_stack = 0; | |
|
56
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
1765 for (i = 0; i < (int)NTEST_THREADS; i++) { |
| 2 | 1766 for (j = 0; j < STACK_SIZE; j++) { |
| 1767 if (stacks[i][j]) break; | |
| 1768 } | |
| 1769 actual_stack = STACK_SIZE-j; | |
| 1770 if (actual_stack < min_stack) min_stack = actual_stack; | |
| 1771 if (actual_stack > max_stack) max_stack = actual_stack; | |
| 1772 total_stack += actual_stack; | |
| 1773 } | |
| 1774 for (j = 0; j < STACKSIZE; j++) { | |
|
8
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
4
diff
changeset
|
1775 if (((char *)stack[0])[j]) break; |
| 2 | 1776 } |
|
1927
275f1861b36f
* tests/tm_basic.cxx (_run_all_tests): Fixed compiler warning.
asl
parents:
1507
diff
changeset
|
1777 diag_printf("%5ld %5d %5d (main stack: %5d) Thread stack used (%d total)\n", |
|
275f1861b36f
* tests/tm_basic.cxx (_run_all_tests): Fixed compiler warning.
asl
parents:
1507
diff
changeset
|
1778 (unsigned long) total_stack/NTEST_THREADS, min_stack, max_stack, |
| 2 | 1779 STACKSIZE - j, STACK_SIZE); |
|
8
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
4
diff
changeset
|
1780 |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
4
diff
changeset
|
1781 cyg_test_dump_thread_stack_stats( "All done, main stack", thread[0] ); |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
4
diff
changeset
|
1782 cyg_test_dump_interrupt_stack_stats( "All done" ); |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
4
diff
changeset
|
1783 cyg_test_dump_idlethread_stack_stats( "All done" ); |
|
177
4c750ce71ae3
Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents:
161
diff
changeset
|
1784 #endif |
|
4c750ce71ae3
Merge from eCos master repository on 2001-08-10-19:22:57-BST
jlarmour
parents:
161
diff
changeset
|
1785 |
| 2 | 1786 enable_clock_latency_measurement(); |
| 1787 | |
| 0 | 1788 ticks = cyg_current_time(); |
| 2 | 1789 diag_printf("\nTiming complete - %d ms total\n\n", (int)((ticks*ns_per_system_clock)/1000)); |
| 1001 | 1790 } |
| 0 | 1791 |
| 1001 | 1792 void |
| 1793 run_all_tests(CYG_ADDRESS id) | |
| 1794 { | |
| 1795 #if CYGNUM_TESTS_RUN_COUNT < 0 | |
| 1796 while (1) | |
| 1797 #else | |
| 1798 int i; | |
| 1799 for (i = 0; i < CYGNUM_TESTS_RUN_COUNT; i++) | |
| 1800 #endif | |
| 1801 _run_all_tests(id); | |
| 0 | 1802 CYG_TEST_PASS_FINISH("Basic timing OK"); |
| 1803 } | |
| 1804 | |
| 1805 void tm_basic_main( void ) | |
| 1806 { | |
| 1807 CYG_TEST_INIT(); | |
| 1808 | |
| 2 | 1809 if (cyg_test_is_simulator) { |
| 1810 nsamples = NSAMPLES_SIM; | |
| 1811 ntest_threads = NTEST_THREADS_SIM; | |
| 1812 nthread_switches = NTHREAD_SWITCHES_SIM; | |
| 1813 nmutexes = NMUTEXES_SIM; | |
| 1814 nmboxes = NMBOXES_SIM; | |
| 1815 nsemaphores = NSEMAPHORES_SIM; | |
| 1816 nscheds = NSCHEDS_SIM; | |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1817 nflags = NFLAGS_SIM; |
| 2 | 1818 ncounters = NCOUNTERS_SIM; |
| 1819 nalarms = NALARMS_SIM; | |
| 1820 } else { | |
| 1821 nsamples = NSAMPLES; | |
| 1822 ntest_threads = NTEST_THREADS; | |
| 1823 nthread_switches = NTHREAD_SWITCHES; | |
| 1824 nmutexes = NMUTEXES; | |
| 1825 nmboxes = NMBOXES; | |
| 1826 nsemaphores = NSEMAPHORES; | |
| 1827 nscheds = NSCHEDS; | |
|
445
4bfb0d444b05
Add tests for kernel flag synchronizers (incomplete).
gthomas
parents:
394
diff
changeset
|
1828 nflags = NFLAGS; |
| 2 | 1829 ncounters = NCOUNTERS; |
| 1830 nalarms = NALARMS; | |
| 1831 } | |
| 1832 | |
|
56
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
1833 // Sanity |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
1834 #ifdef WORKHORSE_TEST |
|
2635
8f706d6bdc35
* tests/tm_basic.cxx (max): Actually the meaning was right before,
jlarmour
parents:
2624
diff
changeset
|
1835 ntest_threads = min(512, ntest_threads); |
|
8f706d6bdc35
* tests/tm_basic.cxx (max): Actually the meaning was right before,
jlarmour
parents:
2624
diff
changeset
|
1836 nmutexes = min(1024, nmutexes); |
|
8f706d6bdc35
* tests/tm_basic.cxx (max): Actually the meaning was right before,
jlarmour
parents:
2624
diff
changeset
|
1837 nsemaphores = min(1024, nsemaphores); |
|
8f706d6bdc35
* tests/tm_basic.cxx (max): Actually the meaning was right before,
jlarmour
parents:
2624
diff
changeset
|
1838 nmboxes = min(1024, nmboxes); |
|
8f706d6bdc35
* tests/tm_basic.cxx (max): Actually the meaning was right before,
jlarmour
parents:
2624
diff
changeset
|
1839 ncounters = min(1024, ncounters); |
|
8f706d6bdc35
* tests/tm_basic.cxx (max): Actually the meaning was right before,
jlarmour
parents:
2624
diff
changeset
|
1840 nalarms = min(1024, nalarms); |
|
56
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
1841 #else |
|
2635
8f706d6bdc35
* tests/tm_basic.cxx (max): Actually the meaning was right before,
jlarmour
parents:
2624
diff
changeset
|
1842 ntest_threads = min(64, ntest_threads); |
|
8f706d6bdc35
* tests/tm_basic.cxx (max): Actually the meaning was right before,
jlarmour
parents:
2624
diff
changeset
|
1843 nmutexes = min(32, nmutexes); |
|
8f706d6bdc35
* tests/tm_basic.cxx (max): Actually the meaning was right before,
jlarmour
parents:
2624
diff
changeset
|
1844 nsemaphores = min(32, nsemaphores); |
|
8f706d6bdc35
* tests/tm_basic.cxx (max): Actually the meaning was right before,
jlarmour
parents:
2624
diff
changeset
|
1845 nmboxes = min(32, nmboxes); |
|
8f706d6bdc35
* tests/tm_basic.cxx (max): Actually the meaning was right before,
jlarmour
parents:
2624
diff
changeset
|
1846 ncounters = min(32, ncounters); |
|
8f706d6bdc35
* tests/tm_basic.cxx (max): Actually the meaning was right before,
jlarmour
parents:
2624
diff
changeset
|
1847 nflags = min(32, nflags); |
|
8f706d6bdc35
* tests/tm_basic.cxx (max): Actually the meaning was right before,
jlarmour
parents:
2624
diff
changeset
|
1848 nalarms = min(32, nalarms); |
|
56
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
1849 #endif |
|
755351606154
Merge from eCos master repository on 1999-12-01-18:03:05-GMT
jlarmour
parents:
38
diff
changeset
|
1850 |
| 0 | 1851 new_thread(run_all_tests, 0); |
| 1852 | |
| 1853 Cyg_Scheduler::scheduler.start(); | |
|
4
1d7f19c9e4d1
Merge from eCos master repository on 1999-05-11-21:11:10-BST
jlarmour
parents:
2
diff
changeset
|
1854 |
| 0 | 1855 } |
| 1856 | |
|
130
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
76
diff
changeset
|
1857 #ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG |
|
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
76
diff
changeset
|
1858 externC void |
|
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
76
diff
changeset
|
1859 cyg_hal_invoke_constructors(); |
|
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
76
diff
changeset
|
1860 #endif |
|
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
76
diff
changeset
|
1861 |
| 0 | 1862 externC void |
| 1863 cyg_start( void ) | |
| 1864 { | |
|
130
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
76
diff
changeset
|
1865 #ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG |
|
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
76
diff
changeset
|
1866 cyg_hal_invoke_constructors(); |
|
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
76
diff
changeset
|
1867 #endif |
| 0 | 1868 tm_basic_main(); |
| 1869 } | |
| 2 | 1870 |
| 1871 #else // CYGFUN_KERNEL_API_C | |
| 1872 | |
| 1873 externC void | |
| 1874 cyg_start( void ) | |
| 1875 { | |
| 1876 CYG_TEST_INIT(); | |
| 1507 | 1877 CYG_TEST_INFO("Timing tests require:\n" |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
1878 "CYGFUN_KERNEL_API_C && \n" |
|
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
1879 "CYGSEM_KERNEL_SCHED_MLQUEUE &&\n" |
|
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
1880 "CYGVAR_KERNEL_COUNTERS_CLOCK &&\n" |
|
76
435cced73e2f
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
jlarmour
parents:
66
diff
changeset
|
1881 "!CYGDBG_INFRA_DIAG_USE_DEVICE &&\n" |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
1882 "(CYGNUM_KERNEL_SCHED_PRIORITIES > 12)\n"); |
| 1507 | 1883 CYG_TEST_NA("Timing tests requirements"); |
| 2 | 1884 } |
| 1885 #endif // CYGFUN_KERNEL_API_C, etc. | |
| 1886 | |
| 0 | 1887 // EOF tm_basic.cxx |
