Changes in src/libcfa/concurrency/kernel [6b0b624:bdeba0b]
- File:
-
- 1 edited
-
src/libcfa/concurrency/kernel (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/kernel
r6b0b624 rbdeba0b 1 // -*- Mode: CFA -*- 1 2 // 2 3 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo … … 9 10 // Author : Thierry Delisle 10 11 // Created On : Tue Jan 17 12:27:26 2017 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Jul 22 09:58:39 201713 // Update Count : 212 // Last Modified By : Thierry Delisle 13 // Last Modified On : -- 14 // Update Count : 0 14 15 // 15 16 16 #pragma once 17 #ifndef KERNEL_H 18 #define KERNEL_H 17 19 18 20 #include <stdbool.h> … … 26 28 //----------------------------------------------------------------------------- 27 29 // Locks 28 void lock ( spinlock * DEBUG_CTX_PARAM2 ); // Lock the spinlock, spin if already acquired 29 void lock _yield( spinlock * DEBUG_CTX_PARAM2 ); // Lock the spinlock, yield repeatedly if already acquired30 bool try_lock ( spinlock * DEBUG_CTX_PARAM2 ); // Lock the spinlock, return false if already acquired 31 void unlock ( spinlock * ); // Unlock the spinlock30 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 * ); 32 34 33 35 struct semaphore { … … 46 48 // Cluster 47 49 struct cluster { 48 spinlock ready_queue_lock; // Ready queue locks 49 __thread_queue_t ready_queue; // Ready queue for threads 50 unsigned long long int preemption; // Preemption rate on this cluster 50 __thread_queue_t ready_queue; 51 spinlock lock; 51 52 }; 52 53 … … 75 76 static inline void ^?{}(FinishAction * this) {} 76 77 77 // Processor78 // Wrapper around kernel threads79 78 struct processor { 80 // Main state 81 struct processorCtx_t * runner; // Coroutine ctx who does keeps the state of the processor 82 cluster * cltr; // Cluster from which to get threads 83 pthread_t kernel_thread; // Handle to pthreads 79 struct processorCtx_t * runner; 80 cluster * cltr; 81 pthread_t kernel_thread; 84 82 85 // Termination 86 volatile bool do_terminate; // Set to true to notify the processor should terminate 87 semaphore terminated; // Termination synchronisation 83 semaphore terminated; 84 volatile bool is_terminated; 88 85 89 // RunThread data 90 struct FinishAction finish; // Action to do after a thread is ran 86 struct FinishAction finish; 91 87 92 // Preemption data 93 struct alarm_node_t * preemption_alarm; // Node which is added in the discrete event simulaiton 94 bool pending_preemption; // If true, a preemption was triggered in an unsafe region, the processor must preempt as soon as possible 88 struct alarm_node_t * preemption_alarm; 89 unsigned int preemption; 95 90 96 #ifdef __CFA_DEBUG__ 97 char * last_enable; // Last function to enable preemption on this processor 98 #endif 91 bool pending_preemption; 92 93 char * last_enable; 99 94 }; 100 95 … … 103 98 void ^?{}(processor * this); 104 99 100 #endif //KERNEL_H 101 105 102 // Local Variables: // 106 // mode: c//107 // tab-width: 4//103 // mode: CFA // 104 // tab-width: 6 // 108 105 // End: //
Note:
See TracChangeset
for help on using the changeset viewer.