comparison packages/kernel/current/tests/thread2.cxx @ 2:443894e2e912 ecos-v1_2_1-release

Block commit of eCos version 1.2.1
author jlarmour
date Tue, 11 May 1999 12:24:34 +0000
parents 3111d98ba7b3
children c38311975d4f
comparison
equal deleted inserted replaced
1:72f549f0d891 2:443894e2e912
20 // 20 //
21 // The Original Code is eCos - Embedded Cygnus Operating System, released 21 // The Original Code is eCos - Embedded Cygnus Operating System, released
22 // September 30, 1998. 22 // September 30, 1998.
23 // 23 //
24 // The Initial Developer of the Original Code is Cygnus. Portions created 24 // The Initial Developer of the Original Code is Cygnus. Portions created
25 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved. 25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved.
26 // ------------------------------------------- 26 // -------------------------------------------
27 // 27 //
28 //####COPYRIGHTEND#### 28 //####COPYRIGHTEND####
29 //========================================================================== 29 //==========================================================================
30 //#####DESCRIPTIONBEGIN#### 30 //#####DESCRIPTIONBEGIN####
63 63
64 #include <cyg/infra/testcase.h> 64 #include <cyg/infra/testcase.h>
65 65
66 #include <cyg/kernel/sched.inl> 66 #include <cyg/kernel/sched.inl>
67 67
68 #include "testaux.hxx"
69
70 #ifndef CYGIMP_THREAD_PRIORITY 68 #ifndef CYGIMP_THREAD_PRIORITY
71 #error "Test requires thread priorities" 69 #error "Test requires thread priorities"
72 #endif 70 #endif
73
74 #define STACKSIZE 4096
75
76 static char stack[3][STACKSIZE];
77 71
78 static Cyg_Counting_Semaphore s0, s1, s2; 72 static Cyg_Counting_Semaphore s0, s1, s2;
79 73
80 static volatile cyg_ucount8 q = 0; 74 static volatile cyg_ucount8 q = 0;
81 75
82 static Cyg_Thread *thread0, *thread1, *thread2; 76 static Cyg_Thread *thread0, *thread1, *thread2;
83 77
84 static char thread[3][sizeof(Cyg_Thread)]; 78 #define NTHREADS 3
85 79 #include "testaux.hxx"
86 inline void *operator new(size_t size, void *ptr) { return ptr; };
87
88 80
89 static void entry0( CYG_ADDRWORD data ) 81 static void entry0( CYG_ADDRWORD data )
90 { 82 {
91 CHECK( 0 == q++ ); 83 CHECK( 0 == q++ );
92 s0.wait(); 84 s0.wait();
159 151
160 void thread2_main( void ) 152 void thread2_main( void )
161 { 153 {
162 CYG_TEST_INIT(); 154 CYG_TEST_INIT();
163 155
164 thread0 = new((void *)&thread[0]) 156 thread0 = new_thread( entry0, 0 );
165 Cyg_Thread(entry0, 0, STACKSIZE, (CYG_ADDRESS)stack[0] ); 157 thread1 = new_thread( entry1, 1 );
166 thread1 = new((void *)&thread[1]) 158 thread2 = new_thread( entry2, 2 );
167 Cyg_Thread(entry1, 1, STACKSIZE, (CYG_ADDRESS)stack[1] );
168 thread2 = new((void *)&thread[2])
169 Cyg_Thread(entry2, 2, STACKSIZE, (CYG_ADDRESS)stack[2] );
170 159
171 thread0->resume(); 160 thread0->resume();
172 thread1->resume(); 161 thread1->resume();
173 thread2->resume(); 162 thread2->resume();
174 163