Mercurial > nand-ecoscentric
annotate packages/kernel/current/tests/kill.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 // kill.cxx | |
| 4 // | |
| 5 // Thread kill test | |
| 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:
151
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:
151
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:
151
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:
151
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:
151
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): nickg | |
| 2 | 43 // Contributors: nickg |
| 0 | 44 // Date: 1998-04-24 |
| 45 // Description: Tests the functionality of thread kill() and | |
| 46 // reinitalize(). | |
| 47 //####DESCRIPTIONEND#### | |
| 48 | |
| 49 #include <pkgconf/kernel.h> | |
| 50 | |
| 51 #include <cyg/kernel/thread.hxx> | |
| 52 #include <cyg/kernel/thread.inl> | |
| 53 #include <cyg/kernel/sched.hxx> | |
| 54 #include <cyg/kernel/mutex.hxx> | |
| 55 #include <cyg/kernel/sema.hxx> | |
| 56 | |
| 57 #include <cyg/infra/testcase.h> | |
| 58 | |
| 2 | 59 #ifdef CYGFUN_KERNEL_THREADS_TIMER |
| 60 | |
| 0 | 61 #include <cyg/kernel/sched.inl> |
| 62 | |
| 63 #define NTHREADS 3 | |
| 64 | |
| 65 #include "testaux.hxx" | |
| 66 | |
|
151
25e238959bae
Merge from eCos master repository on 2001-02-12-23:44:24-GMT
jlarmour
parents:
130
diff
changeset
|
67 // In general, this delay has to be long enough to account for slow targets |
|
25e238959bae
Merge from eCos master repository on 2001-02-12-23:44:24-GMT
jlarmour
parents:
130
diff
changeset
|
68 // and potential problems on e.g. the linux synthetic target to avoid |
| 2 | 69 // potential problems due to timing inaccuracy and scheduling of Linux |
|
151
25e238959bae
Merge from eCos master repository on 2001-02-12-23:44:24-GMT
jlarmour
parents:
130
diff
changeset
|
70 // tasks. It is decreased further below for simulators. |
| 2 | 71 int delay_ticks = 5; |
| 72 | |
| 73 | |
| 0 | 74 static Cyg_Binary_Semaphore s0, s1; |
| 75 | |
| 76 volatile cyg_atomic thread0_state; | |
| 77 volatile cyg_atomic thread1_state; | |
| 78 volatile cyg_atomic thread2_state; | |
| 79 | |
| 80 static void entry0( CYG_ADDRWORD data ) | |
| 81 { | |
| 82 Cyg_Thread *self = Cyg_Thread::self(); | |
| 83 | |
| 84 thread0_state = 1; | |
| 85 | |
| 86 s0.wait(); | |
| 87 | |
| 88 thread0_state = 2; | |
| 89 | |
| 90 CYG_TEST_FAIL_FINISH("Thread not killed"); | |
| 91 | |
| 92 self->exit(); | |
| 93 } | |
| 94 | |
| 95 | |
| 96 static void entry1( CYG_ADDRWORD data ) | |
| 97 { | |
| 98 Cyg_Thread *self = Cyg_Thread::self(); | |
| 99 | |
| 100 thread1_state = 1; | |
| 101 | |
| 2 | 102 self->delay(delay_ticks); |
| 0 | 103 |
| 104 if( thread2_state != 1 ) | |
| 105 CYG_TEST_FAIL_FINISH("Thread2 in wrong state"); | |
| 106 | |
| 107 thread1_state = 2; | |
| 108 | |
| 109 thread[0]->kill(); | |
| 110 | |
| 111 thread1_state = 3; | |
| 112 | |
| 113 thread[2]->kill(); | |
| 114 | |
| 115 thread1_state = 4; | |
| 116 | |
| 2 | 117 self->delay(delay_ticks); |
| 0 | 118 |
| 119 thread1_state = 5; | |
| 120 thread2_state = 0; | |
| 121 | |
| 122 thread[2]->reinitialize(); | |
| 123 thread[2]->resume(); | |
| 124 | |
| 2 | 125 self->delay(delay_ticks); |
| 0 | 126 |
| 127 if( thread2_state != 1 ) | |
| 128 CYG_TEST_FAIL_FINISH("Thread2 in wrong state"); | |
| 129 | |
| 130 thread1_state = 6; | |
| 131 | |
| 2 | 132 self->delay(delay_ticks); |
| 0 | 133 |
| 134 if( thread2_state != 2 ) | |
| 135 CYG_TEST_FAIL_FINISH("Thread2 in wrong state"); | |
| 136 | |
| 137 thread[2]->kill(); | |
| 138 | |
| 139 thread1_state = 7; | |
| 140 | |
| 141 CYG_TEST_PASS_FINISH("Kill OK"); | |
| 142 | |
| 143 Cyg_Thread::self()->exit(); | |
| 144 } | |
| 145 | |
| 146 static void entry2( CYG_ADDRWORD data ) | |
| 147 { | |
| 148 thread2_state = 1; | |
| 149 | |
| 150 while( thread1_state != 6 ) continue; | |
| 151 | |
| 152 thread2_state = 2; | |
| 153 | |
| 154 for(;;) continue; | |
| 155 | |
| 156 } | |
| 157 | |
| 158 void release_main(void) | |
| 159 { | |
| 160 CYG_TEST_INIT(); | |
| 161 | |
|
151
25e238959bae
Merge from eCos master repository on 2001-02-12-23:44:24-GMT
jlarmour
parents:
130
diff
changeset
|
162 if (cyg_test_is_simulator) |
|
25e238959bae
Merge from eCos master repository on 2001-02-12-23:44:24-GMT
jlarmour
parents:
130
diff
changeset
|
163 delay_ticks = 2; |
|
25e238959bae
Merge from eCos master repository on 2001-02-12-23:44:24-GMT
jlarmour
parents:
130
diff
changeset
|
164 |
| 0 | 165 new_thread( entry0, 0); |
| 166 new_thread( entry1, 1); | |
| 167 new_thread( entry2, 2); | |
| 168 | |
| 169 thread[0]->set_priority(5); | |
| 170 thread[1]->set_priority(6); | |
| 171 thread[2]->set_priority(7); | |
| 172 | |
| 173 Cyg_Scheduler::start(); | |
| 174 | |
| 175 CYG_TEST_FAIL_FINISH("Not reached"); | |
| 176 } | |
| 177 | |
| 178 externC void | |
| 179 cyg_start( void ) | |
| 180 { | |
|
130
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
66
diff
changeset
|
181 #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
|
182 cyg_hal_invoke_constructors(); |
|
eb9fd8c04db3
Merge from eCos master repository on 2000-10-23-17:01:37-BST
jlarmour
parents:
66
diff
changeset
|
183 #endif |
| 0 | 184 release_main(); |
| 185 } | |
| 2 | 186 |
| 187 #else // ifdef CYGFUN_KERNEL_THREADS_TIMER | |
| 188 | |
| 189 externC void | |
| 190 cyg_start( void ) | |
| 191 { | |
| 192 CYG_TEST_INIT(); | |
| 193 CYG_TEST_NA("Kernel threads timer disabled"); | |
| 194 } | |
| 195 | |
| 196 #endif // ifdef CYGFUN_KERNEL_THREADS_TIMER | |
| 0 | 197 |
| 198 // EOF kill.cxx |
