Changeset e60e0dc for src/libcfa/concurrency/kernel
- Timestamp:
- Jul 17, 2017, 3:54:02 PM (7 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:
- 5bd0aad
- Parents:
- b706db1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/kernel
rb706db1 re60e0dc 28 28 //----------------------------------------------------------------------------- 29 29 // Locks 30 bool try_lock ( spinlock * DEBUG_CTX_PARAM2 ); 31 void lock ( spinlock * DEBUG_CTX_PARAM2 );32 void lock_yield( spinlock * DEBUG_CTX_PARAM2 ); 33 void unlock ( spinlock * ); 30 void lock ( spinlock * DEBUG_CTX_PARAM2 ); // Lock the spinlock, spin if already acquired 31 void lock_yield( spinlock * DEBUG_CTX_PARAM2 ); // Lock the spinlock, yield repeatedly if already acquired 32 bool try_lock ( spinlock * DEBUG_CTX_PARAM2 ); // Lock the spinlock, return false if already acquired 33 void unlock ( spinlock * ); // Unlock the spinlock 34 34 35 35 struct semaphore { … … 48 48 // Cluster 49 49 struct cluster { 50 __thread_queue_t ready_queue; 51 spinlock lock; 50 spinlock ready_queue_lock; // Ready queue locks 51 __thread_queue_t ready_queue; // Ready queue for threads 52 unsigned long long int preemption; // Preemption rate on this cluster 52 53 }; 53 54 … … 76 77 static inline void ^?{}(FinishAction * this) {} 77 78 79 // Processor 80 // Wrapper around kernel threads 78 81 struct processor { 79 struct processorCtx_t * runner; 80 cluster * cltr; 81 pthread_t kernel_thread; 82 // Main state 83 struct processorCtx_t * runner; // Coroutine ctx who does keeps the state of the processor 84 cluster * cltr; // Cluster from which to get threads 85 pthread_t kernel_thread; // Handle to pthreads 82 86 83 semaphore terminated; 84 volatile bool is_terminated; 87 // Termination 88 volatile bool do_terminate; // Set to true to notify the processor should terminate 89 semaphore terminated; // Termination synchronisation 85 90 86 struct FinishAction finish; 91 // RunThread data 92 struct FinishAction finish; // Action to do after a thread is ran 87 93 88 struct alarm_node_t * preemption_alarm; 89 unsigned int preemption; 94 // Preemption data 95 struct alarm_node_t * preemption_alarm; // Node which is added in the discrete event simulaiton 96 bool pending_preemption; // If true, a preemption was triggered in an unsafe region, the processor must preempt as soon as possible 90 97 91 bool pending_preemption; 92 93 char * last_enable; 98 #ifdef __CFA_DEBUG__ 99 char * last_enable; // Last function to enable preemption on this processor 100 #endif 94 101 }; 95 102
Note: See TracChangeset
for help on using the changeset viewer.