comparison packages/kernel/current/tests/sync3.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####
93 93
94 } 94 }
95 95
96 static void entry0( CYG_ADDRWORD data ) 96 static void entry0( CYG_ADDRWORD data )
97 { 97 {
98 s0.wait(); // wait until t2 has gained m0.lock 98 s0.wait(); // wait until t2 has gained m0.lock
99 check_priorities_normal(); 99 check_priorities_normal();
100 m0.lock(); { 100 m0.lock(); {
101 check_priorities_normal(); 101 check_priorities_normal();
102 CHECK( 2 == m0d ); 102 CHECK( 2 == m0d );
103 m0d = 0; 103 m0d = 0;
104 } m0.unlock(); 104 } m0.unlock();
105 check_priorities_normal(); 105 check_priorities_normal();
106 #ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE 106 #ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE
107 CYG_TEST_PASS_FINISH("Sync 3 OK -- priority inheritance worked"); 107 CYG_TEST_PASS_FINISH("Sync 3 OK -- priority inheritance worked");
108 #else 108 #else
116 s1.wait(); 116 s1.wait();
117 // The delay below will allow testing of the priority inheritance 117 // The delay below will allow testing of the priority inheritance
118 // mechanism when scheduler does not guarantee to schedule threads 118 // mechanism when scheduler does not guarantee to schedule threads
119 // in strict priority order. 119 // in strict priority order.
120 for ( volatile cyg_ucount32 i=0; i < 100000; i++ ) 120 for ( volatile cyg_ucount32 i=0; i < 100000; i++ )
121 ; // math is hard 121 ; // math is hard
122 122
123 #ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE 123 #ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE
124 // thread0 should have stopped by this point 124 // thread0 should have stopped by this point
125 CYG_TEST_FAIL_FINISH("Sync 3: priority inheritance mechanism failed"); 125 CYG_TEST_FAIL_FINISH("Sync 3: priority inheritance mechanism failed");
126 #else 126 #else
132 } 132 }
133 133
134 void entry2( CYG_ADDRWORD data ) 134 void entry2( CYG_ADDRWORD data )
135 { 135 {
136 m0.lock(); { 136 m0.lock(); {
137 CHECK( 9 == m0d ); 137 CHECK( 9 == m0d );
138 check_priorities_normal(); 138 check_priorities_normal();
139 s0.post(); // Now I have lock on m0, wake t0 then t1 139 s0.post(); // Now I have lock on m0, wake t0 then t1
140 check_priorities_inherited(); 140 check_priorities_inherited();
141 s1.post(); 141 s1.post();
142 check_priorities_inherited(); 142 check_priorities_inherited();
143 m0d = 2; 143 m0d = 2;
144 } m0.unlock(); 144 } m0.unlock();
145 check_priorities_normal(); 145 check_priorities_normal();
146 m0.lock(); { 146 m0.lock(); {
147 check_priorities_normal(); 147 check_priorities_normal();
148 CHECK( 0 == m0d ); 148 CHECK( 0 == m0d );
149 m0d = 21; 149 m0d = 21;
150 s2.wait(); // never posted 150 s2.wait(); // never posted
151 } m0.unlock(); 151 } m0.unlock();
152 } 152 }
153 153
154 154
155 155