Ignore:
Timestamp:
Apr 15, 2021, 12:05:16 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
8590328
Parents:
2f5ea69 (diff), a4b0aa4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

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

    r2f5ea69 r8cfa4ef  
    469469        this.name = name;
    470470        this.cltr = &_cltr;
     471        this.cltr_id = -1u;
    471472        do_terminate = false;
    472473        preemption_alarm = 0p;
     
    489490        #endif
    490491
    491         lock( this.cltr->idles );
    492                 int target = this.cltr->idles.total += 1u;
    493         unlock( this.cltr->idles );
    494 
    495         id = doregister((__processor_id_t*)&this);
    496 
     492        // Register and Lock the RWlock so no-one pushes/pops while we are changing the queue
     493        uint_fast32_t last_size = ready_mutate_register((__processor_id_t*)&this);
     494                this.cltr->procs.total += 1u;
     495                insert_last(this.cltr->procs.actives, this);
     496
     497                // Adjust the ready queue size
     498                ready_queue_grow( cltr );
     499
     500        // Unlock the RWlock
     501        ready_mutate_unlock( last_size );
     502
     503        __cfadbg_print_safe(runtime_core, "Kernel : core %p created\n", &this);
     504}
     505
     506// Not a ctor, it just preps the destruction but should not destroy members
     507static void deinit(processor & this) {
    497508        // Lock the RWlock so no-one pushes/pops while we are changing the queue
    498509        uint_fast32_t last_size = ready_mutate_lock();
     510                this.cltr->procs.total -= 1u;
     511                remove(this);
    499512
    500513                // Adjust the ready queue size
    501                 this.cltr_id = ready_queue_grow( cltr, target );
    502 
    503         // Unlock the RWlock
    504         ready_mutate_unlock( last_size );
    505 
    506         __cfadbg_print_safe(runtime_core, "Kernel : core %p created\n", &this);
    507 }
    508 
    509 // Not a ctor, it just preps the destruction but should not destroy members
    510 static void deinit(processor & this) {
    511         lock( this.cltr->idles );
    512                 int target = this.cltr->idles.total -= 1u;
    513         unlock( this.cltr->idles );
    514 
    515         // Lock the RWlock so no-one pushes/pops while we are changing the queue
    516         uint_fast32_t last_size = ready_mutate_lock();
    517 
    518                 // Adjust the ready queue size
    519                 ready_queue_shrink( this.cltr, target );
    520 
    521         // Unlock the RWlock
    522         ready_mutate_unlock( last_size );
    523 
    524         // Finally we don't need the read_lock any more
    525         unregister((__processor_id_t*)&this);
     514                ready_queue_shrink( this.cltr );
     515
     516        // Unlock the RWlock and unregister: we don't need the read_lock any more
     517        ready_mutate_unregister((__processor_id_t*)&this, last_size );
    526518
    527519        close(this.idle);
     
    566558//-----------------------------------------------------------------------------
    567559// Cluster
    568 static void ?{}(__cluster_idles & this) {
     560static void ?{}(__cluster_proc_list & this) {
    569561        this.lock  = 0;
    570562        this.idle  = 0;
    571563        this.total = 0;
    572         (this.list){};
    573564}
    574565
     
    596587
    597588                // Adjust the ready queue size
    598                 ready_queue_grow( &this, 0 );
     589                ready_queue_grow( &this );
    599590
    600591        // Unlock the RWlock
     
    611602
    612603                // Adjust the ready queue size
    613                 ready_queue_shrink( &this, 0 );
     604                ready_queue_shrink( &this );
    614605
    615606        // Unlock the RWlock
Note: See TracChangeset for help on using the changeset viewer.