- File:
-
- 1 edited
-
libcfa/src/concurrency/kernel/cluster.cfa (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/cluster.cfa
r2af1943 r5024df4 229 229 for( idx ; lanes_count ) { 230 230 __intrusive_lane_t & sl = readyQ.data[idx]; 231 assert(!readyQ.data[idx].l .lock);231 assert(!readyQ.data[idx].lock); 232 232 233 233 if(is_empty(sl)) { 234 assert( sl. l.anchor.next == 0p );235 assert( sl. l.anchor.ts == MAX );236 assert( mock_head(sl) == sl. l.prev );234 assert( sl.anchor.next == 0p ); 235 assert( sl.anchor.ts == MAX ); 236 assert( mock_head(sl) == sl.prev ); 237 237 } else { 238 assert( sl. l.anchor.next != 0p );239 assert( sl. l.anchor.ts != MAX );240 assert( mock_head(sl) != sl. l.prev );238 assert( sl.anchor.next != 0p ); 239 assert( sl.anchor.ts != MAX ); 240 assert( mock_head(sl) != sl.prev ); 241 241 } 242 242 } … … 249 249 static inline void fix(__intrusive_lane_t & ll) { 250 250 if(is_empty(ll)) { 251 verify(ll. l.anchor.next == 0p);252 ll. l.prev = mock_head(ll);251 verify(ll.anchor.next == 0p); 252 ll.prev = mock_head(ll); 253 253 } 254 254 } … … 299 299 tscs = alloc(count, tscs`realloc); 300 300 for(i; count) { 301 tscs[i].t .tv = rdtscl();302 tscs[i]. t.ma = 0;301 tscs[i].tv = rdtscl(); 302 tscs[i].ma = 0; 303 303 } 304 304 } … … 400 400 for( idx; ncount ~ ocount) { 401 401 // Lock is not strictly needed but makes checking invariants much easier 402 __attribute__((unused)) bool locked = __atomic_try_acquire(&readyQ.data[idx].l .lock);402 __attribute__((unused)) bool locked = __atomic_try_acquire(&readyQ.data[idx].lock); 403 403 verify(locked); 404 404 … … 418 418 419 419 // Unlock the lane 420 __atomic_unlock(&readyQ.data[idx].l .lock);420 __atomic_unlock(&readyQ.data[idx].lock); 421 421 422 422 // TODO print the queue statistics here … … 467 467 } 468 468 469 #define nested_offsetof(type, field) ((off_t)(&(((type*)0)-> field)))470 471 469 // Ctor 472 470 void ?{}( __intrusive_lane_t & this ) { 473 this.l .lock = false;474 this. l.prev = mock_head(this);475 this. l.anchor.next = 0p;476 this. l.anchor.ts = MAX;471 this.lock = false; 472 this.prev = mock_head(this); 473 this.anchor.next = 0p; 474 this.anchor.ts = MAX; 477 475 #if !defined(__CFA_NO_STATISTICS__) 478 this. l.cnt = 0;476 this.cnt = 0; 479 477 #endif 480 478 481 479 // We add a boat-load of assertions here because the anchor code is very fragile 482 /* paranoid */ _Static_assert( offsetof( thread$, link ) == nested_offsetof(__intrusive_lane_t, l.anchor) );483 /* paranoid */ verify( offsetof( thread$, link ) == nested_offsetof(__intrusive_lane_t, l.anchor) );484 /* paranoid */ verify( ((uintptr_t)( mock_head(this) ) + offsetof( thread$, link )) == (uintptr_t)(&this. l.anchor) );485 /* paranoid */ verify( &mock_head(this)->link.next == &this. l.anchor.next );486 /* paranoid */ verify( &mock_head(this)->link.ts == &this. l.anchor.ts );480 /* paranoid */ _Static_assert( offsetof( thread$, link ) == offsetof(__intrusive_lane_t, anchor) ); 481 /* paranoid */ verify( offsetof( thread$, link ) == offsetof(__intrusive_lane_t, anchor) ); 482 /* paranoid */ verify( ((uintptr_t)( mock_head(this) ) + offsetof( thread$, link )) == (uintptr_t)(&this.anchor) ); 483 /* paranoid */ verify( &mock_head(this)->link.next == &this.anchor.next ); 484 /* paranoid */ verify( &mock_head(this)->link.ts == &this.anchor.ts ); 487 485 /* paranoid */ verify( mock_head(this)->link.next == 0p ); 488 486 /* paranoid */ verify( mock_head(this)->link.ts == MAX ); 489 /* paranoid */ verify( mock_head(this) == this.l.prev ); 490 /* paranoid */ verify( __alignof__(__intrusive_lane_t) == 64 ); 491 /* paranoid */ verify( __alignof__(this) == 64 ); 492 /* paranoid */ verifyf( ((intptr_t)(&this) % 64) == 0, "Expected address to be aligned %p %% 64 == %zd", &this, ((intptr_t)(&this) % 64) ); 493 } 494 495 #undef nested_offsetof 487 /* paranoid */ verify( mock_head(this) == this.prev ); 488 /* paranoid */ verify( __alignof__(__intrusive_lane_t) == 128 ); 489 /* paranoid */ verify( __alignof__(this) == 128 ); 490 /* paranoid */ verifyf( ((intptr_t)(&this) % 128) == 0, "Expected address to be aligned %p %% 128 == %zd", &this, ((intptr_t)(&this) % 128) ); 491 } 496 492 497 493 // Dtor is trivial 498 494 void ^?{}( __intrusive_lane_t & this ) { 499 495 // Make sure the list is empty 500 /* paranoid */ verify( this. l.anchor.next == 0p );501 /* paranoid */ verify( this. l.anchor.ts == MAX );502 /* paranoid */ verify( mock_head(this) == this.l.prev );496 /* paranoid */ verify( this.anchor.next == 0p ); 497 /* paranoid */ verify( this.anchor.ts == MAX ); 498 /* paranoid */ verify( mock_head(this) == this.prev ); 503 499 } 504 500
Note:
See TracChangeset
for help on using the changeset viewer.