Ignore:
Timestamp:
Jul 20, 2020, 3:30:25 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
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
Message:

Moved processor registration to constructor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/ready_queue.cfa

    r3f1d9b5 r28d73c1  
    186186//=======================================================================
    187187void ?{}(__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;
    195190}
    196191
    197192void ^?{}(__ready_queue_t & this) with (this) {
    198         verify( 4  == lanes.count );
     193        verify( 0  == lanes.count );
    199194        verify( !query( snzi ) );
    200 
    201         ^(snzi){};
    202 
    203         for( i; 4 ) {
    204                 ^(lanes.data[i]){};
    205         }
    206195        free(lanes.data);
    207196}
     
    495484}
    496485
     486#warning remove when alloc is fixed
     487forall( dtype T | sized(T) )
     488static 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
    497501// Grow the ready queue
    498502void ready_queue_grow  (struct cluster * cltr) {
     
    513517
    514518                // Allocate new array (uses realloc and memcpies the data)
    515                 lanes.data = alloc(lanes.data, ncount);
     519                lanes.data = correct_alloc(lanes.data, ncount);
    516520
    517521                // Fix the moved data
     
    558562                size_t ocount = lanes.count;
    559563                // 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");
    561565
    562566                // reduce the actual count so push doesn't use the old queues
     
    600604
    601605                // 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);
    603607
    604608                // Fix the moved data
Note: See TracChangeset for help on using the changeset viewer.