Changeset c6c7e6c
- Timestamp:
- Apr 24, 2021, 6:35:43 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- a3821fa
- Parents:
- c1c95b1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.cfa
rc1c95b1 rc6c7e6c 110 110 static $thread * __next_thread(cluster * this); 111 111 static $thread * __next_thread_slow(cluster * this); 112 static inline bool __must_unpark( $thread * thrd ) __attribute((nonnull(1))); 112 113 static void __run_thread(processor * this, $thread * dst); 113 114 static void __wake_one(cluster * cltr); … … 496 497 } 497 498 498 void unpark( $thread * thrd ) { 499 if( !thrd ) return; 500 499 static inline bool __must_unpark( $thread * thrd ) { 501 500 int old_ticket = __atomic_fetch_add(&thrd->ticket, 1, __ATOMIC_SEQ_CST); 502 501 switch(old_ticket) { 503 502 case TICKET_RUNNING: 504 503 // Wake won the race, the thread will reschedule/rerun itself 505 break;504 return false; 506 505 case TICKET_BLOCKED: 507 506 /* paranoid */ verify( ! thrd->preempted != __NO_PREEMPTION ); 508 507 /* paranoid */ verify( thrd->state == Blocked ); 509 510 { 511 /* paranoid */ verify( publicTLS_get(this_proc_id) ); 512 disable_interrupts(); 513 514 /* paranoid */ verify( ! __preemption_enabled() ); 515 516 // Wake lost the race, 517 __schedule_thread( thrd ); 518 519 /* paranoid */ verify( ! __preemption_enabled() ); 520 521 enable_interrupts_noPoll(); 522 /* paranoid */ verify( publicTLS_get(this_proc_id) ); 523 } 524 525 break; 508 return true; 526 509 default: 527 510 // This makes no sense, something is wrong abort 528 511 abort("Thread %p (%s) has mismatch park/unpark\n", thrd, thrd->self_cor.name); 512 } 513 } 514 515 void unpark( $thread * thrd ) { 516 if( !thrd ) return; 517 518 if(__must_unpark(thrd)) { 519 /* paranoid */ verify( publicTLS_get(this_proc_id) ); 520 disable_interrupts(); 521 522 /* paranoid */ verify( ! __preemption_enabled() ); 523 524 // Wake lost the race, 525 __schedule_thread( thrd ); 526 527 /* paranoid */ verify( ! __preemption_enabled() ); 528 529 enable_interrupts_noPoll(); 530 /* paranoid */ verify( publicTLS_get(this_proc_id) ); 529 531 } 530 532 }
Note: See TracChangeset
for help on using the changeset viewer.