comparison packages/kernel/current/tests/kill.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####
31 // 31 //
32 // Author(s): nickg 32 // Author(s): nickg
33 // Contributors: nickg 33 // Contributors: nickg
34 // Date: 1998-04-24 34 // Date: 1998-04-24
35 // Description: Tests the functionality of thread kill() and 35 // Description: Tests the functionality of thread kill() and
36 // reinitalize(). 36 // reinitalize().
37 //####DESCRIPTIONEND#### 37 //####DESCRIPTIONEND####
38 38
44 #include <cyg/kernel/mutex.hxx> 44 #include <cyg/kernel/mutex.hxx>
45 #include <cyg/kernel/sema.hxx> 45 #include <cyg/kernel/sema.hxx>
46 46
47 #include <cyg/infra/testcase.h> 47 #include <cyg/infra/testcase.h>
48 48
49 #ifdef CYGFUN_KERNEL_THREADS_TIMER
50
49 #include <cyg/kernel/sched.inl> 51 #include <cyg/kernel/sched.inl>
50 52
51 #define NTHREADS 3 53 #define NTHREADS 3
52 54
53 #include "testaux.hxx" 55 #include "testaux.hxx"
56
57 #ifdef CYGPKG_HAL_I386_LINUX
58 // On the synthetic target the delay needs to be a bit bigger to avoid
59 // potential problems due to timing inaccuracy and scheduling of Linux
60 // tasks.
61 int delay_ticks = 5;
62 #else
63 // if we delayed for just one tick, there's a good chance the clock may
64 // roll over immediately, giving a negligible practical delay. So always use
65 // a value greater than 1
66 int delay_ticks = 2;
67 #endif
68
69
54 70
55 static Cyg_Binary_Semaphore s0, s1; 71 static Cyg_Binary_Semaphore s0, s1;
56 72
57 volatile cyg_atomic thread0_state; 73 volatile cyg_atomic thread0_state;
58 volatile cyg_atomic thread1_state; 74 volatile cyg_atomic thread1_state;
78 { 94 {
79 Cyg_Thread *self = Cyg_Thread::self(); 95 Cyg_Thread *self = Cyg_Thread::self();
80 96
81 thread1_state = 1; 97 thread1_state = 1;
82 98
83 self->delay(1); 99 self->delay(delay_ticks);
84 100
85 if( thread2_state != 1 ) 101 if( thread2_state != 1 )
86 CYG_TEST_FAIL_FINISH("Thread2 in wrong state"); 102 CYG_TEST_FAIL_FINISH("Thread2 in wrong state");
87 103
88 thread1_state = 2; 104 thread1_state = 2;
93 109
94 thread[2]->kill(); 110 thread[2]->kill();
95 111
96 thread1_state = 4; 112 thread1_state = 4;
97 113
98 self->delay(1); 114 self->delay(delay_ticks);
99 115
100 thread1_state = 5; 116 thread1_state = 5;
101 thread2_state = 0; 117 thread2_state = 0;
102 118
103 thread[2]->reinitialize(); 119 thread[2]->reinitialize();
104 thread[2]->resume(); 120 thread[2]->resume();
105 121
106 self->delay(1); 122 self->delay(delay_ticks);
107 123
108 if( thread2_state != 1 ) 124 if( thread2_state != 1 )
109 CYG_TEST_FAIL_FINISH("Thread2 in wrong state"); 125 CYG_TEST_FAIL_FINISH("Thread2 in wrong state");
110 126
111 thread1_state = 6; 127 thread1_state = 6;
112 128
113 self->delay(1); 129 self->delay(delay_ticks);
114 130
115 if( thread2_state != 2 ) 131 if( thread2_state != 2 )
116 CYG_TEST_FAIL_FINISH("Thread2 in wrong state"); 132 CYG_TEST_FAIL_FINISH("Thread2 in wrong state");
117 133
118 thread[2]->kill(); 134 thread[2]->kill();
156 externC void 172 externC void
157 cyg_start( void ) 173 cyg_start( void )
158 { 174 {
159 release_main(); 175 release_main();
160 } 176 }
177
178 #else // ifdef CYGFUN_KERNEL_THREADS_TIMER
179
180 externC void
181 cyg_start( void )
182 {
183 CYG_TEST_INIT();
184 CYG_TEST_NA("Kernel threads timer disabled");
185 }
186
187 #endif // ifdef CYGFUN_KERNEL_THREADS_TIMER
161 188
162 // EOF kill.cxx 189 // EOF kill.cxx