Changeset 3ea8ad1
- Timestamp:
- Nov 18, 2020, 2:28:02 PM (3 years ago)
- Branches:
- ADT, arm-eh, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 69d1748
- Parents:
- 9d6e1b8a
- Location:
- libcfa/src/concurrency
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/invoke.h
r9d6e1b8a r3ea8ad1 68 68 }; 69 69 70 enum __Coroutine_State { Halted, Start, Primed, Blocked, Ready, Active, Cancelled };70 enum __Coroutine_State { Halted, Start, Primed, Blocked, Ready, Active, Cancelled, Halting }; 71 71 72 72 struct $coroutine { -
libcfa/src/concurrency/kernel.cfa
r9d6e1b8a r3ea8ad1 288 288 } 289 289 290 if(unlikely(thrd_dst->state == Halt ed)) {290 if(unlikely(thrd_dst->state == Halting)) { 291 291 // The thread has halted, it should never be scheduled/run again 292 292 // finish the thread … … 484 484 /* paranoid */ verifyf( ((uintptr_t)thrd->context.SP) < ((uintptr_t)__get_stack(thrd->curr_cor)->base ), "ERROR : $thread %p has been corrupted.\n StackPointer too small.\n", thrd ); 485 485 486 thrd->state = Halt ed;486 thrd->state = Halting; 487 487 if( TICKET_RUNNING != thrd->ticket ) { abort( "Thread terminated with pending unpark" ); } 488 488 if( thrd != this->owner ) { abort( "Thread internal monitor has incorrect owner" ); } -
libcfa/src/concurrency/monitor.cfa
r9d6e1b8a r3ea8ad1 142 142 static void __dtor_enter( $monitor * this, fptr_t func, bool join ) { 143 143 $thread * thrd = active_thread(); 144 #if defined( __CFA_WITH_VERIFY__ ) 145 bool is_thrd = this == &thrd->self_mon; 146 #endif 144 147 145 148 // Lock the monitor spinlock … … 155 158 __set_owner( this, thrd ); 156 159 157 verifyf( active_thread() == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", active_thread(), this->owner, this->recursion, this ); 160 /* paranoid */ verifyf( active_thread() == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", active_thread(), this->owner, this->recursion, this ); 161 /* paranoid */ verify( !is_thrd || thrd->state == Halted || thrd->state == Cancelled ); 158 162 159 163 unlock( this->lock ); … … 175 179 __set_owner( this, thrd ); 176 180 177 verifyf( active_thread() == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", active_thread(), this->owner, this->recursion, this ); 181 /* paranoid */ verifyf( active_thread() == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", active_thread(), this->owner, this->recursion, this ); 182 /* paranoid */ verify( !is_thrd || thrd->state == Halted || thrd->state == Cancelled ); 178 183 179 184 unlock( this->lock ); 180 185 return; 181 186 } 187 188 // The monitor is busy, if this is a thread and the thread owns itself, it better be active 189 /* paranoid */ verify( !is_thrd || this->owner != thrd || (thrd->state != Halted && thrd->state != Cancelled) ); 182 190 183 191 __lock_size_t count = 1; … … 209 217 // Some one was waiting for us, enter 210 218 /* paranoid */ verifyf( active_thread() == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", active_thread(), this->owner, this->recursion, this ); 219 220 __cfaabi_dbg_print_safe( "Kernel : Destroying %p\n", this); 221 return; 211 222 } 212 223 else { … … 228 239 return; 229 240 } 230 231 __cfaabi_dbg_print_safe( "Kernel : Destroying %p\n", this);232 233 241 } 234 242 … … 294 302 295 303 /* paranoid */ verifyf( thrd == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", thrd, this->owner, this->recursion, this ); 296 /* paranoid */ verify( thrd->state == Halt ed);304 /* paranoid */ verify( thrd->state == Halting ); 297 305 /* paranoid */ verify( this->recursion == 1 ); 298 306 … … 303 311 // Fetch the next thread, can be null 304 312 $thread * new_owner = next_thread( this ); 313 314 // Mark the state as fully halted 315 thrd->state = Halted; 305 316 306 317 // Release the monitor lock -
libcfa/src/concurrency/thread.cfa
r9d6e1b8a r3ea8ad1 82 82 T & thrd, void(*defaultResumptionHandler)(ThreadCancelled(T) &)) { 83 83 $monitor * m = get_monitor(thrd); 84 $thread * desc = get_thread(thrd); 85 86 // Setup the monitor guard 84 87 void (*dtor)(T& mutex this) = ^?{}; 85 88 bool join = defaultResumptionHandler != (void(*)(ThreadCancelled(T)&))0; 86 89 (this.mg){&m, (void(*)())dtor, join}; 87 90 91 92 /* paranoid */ verifyf( Halted == desc->state || Cancelled == desc->state, "Expected thread to be Halted or Cancelled, was %d\n", (int)desc->state ); 93 88 94 // After the guard set-up and any wait, check for cancellation. 89 $thread * desc = get_thread(thrd);90 95 struct _Unwind_Exception * cancellation = desc->self_cor.cancellation; 91 96 if ( likely( 0p == cancellation ) ) {
Note: See TracChangeset
for help on using the changeset viewer.