Changeset 9e45e46 for src/libcfa
- Timestamp:
- Feb 9, 2017, 5:31:23 PM (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:
- a073d46
- Parents:
- 8d4f7fe
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/kernel
r8d4f7fe r9e45e46 68 68 void unlock( simple_lock * ); 69 69 70 struct pthread_spinlock_guard {71 pthread_spinlock_t * lock;72 };73 74 static inline void ?{}( pthread_spinlock_guard * this, pthread_spinlock_t * lock ) {75 this->lock = lock;76 pthread_spin_lock( this->lock );77 }78 79 static inline void ^?{}( pthread_spinlock_guard * this ) {80 pthread_spin_unlock( this->lock );81 }82 83 // //Simple spinlock implementation from84 // //http://stackoverflow.com/questions/1383363/is-my-spin-lock-implementation-correct-and-optimal85 // //Not optimal but correct86 // #define VOL87 88 // struct simple_spinlock {89 // VOL int lock;90 // };91 92 // extern VOL int __sync_lock_test_and_set( VOL int *, VOL int);93 // extern void __sync_synchronize();94 95 // static inline void lock( simple_spinlock * this ) {96 // while (__sync_lock_test_and_set(&this->lock, 1)) {97 // // Do nothing. This GCC builtin instruction98 // // ensures memory barrier.99 // }100 // }101 102 // static inline void unlock( simple_spinlock * this ) {103 // __sync_synchronize(); // Memory barrier.104 // this->lock = 0;105 // }106 107 70 #endif //KERNEL_H 108 71
Note: See TracChangeset
for help on using the changeset viewer.