- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/thread.cfa
r015925a ra167c70c 19 19 #include "thread.hfa" 20 20 21 #include "exception.hfa" 21 22 #include "kernel/private.hfa" 22 #include " exception.hfa"23 #include "limits.hfa" 23 24 24 25 #define __CFA_INVOKE_PRIVATE__ … … 26 27 27 28 extern uint32_t __global_random_seed, __global_random_prime, __global_random_mask; 29 30 #pragma GCC visibility push(default) 28 31 29 32 //----------------------------------------------------------------------------- … … 42 45 curr_cluster = &cl; 43 46 link.next = 0p; 44 link.ts = -1llu;47 link.ts = MAX; 45 48 preferred = ready_queue_new_preferred(); 46 49 last_proc = 0p; 47 50 random_state = __global_random_mask ? __global_random_prime : __global_random_prime ^ rdtscl(); 48 51 #if defined( __CFA_WITH_VERIFY__ ) 52 executing = 0p; 49 53 canary = 0x0D15EA5E0D15EA5Ep; 50 54 #endif … … 87 91 } 88 92 89 forall(T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled ,(T))90 | { EHM_DEFAULT_VTABLE(ThreadCancelled ,(T)); })93 forall(T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled(T)) 94 | { EHM_DEFAULT_VTABLE(ThreadCancelled(T)); }) 91 95 void ?{}( thread_dtor_guard_t & this, 92 96 T & thrd, void(*cancelHandler)(ThreadCancelled(T) &)) { … … 166 170 167 171 //----------------------------------------------------------------------------- 168 forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled ,(T))169 | { EHM_DEFAULT_VTABLE(ThreadCancelled,(T)); })172 forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled(T)) 173 | { EHM_DEFAULT_VTABLE(ThreadCancelled(T)); }) 170 174 T & join( T & this ) { 171 175 thread_dtor_guard_t guard = { this, defaultResumptionHandler }; 172 176 return this; 177 } 178 179 //----------------------------------------------------------------------------- 180 bool migrate( thread$ * thrd, struct cluster & cl ) { 181 182 monitor$ * tmon = get_monitor(thrd); 183 monitor$ * __monitors[] = { tmon }; 184 monitor_guard_t __guard = { __monitors, 1 }; 185 186 187 { 188 // if nothing needs to be done, return false 189 if( thrd->curr_cluster == &cl ) return false; 190 191 // are we migrating ourself? 192 const bool local = thrd == active_thread(); 193 194 /* paranoid */ verify( !local || &cl != active_cluster() ); 195 /* paranoid */ verify( !local || thrd->curr_cluster == active_cluster() ); 196 /* paranoid */ verify( !local || thrd->curr_cluster == active_processor()->cltr ); 197 /* paranoid */ verify( local || tmon->signal_stack.top->owner->waiting_thread == thrd ); 198 /* paranoid */ verify( local || tmon->signal_stack.top ); 199 200 // make sure we aren't interrupted while doing this 201 // not as important if we aren't local 202 disable_interrupts(); 203 204 // actually move the thread 205 unregister( thrd->curr_cluster, *thrd ); 206 thrd->curr_cluster = &cl; 207 doregister( thrd->curr_cluster, *thrd ); 208 209 // restore interrupts 210 enable_interrupts(); 211 212 // if this is the local thread, we are still running on the old cluster 213 if(local) yield(); 214 215 /* paranoid */ verify( !local || &cl == active_cluster() ); 216 /* paranoid */ verify( !local || thrd->curr_cluster == active_cluster() ); 217 /* paranoid */ verify( !local || thrd->curr_cluster == active_processor()->cltr ); 218 /* paranoid */ verify( local || tmon->signal_stack.top ); 219 /* paranoid */ verify( local || tmon->signal_stack.top->owner->waiting_thread == thrd ); 220 221 return true; 222 } 173 223 } 174 224
Note: See TracChangeset
for help on using the changeset viewer.