Ignore:
Timestamp:
Dec 13, 2019, 1:45:49 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:
75ca7f4
Parents:
983edfd
Message:

new ready queue seems to work but halting does not, had to be disabled

File:
1 edited

Legend:

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

    r983edfd rc84b4be  
    240240        this.lock = false;
    241241        this.last_id = -1u;
     242        this.count = 0u;
    242243
    243244        this.before.link.prev = 0p;
     
    283284        /* paranoid */ verify(tail(this)->link.next == 0p );
    284285        /* paranoid */ verify(tail(this)->link.prev == head(this) );
     286        /* paranoid */ verify(this.count == 0u );
    285287}
    286288
     
    292294        verify(node->link.next == 0p);
    293295        verify(node->link.prev == 0p);
     296
     297        this.count++;
    294298
    295299        if(this.before.link.ts == 0l) {
     
    345349        }
    346350
     351        this.count--;
    347352        /* paranoid */ verify(node);
    348353
     
    693698void ready_queue_grow  (struct cluster * cltr) {
    694699        uint_fast32_t last_size = ready_mutate_lock( *cltr );
     700        __cfaabi_dbg_print_safe("Kernel : Growing ready queue\n");
    695701        check( cltr->ready_queue );
    696702
     
    723729        // Make sure that everything is consistent
    724730        check( cltr->ready_queue );
     731        __cfaabi_dbg_print_safe("Kernel : Growing ready queue done\n");
    725732        ready_mutate_unlock( *cltr, last_size );
    726733}
     
    728735void ready_queue_shrink(struct cluster * cltr) {
    729736        uint_fast32_t last_size = ready_mutate_lock( *cltr );
     737        __cfaabi_dbg_print_safe("Kernel : Shrinking ready queue\n");
    730738        with( cltr->ready_queue ) {
     739                #if defined(__CFA_WITH_VERIFY__)
     740                        size_t nthreads = 0;
     741                        for( idx; (size_t)list.count ) {
     742                                nthreads += list.data[idx].count;
     743                        }
     744                #endif
     745
    731746                size_t ocount = list.count;
    732747                // Check that we have some space left
     
    737752                // redistribute old data
    738753                verify(ocount > list.count);
     754                __attribute__((unused)) size_t displaced = 0;
    739755                for( idx; (size_t)list.count ~ ocount) {
    740756                        // This is not strictly needed but makes checking invariants much easier
     
    747763                                verify(thrd);
    748764                                push(cltr, thrd);
     765                                displaced++;
    749766                        }
    750767
     
    755772                        ^(list.data[idx]){};
    756773                }
     774
     775                __cfaabi_dbg_print_safe("Kernel : Shrinking ready queue displaced %zu threads\n", displaced);
    757776
    758777                // clear the now unused masks
     
    776795
    777796                        empty.count = 0;
    778                         for( i ; lword ) {
     797                        for( i ; 0 ~= lword ) {
    779798                                empty.count += __builtin_popcountl(empty.mask[i]);
    780799                        }
     
    788807                        fix(list.data[idx]);
    789808                }
     809
     810                #if defined(__CFA_WITH_VERIFY__)
     811                        for( idx; (size_t)list.count ) {
     812                                nthreads -= list.data[idx].count;
     813                        }
     814                        assertf(nthreads == 0, "Shrinking changed number of threads");
     815                #endif
    790816        }
    791817
    792818        // Make sure that everything is consistent
    793819        check( cltr->ready_queue );
     820        __cfaabi_dbg_print_safe("Kernel : Shrinking ready queue done\n");
    794821        ready_mutate_unlock( *cltr, last_size );
    795822}
Note: See TracChangeset for help on using the changeset viewer.