Changeset 62502cc4


Ignore:
Timestamp:
Aug 13, 2020, 1:19:20 PM (15 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast, new-ast-unique-expr
Children:
badd22f
Parents:
0240cd6
Message:

Fixed deadlock where threads could acquire the central scheduler lock for writing while preemption was enabled, leading to any attempt at running any thread to deadlock.
Also added runtime checks to catch new code which could forget to disable interrupts

Location:
libcfa/src/concurrency
Files:
2 edited

Legend:

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

    r0240cd6 r62502cc4  
    516516        ( this.terminated ){ 0 };
    517517        ( this.runner ){};
    518         init( this, name, _cltr );
     518
     519        disable_interrupts();
     520                init( this, name, _cltr );
     521        enable_interrupts( __cfaabi_dbg_ctx );
    519522
    520523        __cfadbg_print_safe(runtime_core, "Kernel : Starting core %p\n", &this);
     
    540543        free( this.stack );
    541544
    542         deinit( this );
     545        disable_interrupts();
     546                deinit( this );
     547        enable_interrupts( __cfaabi_dbg_ctx );
    543548}
    544549
  • libcfa/src/concurrency/ready_queue.cfa

    r0240cd6 r62502cc4  
    150150//  queues or removing them.
    151151uint_fast32_t ready_mutate_lock( void ) with(*__scheduler_lock) {
     152        /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
     153
    152154        // Step 1 : lock global lock
    153155        // It is needed to avoid processors that register mid Critical-Section
     
    164166        }
    165167
     168        /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    166169        return s;
    167170}
    168171
    169172void ready_mutate_unlock( uint_fast32_t last_s ) with(*__scheduler_lock) {
     173        /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
     174
    170175        // Step 1 : release local locks
    171176        // This must be done while the global lock is held to avoid
     
    182187        /*paranoid*/ assert(true == lock);
    183188        __atomic_store_n(&lock, (bool)false, __ATOMIC_RELEASE);
     189
     190        /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    184191}
    185192
Note: See TracChangeset for help on using the changeset viewer.