Changeset a017ee7


Ignore:
Timestamp:
Apr 15, 2021, 11:45:44 AM (2 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master
Children:
a4b0aa4
Parents:
fc59b580
Message:

Ready-queue grow/shrink now reassigns the id of all processors.

Location:
libcfa/src/concurrency
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel/startup.cfa

    rfc59b580 ra017ee7  
    469469        this.name = name;
    470470        this.cltr = &_cltr;
     471        this.cltr_id = -1u;
    471472        do_terminate = false;
    472473        preemption_alarm = 0p;
     
    491492        // Register and Lock the RWlock so no-one pushes/pops while we are changing the queue
    492493        uint_fast32_t last_size = ready_mutate_register((__processor_id_t*)&this);
    493                 int target = this.cltr->procs.total += 1u;
     494                this.cltr->procs.total += 1u;
    494495                insert_last(this.cltr->procs.actives, this);
    495496
    496497                // Adjust the ready queue size
    497                 this.cltr_id = ready_queue_grow( cltr, target );
     498                ready_queue_grow( cltr );
    498499
    499500        // Unlock the RWlock
     
    507508        // Lock the RWlock so no-one pushes/pops while we are changing the queue
    508509        uint_fast32_t last_size = ready_mutate_lock();
    509                 int target = this.cltr->procs.total -= 1u;
     510                this.cltr->procs.total -= 1u;
    510511                remove(this);
    511512
    512513                // Adjust the ready queue size
    513                 ready_queue_shrink( this.cltr, target );
     514                ready_queue_shrink( this.cltr );
    514515
    515516        // Unlock the RWlock and unregister: we don't need the read_lock any more
     
    586587
    587588                // Adjust the ready queue size
    588                 ready_queue_grow( &this, 0 );
     589                ready_queue_grow( &this );
    589590
    590591        // Unlock the RWlock
     
    601602
    602603                // Adjust the ready queue size
    603                 ready_queue_shrink( &this, 0 );
     604                ready_queue_shrink( &this );
    604605
    605606        // Unlock the RWlock
  • libcfa/src/concurrency/kernel_private.hfa

    rfc59b580 ra017ee7  
    312312//-----------------------------------------------------------------------
    313313// Increase the width of the ready queue (number of lanes) by 4
    314 unsigned ready_queue_grow  (struct cluster * cltr, int target);
     314void ready_queue_grow  (struct cluster * cltr);
    315315
    316316//-----------------------------------------------------------------------
    317317// Decrease the width of the ready queue (number of lanes) by 4
    318 void ready_queue_shrink(struct cluster * cltr, int target);
     318void ready_queue_shrink(struct cluster * cltr);
    319319
    320320
  • libcfa/src/concurrency/ready_queue.cfa

    rfc59b580 ra017ee7  
    254254        __attribute__((unused)) int preferred;
    255255        #if defined(BIAS)
     256                /* paranoid */ verify(external || kernelTLS().this_processor->cltr_id < lanes.count );
    256257                preferred =
    257258                        //*
     
    344345        int preferred;
    345346        #if defined(BIAS)
    346                 // Don't bother trying locally too much
     347                /* paranoid */ verify(kernelTLS().this_processor->cltr_id < lanes.count );
    347348                preferred = kernelTLS().this_processor->cltr_id;
    348349        #endif
     
    541542}
    542543
     544static void assign_list(unsigned & value, const int inc, dlist(processor, processor) & list, unsigned count) {
     545        processor * it = &list`first;
     546        for(unsigned i = 0; i < count; i++) {
     547                /* paranoid */ verifyf( it, "Unexpected null iterator, at index %u of %u\n", i, count);
     548                it->cltr_id = value;
     549                value += inc;
     550                it = &(*it)`next;
     551        }
     552}
     553
     554static void reassign_cltr_id(struct cluster * cltr, const int inc) {
     555        unsigned preferred = 0;
     556        assign_list(preferred, inc, cltr->procs.actives, cltr->procs.total - cltr->procs.idle);
     557        assign_list(preferred, inc, cltr->procs.idles  , cltr->procs.idle );
     558}
     559
    543560// Grow the ready queue
    544 unsigned ready_queue_grow(struct cluster * cltr, int target) {
    545         unsigned preferred;
     561void ready_queue_grow(struct cluster * cltr) {
    546562        size_t ncount;
     563        int target = cltr->procs.total;
    547564
    548565        /* paranoid */ verify( ready_mutate_islocked() );
     
    562579                if(target >= 2) {
    563580                        ncount = target * 4;
    564                         preferred = ncount - 4;
    565581                } else {
    566582                        ncount = 1;
    567                         preferred = 0;
    568583                }
    569584
     
    595610        }
    596611
     612        reassign_cltr_id(cltr, 4);
     613
    597614        // Make sure that everything is consistent
    598615        /* paranoid */ check( cltr->ready_queue );
     
    601618
    602619        /* paranoid */ verify( ready_mutate_islocked() );
    603         return preferred;
    604620}
    605621
    606622// Shrink the ready queue
    607 void ready_queue_shrink(struct cluster * cltr, int target) {
     623void ready_queue_shrink(struct cluster * cltr) {
    608624        /* paranoid */ verify( ready_mutate_islocked() );
    609625        __cfadbg_print_safe(ready_queue, "Kernel : Shrinking ready queue\n");
     
    611627        // Make sure that everything is consistent
    612628        /* paranoid */ check( cltr->ready_queue );
     629
     630        int target = cltr->procs.total;
    613631
    614632        with( cltr->ready_queue ) {
     
    679697        }
    680698
     699        reassign_cltr_id(cltr, 4);
     700
    681701        // Make sure that everything is consistent
    682702        /* paranoid */ check( cltr->ready_queue );
Note: See TracChangeset for help on using the changeset viewer.