Changeset b826e6b for src/libcfa/concurrency/kernel_private.h
- Timestamp:
- Jul 19, 2017, 11:49:33 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 9cc0472
- Parents:
- fea3faa (diff), a57cb58 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/kernel_private.h
rfea3faa rb826e6b 18 18 #define KERNEL_PRIVATE_H 19 19 20 #include "libhdr.h" 21 20 22 #include "kernel" 21 23 #include "thread" … … 23 25 #include "alarm.h" 24 26 25 #include "libhdr.h"26 27 27 28 //----------------------------------------------------------------------------- 28 29 // Scheduler 30 31 extern "C" { 32 void disable_interrupts(); 33 void enable_interrupts_noPoll(); 34 void enable_interrupts( DEBUG_CTX_PARAM ); 35 } 36 29 37 void ScheduleThread( thread_desc * ); 38 static inline void WakeThread( thread_desc * thrd ) { 39 if( !thrd ) return; 40 41 disable_interrupts(); 42 ScheduleThread( thrd ); 43 enable_interrupts( DEBUG_CTX ); 44 } 30 45 thread_desc * nextThread(cluster * this); 31 46 32 void ScheduleInternal(void); 33 void ScheduleInternal(spinlock * lock); 34 void ScheduleInternal(thread_desc * thrd); 35 void ScheduleInternal(spinlock * lock, thread_desc * thrd); 36 void ScheduleInternal(spinlock ** locks, unsigned short count); 37 void ScheduleInternal(spinlock ** locks, unsigned short count, thread_desc ** thrds, unsigned short thrd_count); 47 //Block current thread and release/wake-up the following resources 48 void BlockInternal(void); 49 void BlockInternal(spinlock * lock); 50 void BlockInternal(thread_desc * thrd); 51 void BlockInternal(spinlock * lock, thread_desc * thrd); 52 void BlockInternal(spinlock ** locks, unsigned short count); 53 void BlockInternal(spinlock ** locks, unsigned short count, thread_desc ** thrds, unsigned short thrd_count); 54 void LeaveThread(spinlock * lock, thread_desc * thrd); 38 55 39 56 //----------------------------------------------------------------------------- … … 49 66 void spin(processor * this, unsigned int * spin_count); 50 67 51 struct system_proc_t { 52 processor proc; 53 68 struct event_kernel_t { 54 69 alarm_list_t alarms; 55 spinlock alarm_lock; 56 57 bool pending_alarm; 70 spinlock lock; 58 71 }; 59 72 60 extern cluster * systemCluster; 61 extern system_proc_t * systemProcessor; 62 extern thread_local processor * this_processor; 73 extern event_kernel_t * event_kernel; 63 74 64 static inline void disable_interrupts() { 65 __attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, 1, __ATOMIC_SEQ_CST ); 66 assert( prev != (unsigned short) -1 ); 67 } 68 69 static inline void enable_interrupts_noRF() { 70 __attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, -1, __ATOMIC_SEQ_CST ); 71 verify( prev != (unsigned short) 0 ); 72 } 73 74 static inline void enable_interrupts() { 75 __attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, -1, __ATOMIC_SEQ_CST ); 76 verify( prev != (unsigned short) 0 ); 77 if( prev == 1 && this_processor->pending_preemption ) { 78 ScheduleInternal( this_processor->current_thread ); 79 this_processor->pending_preemption = false; 80 } 81 } 75 extern volatile thread_local processor * this_processor; 76 extern volatile thread_local coroutine_desc * this_coroutine; 77 extern volatile thread_local thread_desc * this_thread; 78 extern volatile thread_local bool preemption_in_progress; 79 extern volatile thread_local unsigned short disable_preempt_count; 82 80 83 81 //----------------------------------------------------------------------------- … … 90 88 extern void ThreadCtxSwitch(coroutine_desc * src, coroutine_desc * dst); 91 89 90 //----------------------------------------------------------------------------- 91 // Utils 92 #define KERNEL_STORAGE(T,X) static char storage_##X[sizeof(T)] 93 92 94 #endif //KERNEL_PRIVATE_H 93 95
Note:
See TracChangeset
for help on using the changeset viewer.