Mercurial > nand-ecoscentric
annotate packages/kernel/current/tests/thread1.cxx @ 3403:8c8767bb9a62 default tip
devs/nand/micron_mt29: Remove defunct references (in comments) to mt29f2g08_oob_ecc.
| author | Ross Younger <wry@ecoscentric.com> |
|---|---|
| date | Sun, 18 Jan 2015 17:59:01 +1300 |
| parents | 74dbf4c3f2e1 |
| children |
| rev | line source |
|---|---|
| 0 | 1 //========================================================================== |
| 2 // | |
| 3 // thread1.cxx | |
| 4 // | |
| 5 // Thread test 1 | |
| 6 // | |
| 7 //========================================================================== | |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
8 // ####ECOSGPLCOPYRIGHTBEGIN#### |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
9 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
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:
210
diff
changeset
|
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
12 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
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:
210
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:
210
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:
210
diff
changeset
|
16 // version. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
17 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
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:
210
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:
210
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:
210
diff
changeset
|
21 // for more details. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
22 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
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:
210
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:
210
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:
130
diff
changeset
|
26 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
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:
210
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:
210
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:
210
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:
210
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:
210
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:
210
diff
changeset
|
33 // General Public License v2. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
130
diff
changeset
|
34 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
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:
210
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:
210
diff
changeset
|
37 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
210
diff
changeset
|
38 // ####ECOSGPLCOPYRIGHTEND#### |
| 0 | 39 //========================================================================== |
| 40 //#####DESCRIPTIONBEGIN#### | |
| 41 // | |
| 42 // Author(s): dsm | |
| 43 // Contributors: dsm | |
| 44 // Date: 1998-02-11 | |
| 45 // Description: Tests some basic thread functions. | |
| 46 // Omissions: Cyg_ThreadTimer | |
| 47 // Cyg_Thread | |
| 48 // exit -- not necessarily called | |
| 49 // yield | |
| 50 // set_priority | |
| 51 // get_priority | |
| 52 // get/set_sleep_reason | |
| 53 // get/set_wake_reason | |
| 54 // set/clear_timer | |
| 55 // Cyg_ThreadQueue | |
| 56 // | |
| 57 //####DESCRIPTIONEND#### | |
| 58 | |
| 59 #include <pkgconf/kernel.h> | |
| 60 | |
| 61 #include <cyg/kernel/sched.hxx> | |
| 62 #include <cyg/kernel/thread.hxx> | |
| 63 | |
| 64 #include <cyg/infra/testcase.h> | |
| 65 | |
| 2 | 66 #ifdef CYGFUN_KERNEL_THREADS_TIMER |
| 67 | |
| 0 | 68 #include <cyg/kernel/sched.inl> |
| 69 #include <cyg/kernel/thread.inl> | |
| 70 | |
| 71 #include "testaux.hxx" | |
| 72 | |
| 2 | 73 #ifdef CYGNUM_HAL_STACK_SIZE_TYPICAL |
| 74 #define STACKSIZE CYGNUM_HAL_STACK_SIZE_TYPICAL | |
| 75 #else | |
| 0 | 76 #define STACKSIZE 2000 |
| 2 | 77 #endif |
| 0 | 78 |
| 79 static char stack[2][STACKSIZE]; | |
| 80 | |
| 81 static char thread[2][sizeof(Cyg_Thread)]; | |
| 82 | |
| 83 static Cyg_Thread *pt0,*pt1; | |
| 84 static cyg_uint16 uid0,uid1; | |
| 85 | |
| 86 | |
| 87 static void entry0( CYG_ADDRWORD data ) | |
| 88 { | |
| 89 CHECK( 222 == data ); | |
| 90 | |
| 91 uid0 = pt0->get_unique_id(); | |
| 92 | |
| 93 pt1->suspend(); | |
| 94 pt1->resume(); | |
| 95 | |
| 96 do { | |
| 2 | 97 pt0->delay(1); |
| 0 | 98 } while( Cyg_Thread::RUNNING == pt1->get_state() ); |
| 99 | |
| 100 CHECK( Cyg_Thread::SLEEPING == pt1->get_state() ); | |
| 101 | |
| 102 pt1->wake(); | |
| 103 | |
| 104 CHECK( uid0 != uid1 ); | |
| 105 | |
| 106 CYG_TEST_PASS_FINISH("Thread 1 OK"); | |
| 107 } | |
| 108 | |
| 109 static void entry1( CYG_ADDRWORD data ) | |
| 110 { | |
| 111 CHECK( 333 == data ); | |
| 112 | |
| 113 uid1 = pt1->get_unique_id(); | |
| 114 | |
| 115 Cyg_Thread *self = Cyg_Thread::self(); | |
| 116 | |
| 117 CHECK( self == pt1 ); | |
| 118 | |
| 119 pt1->sleep(); | |
| 120 pt1->suspend(); | |
| 121 | |
| 2 | 122 Cyg_Thread::exit(); // no guarantee this will be called |
| 0 | 123 } |
| 124 | |
| 125 void thread1_main( void ) | |
| 126 { | |
| 127 CYG_TEST_INIT(); | |
| 128 | |
| 129 pt0 = new((void *)&thread[0]) | |
| 2 | 130 Cyg_Thread(CYG_SCHED_DEFAULT_INFO, |
| 131 entry0, 222, | |
| 132 "thread 0", | |
| 133 (CYG_ADDRESS)stack[0], STACKSIZE ); | |
| 0 | 134 pt1 = new((void *)&thread[1]) |
| 2 | 135 Cyg_Thread(CYG_SCHED_DEFAULT_INFO, |
| 136 entry1, 333, | |
| 137 "thread 1", | |
| 138 (CYG_ADDRESS)stack[1], STACKSIZE ); | |
| 0 | 139 |
| 140 CYG_ASSERTCLASS( pt0, "error" ); | |
| 141 CYG_ASSERTCLASS( pt1, "error" ); | |
| 142 | |
| 143 pt0->resume(); | |
| 144 pt1->resume(); | |
| 145 | |
| 146 Cyg_Scheduler::start(); | |
| 147 | |
| 148 CYG_TEST_FAIL_FINISH("Not reached"); | |
| 149 } | |
| 150 | |
| 151 externC void | |
| 152 cyg_start( void ) | |
| 153 { | |
|
130
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
66
diff
changeset
|
154 #ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG |
|
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
66
diff
changeset
|
155 cyg_hal_invoke_constructors(); |
|
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
66
diff
changeset
|
156 #endif |
| 0 | 157 thread1_main(); |
| 158 } | |
| 159 | |
| 2 | 160 #else // ifdef CYGFUN_KERNEL_THREADS_TIMER |
| 161 | |
| 162 externC void | |
| 163 cyg_start( void ) | |
| 164 { | |
| 165 CYG_TEST_INIT(); | |
| 166 CYG_TEST_NA("Kernel threads timer disabled"); | |
| 167 } | |
| 168 | |
| 169 #endif // ifdef CYGFUN_KERNEL_THREADS_TIMER | |
| 170 | |
| 0 | 171 // EOF thread1.cxx |
