Changes in src/libcfa/concurrency/kernel [8def349:bd98b58]
- File:
-
- 1 edited
-
src/libcfa/concurrency/kernel (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/kernel
r8def349 rbd98b58 22 22 #include "invoke.h" 23 23 24 extern "C" {25 #include <pthread.h>26 }27 28 24 //----------------------------------------------------------------------------- 29 25 // Cluster 30 26 struct cluster { 31 27 simple_thread_list ready_queue; 32 pthread_spinlock_t lock;33 28 }; 34 29 … … 43 38 coroutine * current_coroutine; 44 39 thread_h * current_thread; 45 pthread_t kernel_thread; 46 simple_lock lock; 47 volatile bool terminated; 40 bool terminated; 48 41 }; 49 42 50 void ?{}(processor * this);51 43 void ?{}(processor * this, cluster * cltr); 52 44 void ^?{}(processor * this); … … 62 54 void unlock( simple_lock * ); 63 55 64 struct pthread_spinlock_guard {65 pthread_spinlock_t * lock;66 };67 68 static inline void ?{}( pthread_spinlock_guard * this, pthread_spinlock_t * lock ) {69 this->lock = lock;70 pthread_spin_lock( this->lock );71 }72 73 static inline void ^?{}( pthread_spinlock_guard * this ) {74 pthread_spin_unlock( this->lock );75 }76 77 // //Simple spinlock implementation from78 // //http://stackoverflow.com/questions/1383363/is-my-spin-lock-implementation-correct-and-optimal79 // //Not optimal but correct80 // #define VOL81 82 // struct simple_spinlock {83 // VOL int lock;84 // };85 86 // extern VOL int __sync_lock_test_and_set( VOL int *, VOL int);87 // extern void __sync_synchronize();88 89 // static inline void lock( simple_spinlock * this ) {90 // while (__sync_lock_test_and_set(&this->lock, 1)) {91 // // Do nothing. This GCC builtin instruction92 // // ensures memory barrier.93 // }94 // }95 96 // static inline void unlock( simple_spinlock * this ) {97 // __sync_synchronize(); // Memory barrier.98 // this->lock = 0;99 // }100 101 56 #endif //KERNEL_H 102 57
Note:
See TracChangeset
for help on using the changeset viewer.