Ignore:
Timestamp:
Jul 24, 2020, 1:11:39 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:
39fc03e
Parents:
f4ec4a90
Message:

Changed ready_queue_(grow/shrink) to take a target instead of going incrementing

File:
1 edited

Legend:

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

    rf4ec4a90 r320ec6fc  
    242242        #endif
    243243
    244         __atomic_fetch_add( &cltr->nprocessors, 1u, __ATOMIC_SEQ_CST );
     244        int target = __atomic_add_fetch( &cltr->nprocessors, 1u, __ATOMIC_SEQ_CST );
    245245
    246246        id = doregister((__processor_id_t*)&this);
     
    250250
    251251                // Adjust the ready queue size
    252                 ready_queue_grow( cltr );
     252                ready_queue_grow( cltr, target );
    253253
    254254        // Unlock the RWlock
     
    260260// Not a ctor, it just preps the destruction but should not destroy members
    261261void deinit(processor & this) {
     262
     263        int target = __atomic_sub_fetch( &this.cltr->nprocessors, 1u, __ATOMIC_SEQ_CST );
     264
    262265        // Lock the RWlock so no-one pushes/pops while we are changing the queue
    263266        uint_fast32_t last_size = ready_mutate_lock();
    264267
    265268                // Adjust the ready queue size
    266                 ready_queue_shrink( this.cltr );
     269                ready_queue_shrink( this.cltr, target );
    267270
    268271                // Make sure we aren't on the idle queue
     
    305308
    306309        deinit( this );
    307 
    308         __atomic_fetch_sub( &cltr->nprocessors, 1u, __ATOMIC_SEQ_CST );
    309310}
    310311
     
    936937
    937938                /* paranoid */ verify( this.do_terminate == true );
    938                 __atomic_fetch_sub( &cltr->nprocessors, 1u, __ATOMIC_SEQ_CST );
    939939                __cfaabi_dbg_print_safe("Kernel : destroyed main processor context %p\n", &runner);
    940940        }
Note: See TracChangeset for help on using the changeset viewer.