Changeset a167c70c for libcfa/src
- Timestamp:
- Oct 27, 2022, 11:24:54 AM (2 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 63d1ebe, 88ac843e
- Parents:
- 8b74fa7
- Location:
- libcfa/src/concurrency
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/thread.cfa
r8b74fa7 ra167c70c 178 178 179 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 } 223 } 224 225 //----------------------------------------------------------------------------- 180 226 #define GENERATOR LCG 181 227 -
libcfa/src/concurrency/thread.hfa
r8b74fa7 ra167c70c 132 132 133 133 //---------- 134 // misc 135 bool migrate( thread$ * thrd, struct cluster & cl ); 136 137 forall( T & | is_thread(T) ) 138 static inline bool migrate( T & mutex thrd, struct cluster & cl ) { return migrate( &(thread&)thrd, cl ); } 139 140 141 //---------- 134 142 // prng 135 143 static inline {
Note: See TracChangeset
for help on using the changeset viewer.