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