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