Changeset 28d73c1 for libcfa/src/concurrency/ready_queue.cfa
- Timestamp:
- Jul 20, 2020, 3:30:25 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 124c1b7
- Parents:
- 3f1d9b5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/ready_queue.cfa
r3f1d9b5 r28d73c1 186 186 //======================================================================= 187 187 void ?{}(__ready_queue_t & this) with (this) { 188 189 lanes.data = alloc(4); 190 for( i; 4 ) { 191 (lanes.data[i]){}; 192 } 193 lanes.count = 4; 194 snzi{ log2( lanes.count / 8 ) }; 188 lanes.data = 0p; 189 lanes.count = 0; 195 190 } 196 191 197 192 void ^?{}(__ready_queue_t & this) with (this) { 198 verify( 4== lanes.count );193 verify( 0 == lanes.count ); 199 194 verify( !query( snzi ) ); 200 201 ^(snzi){};202 203 for( i; 4 ) {204 ^(lanes.data[i]){};205 }206 195 free(lanes.data); 207 196 } … … 495 484 } 496 485 486 #warning remove when alloc is fixed 487 forall( dtype T | sized(T) ) 488 static inline T * correct_alloc( T ptr[], size_t dim ) { 489 if( dim == 0 ) { 490 free(ptr); 491 return 0p; 492 } 493 T * temp = alloc( dim ); 494 if(ptr) { 495 memcpy( temp, ptr, dim * sizeof(T)); 496 free(ptr); 497 } 498 return temp; 499 } 500 497 501 // Grow the ready queue 498 502 void ready_queue_grow (struct cluster * cltr) { … … 513 517 514 518 // Allocate new array (uses realloc and memcpies the data) 515 lanes.data = alloc(lanes.data, ncount);519 lanes.data = correct_alloc(lanes.data, ncount); 516 520 517 521 // Fix the moved data … … 558 562 size_t ocount = lanes.count; 559 563 // Check that we have some space left 560 if(ocount < 8) abort("Program attempted to destroy more Ready Queues than were created");564 if(ocount < 4) abort("Program attempted to destroy more Ready Queues than were created"); 561 565 562 566 // reduce the actual count so push doesn't use the old queues … … 600 604 601 605 // Allocate new array (uses realloc and memcpies the data) 602 lanes.data = alloc(lanes.data, lanes.count);606 lanes.data = correct_alloc(lanes.data, lanes.count); 603 607 604 608 // Fix the moved data
Note: See TracChangeset
for help on using the changeset viewer.