Mercurial > ecos
annotate packages/kernel/current/tests/clock1.cxx @ 64:c38311975d4f ecos-sw-2000-01-28
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
| author | jlarmour |
|---|---|
| date | Fri, 28 Jan 2000 04:59:39 +0000 |
| parents | 443894e2e912 |
| children | bf00f99aec69 |
| rev | line source |
|---|---|
| 0 | 1 //========================================================================== |
| 2 // | |
| 3 // clock1.cxx | |
| 4 // | |
| 5 // Clock test 1 - Real Time Clock | |
| 6 // | |
| 7 //========================================================================== | |
| 8 //####COPYRIGHTBEGIN#### | |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
9 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
10 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
11 // The contents of this file are subject to the Red Hat eCos Public License |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
12 // Version 1.0 (the "License"); you may not use this file except in |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
13 // compliance with the License. You may obtain a copy of the License at |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
14 // http://sourceware.cygnus.com/ecos |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
15 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
16 // Software distributed under the License is distributed on an |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
18 // License for the specific language governing rights and limitations under |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
19 // the License. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
20 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
21 // The Original Code is eCos - Embedded Configurable Operating System, |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
22 // released September 30, 1998. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
23 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
24 // The Initial Developer of the Original Code is Red Hat. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
25 // Portions created by Red Hat are |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
27 // All Rights Reserved. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
28 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
29 // |
| 0 | 30 //####COPYRIGHTEND#### |
| 31 //========================================================================== | |
| 32 //#####DESCRIPTIONBEGIN#### | |
| 33 // | |
| 34 // Author(s): dsm | |
| 35 // Contributors: dsm | |
| 36 // Date: 1998-02-16 | |
| 37 // Description: Tests the Kernel Real Time Clock | |
| 38 // This test creates a thread, starts the scheduler and | |
| 39 // delays for a time of about 5 seconds. This test should | |
| 40 // be expected to run for about this length of time. | |
| 41 // Omissions: | |
| 42 // Doesn't test alarms attached to RTC. | |
| 43 // Assumptions: | |
| 44 // CYGVAR_KERNEL_COUNTERS_CLOCK must be set. | |
| 45 // Resolution of clock small compared with 5s. | |
| 46 // Overhead small compared with 5s. | |
| 47 // Options: | |
| 48 // CYGIMP_KERNEL_COUNTERS_SINGLE_LIST | |
| 49 // CYGIMP_KERNEL_COUNTERS_MULTI_LIST | |
| 50 // CYGVAR_KERNEL_COUNTERS_CLOCK | |
| 51 // CYGNUM_KERNEL_COUNTERS_MULTI_LIST_SIZE | |
| 52 //####DESCRIPTIONEND#### | |
| 53 | |
| 54 #include <pkgconf/kernel.h> | |
| 55 | |
| 56 #include <cyg/kernel/clock.hxx> | |
| 57 #include <cyg/kernel/thread.hxx> | |
| 58 | |
| 59 #include <cyg/infra/testcase.h> | |
| 60 | |
| 61 #include <cyg/kernel/clock.inl> | |
| 62 #include <cyg/kernel/thread.inl> | |
| 63 | |
| 64 #ifdef CYGVAR_KERNEL_COUNTERS_CLOCK | |
| 65 | |
| 66 | |
| 67 #define NTHREADS 1 | |
| 68 #include "testaux.hxx" | |
| 69 | |
| 70 static cyg_uint32 ticks; // Number of ticks thread[0] will delay for | |
| 71 | |
| 2 | 72 static cyg_uint64 TEST_DELAY; |
| 73 | |
| 0 | 74 static void entry0( CYG_ADDRWORD data ) |
| 75 { | |
| 76 ((Cyg_Thread *)data)->delay(ticks); | |
| 77 | |
| 78 CYG_TEST_PASS_FINISH("Clock 1 OK"); | |
| 79 } | |
| 80 | |
| 81 void clock1_main( void ) | |
| 82 { | |
| 83 CYG_TEST_INIT(); | |
| 84 | |
| 2 | 85 if (cyg_test_is_simulator) { |
| 86 TEST_DELAY = 100000000ll; | |
| 87 } else { | |
| 88 TEST_DELAY = 3000000000ll; | |
| 89 } | |
| 90 | |
| 0 | 91 new_thread(entry0, (CYG_ADDRWORD)&thread_obj[0]); |
| 92 | |
| 93 Cyg_Clock::cyg_resolution res; | |
| 94 | |
| 95 res = Cyg_Clock::real_time_clock->get_resolution (); | |
| 96 | |
| 97 // RTC takes res.dividend/res.divisor ns/tick | |
| 98 ticks = ((cyg_uint64)TEST_DELAY * res.divisor) / res.dividend; | |
| 99 | |
| 100 Cyg_Scheduler::start(); | |
| 101 } | |
| 102 | |
| 103 externC void | |
| 104 cyg_start( void ) | |
| 105 { | |
| 106 clock1_main(); | |
| 107 } | |
| 108 | |
| 109 #else // def CYGVAR_KERNEL_COUNTERS_CLOCK | |
| 110 | |
| 111 externC void | |
| 112 cyg_start( void ) | |
| 113 { | |
| 114 CYG_TEST_INIT(); | |
| 2 | 115 CYG_TEST_NA( "Kernel real-time clock disabled"); |
| 0 | 116 } |
| 117 | |
| 118 #endif // def CYGVAR_KERNEL_COUNTERS_CLOCK | |
| 119 | |
| 120 // EOF clock1.cxx |
