Changeset 3381ed7 for libcfa/src/concurrency/kernel_private.hfa
- Timestamp:
- Feb 13, 2020, 4:18:07 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 50b8885
- Parents:
- 9f575ea
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel_private.hfa
r9f575ea r3381ed7 32 32 33 33 void ScheduleThread( thread_desc * ) __attribute__((nonnull (1))); 34 static inline void WakeThread( thread_desc * thrd, bool must_yield ) {35 if( !thrd ) return;36 37 enum coroutine_state new_state = must_yield ? Reschedule : Rerun;38 39 disable_interrupts();40 static_assert(sizeof(thrd->state) == sizeof(int));41 enum coroutine_state old_state = (enum coroutine_state)__atomic_exchange_n((volatile int *)&thrd->state, (int)new_state, __ATOMIC_SEQ_CST);42 switch(old_state) {43 case Active:44 // Wake won the race, the thread will reschedule/rerun itself45 break;46 case Inactive:47 // Wake lost the race,48 thrd->state = Inactive;49 ScheduleThread( thrd );50 break;51 case Rerun:52 case Reschedule:53 abort("More than one thread attempted to schedule thread %p\n", thrd);54 break;55 case Halted:56 case Start:57 case Primed:58 default:59 // This makes no sense, something is wrong abort60 abort();61 }62 enable_interrupts( __cfaabi_dbg_ctx );63 }64 thread_desc * nextThread(cluster * this);65 34 66 35 //Block current thread and release/wake-up the following resources 67 void BlockInternal(void); 68 void BlockInternal(__spinlock_t * lock); 69 void BlockInternal(thread_desc * thrd); 70 void BlockInternal(__spinlock_t * lock, thread_desc * thrd); 71 void BlockInternal(__spinlock_t * locks [], unsigned short count); 72 void BlockInternal(__spinlock_t * locks [], unsigned short count, thread_desc * thrds [], unsigned short thrd_count); 73 void BlockInternal(__finish_callback_fptr_t callback); 74 void LeaveThread(__spinlock_t * lock, thread_desc * thrd); 36 void LeaveThread(); 37 38 bool force_yield( enum __Preemption_Reason ); 75 39 76 40 //-----------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.