Changes in src/libcfa/concurrency/kernel [c81ebf9:e60e0dc]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/kernel
rc81ebf9 re60e0dc 28 28 //----------------------------------------------------------------------------- 29 29 // Locks 30 bool try_lock( spinlock * ); 31 void lock( spinlock * ); 32 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 33 34 34 struct s ignal_once {35 volatile bool cond;36 struct spinlock lock;37 struct __thread_queue_t blocked;35 struct semaphore { 36 spinlock lock; 37 int count; 38 __thread_queue_t waiting; 38 39 }; 39 40 40 void ?{}(signal_once * this); 41 void ^?{}(signal_once * this); 41 void ?{}(semaphore * this, int count = 1); 42 void ^?{}(semaphore * this); 43 void P(semaphore * this); 44 void V(semaphore * this); 42 45 43 void wait( signal_once * );44 void signal( signal_once * );45 46 46 47 //----------------------------------------------------------------------------- 47 48 // Cluster 48 49 struct cluster { 49 __thread_queue_t ready_queue; 50 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 51 53 }; 52 54 … … 68 70 unsigned short thrd_count; 69 71 }; 70 static inline void ?{}(FinishAction * this) { 72 static inline void ?{}(FinishAction * this) { 71 73 this->action_code = No_Action; 72 74 this->thrd = NULL; … … 75 77 static inline void ^?{}(FinishAction * this) {} 76 78 79 // Processor 80 // Wrapper around kernel threads 77 81 struct processor { 78 struct processorCtx_t * runner; 79 cluster * cltr; 80 coroutine_desc * current_coroutine; 81 thread_desc * current_thread; 82 pthread_t kernel_thread; 83 84 signal_once terminated; 85 volatile bool is_terminated; 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 86 86 87 struct FinishAction finish; 87 // Termination 88 volatile bool do_terminate; // Set to true to notify the processor should terminate 89 semaphore terminated; // Termination synchronisation 88 90 89 struct alarm_node_t * preemption_alarm;90 unsigned int preemption;91 // RunThread data 92 struct FinishAction finish; // Action to do after a thread is ran 91 93 92 unsigned short disable_preempt_count; 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 93 97 94 bool pending_preemption; 98 #ifdef __CFA_DEBUG__ 99 char * last_enable; // Last function to enable preemption on this processor 100 #endif 95 101 }; 96 102
Note:
See TracChangeset
for help on using the changeset viewer.