Changeset 7d9598d for libcfa/src
- Timestamp:
- Dec 14, 2022, 12:23:26 PM (17 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 2dcd80a
- Parents:
- 63be3387
- Location:
- libcfa/src/concurrency
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/locks.cfa
r63be3387 r7d9598d 414 414 #ifdef __CFA_DEBUG__ 415 415 if ( lock_used == 0p ) lock_used = &l; 416 else { assert(lock_used == &l); }416 else assert(lock_used == &l); 417 417 #endif 418 418 info_thread( L ) i = { active_thread(), info, &l }; -
libcfa/src/concurrency/locks.hfa
r63be3387 r7d9598d 162 162 163 163 // to use for FUTEX_WAKE and FUTEX_WAIT (other futex calls will need more params) 164 static in t futex(int *uaddr, int futex_op, int val) {164 static inline int futex(int *uaddr, int futex_op, int val) { 165 165 return syscall(SYS_futex, uaddr, futex_op, val, NULL, NULL, 0); 166 166 } … … 181 181 182 182 183 // linear backoff 184 for( int spin = 4; spin < 1024; spin += spin) { 185 state = 0; 186 // if unlocked, lock and return 187 if (internal_try_lock(this, state)) return; 188 if (2 == state) break; 189 for (int i = 0; i < spin; i++) Pause(); 190 } 191 // if (internal_try_lock(this, state)) return; 183 // // linear backoff omitted for now 184 // for( int spin = 4; spin < 1024; spin += spin) { 185 // state = 0; 186 // // if unlocked, lock and return 187 // if (internal_try_lock(this, state)) return; 188 // if (2 == state) break; 189 // for (int i = 0; i < spin; i++) Pause(); 190 // } 191 192 // no contention try to acquire 193 if (internal_try_lock(this, state)) return; 192 194 193 195 // if not in contended state, set to be in contended state … … 290 292 291 293 static inline bool block(linear_backoff_then_block_lock & this) with(this) { 292 lock( spinlock __cfaabi_dbg_ctx2 ); 294 lock( spinlock __cfaabi_dbg_ctx2 ); // TODO change to lockfree queue (MPSC) 293 295 if (lock_value != 2) { 294 296 unlock( spinlock );
Note: See TracChangeset
for help on using the changeset viewer.