Ignore:
Timestamp:
May 1, 2020, 12:37:30 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:
d45ed83
Parents:
9987d79
Message:

Fix error in benchmark where the wrong fd was used.
Changed behcnmark to use seperate cluster for I/O.
Changed some debug prints to use new versions with groups.
Fixed halting race condition leading to deadlock.

File:
1 edited

Legend:

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

    r9987d79 r4069faad  
    1515
    1616#define __cforall_thread__
     17// #define __CFA_DEBUG_PRINT_RUNTIME_CORE__
    1718
    1819//C Includes
     
    4041#include "invoke.h"
    4142
     43
    4244//-----------------------------------------------------------------------------
    4345// Some assembly required
     
    230232        idle{};
    231233
    232         __cfaabi_dbg_print_safe("Kernel : Starting core %p\n", &this);
     234        __cfadbg_print_safe(runtime_core, "Kernel : Starting core %p\n", &this);
    233235
    234236        this.stack = __create_pthread( &this.kernel_thread, __invoke_processor, (void *)&this );
    235237
    236         __cfaabi_dbg_print_safe("Kernel : core %p started\n", &this);
     238        __cfadbg_print_safe(runtime_core, "Kernel : core %p created\n", &this);
    237239}
    238240
    239241void ^?{}(processor & this) with( this ){
    240242        if( ! __atomic_load_n(&do_terminate, __ATOMIC_ACQUIRE) ) {
    241                 __cfaabi_dbg_print_safe("Kernel : core %p signaling termination\n", &this);
     243                __cfadbg_print_safe(runtime_core, "Kernel : core %p signaling termination\n", &this);
    242244
    243245                __atomic_store_n(&do_terminate, true, __ATOMIC_RELAXED);
     
    289291        verify(this);
    290292
    291         __cfaabi_dbg_print_safe("Kernel : core %p starting\n", this);
     293        __cfadbg_print_safe(runtime_core, "Kernel : core %p starting\n", this);
    292294
    293295        doregister(this->cltr, this);
     
    297299                preemption_scope scope = { this };
    298300
    299                 __cfaabi_dbg_print_safe("Kernel : core %p started\n", this);
     301                __cfadbg_print_safe(runtime_core, "Kernel : core %p started\n", this);
    300302
    301303                $thread * readyThread = 0p;
     
    323325                }
    324326
    325                 __cfaabi_dbg_print_safe("Kernel : core %p stopping\n", this);
     327                __cfadbg_print_safe(runtime_core, "Kernel : core %p stopping\n", this);
    326328        }
    327329
     
    330332        V( this->terminated );
    331333
    332         __cfaabi_dbg_print_safe("Kernel : core %p terminated\n", this);
     334        __cfadbg_print_safe(runtime_core, "Kernel : core %p terminated\n", this);
    333335
    334336        // HACK : the coroutine context switch expects this_thread to be set
     
    475477
    476478        //We now have a proper context from which to schedule threads
    477         __cfaabi_dbg_print_safe("Kernel : core %p created (%p, %p)\n", proc, &proc->runner, &ctx);
     479        __cfadbg_print_safe(runtime_core, "Kernel : core %p created (%p, %p)\n", proc, &proc->runner, &ctx);
    478480
    479481        // SKULLDUGGERY: Since the coroutine doesn't have its own stack, we can't
     
    486488
    487489        // Main routine of the core returned, the core is now fully terminated
    488         __cfaabi_dbg_print_safe("Kernel : core %p main ended (%p)\n", proc, &proc->runner);
     490        __cfadbg_print_safe(runtime_core, "Kernel : core %p main ended (%p)\n", proc, &proc->runner);
    489491
    490492        return 0p;
     
    717719static void __kernel_startup(void) {
    718720        verify( ! kernelTLS.preemption_state.enabled );
    719         __cfaabi_dbg_print_safe("Kernel : Starting\n");
     721        __cfadbg_print_safe(runtime_core, "Kernel : Starting\n");
    720722
    721723        __page_size = sysconf( _SC_PAGESIZE );
     
    728730        (*mainCluster){"Main Cluster"};
    729731
    730         __cfaabi_dbg_print_safe("Kernel : Main cluster ready\n");
     732        __cfadbg_print_safe(runtime_core, "Kernel : Main cluster ready\n");
    731733
    732734        // Start by initializing the main thread
     
    738740        (*mainThread){ &info };
    739741
    740         __cfaabi_dbg_print_safe("Kernel : Main thread ready\n");
     742        __cfadbg_print_safe(runtime_core, "Kernel : Main thread ready\n");
    741743
    742744
     
    759761
    760762                runner{ &this };
    761                 __cfaabi_dbg_print_safe("Kernel : constructed main processor context %p\n", &runner);
     763                __cfadbg_print_safe(runtime_core, "Kernel : constructed main processor context %p\n", &runner);
    762764        }
    763765
     
    834836        ^(__cfa_dbg_global_clusters.lock){};
    835837
    836         __cfaabi_dbg_print_safe("Kernel : Shutdown complete\n");
     838        __cfadbg_print_safe(runtime_core, "Kernel : Shutdown complete\n");
    837839}
    838840
     
    859861
    860862        // We are ready to sleep
    861         __cfaabi_dbg_print_safe("Kernel : Processor %p ready to sleep\n", this);
     863        __cfadbg_print_safe(runtime_core, "Kernel : Processor %p ready to sleep\n", this);
    862864        wait( idle );
    863865
    864866        // We have woken up
    865         __cfaabi_dbg_print_safe("Kernel : Processor %p woke up and ready to run\n", this);
     867        __cfadbg_print_safe(runtime_core, "Kernel : Processor %p woke up and ready to run\n", this);
    866868
    867869        // Get ourself off the idle list
     
    879881static bool __wake_one(cluster * this, __attribute__((unused)) bool force) {
    880882        // if we don't want to force check if we know it's false
    881         if( !this->idles.head && !force ) return false;
     883        // if( !this->idles.head && !force ) return false;
    882884
    883885        // First, lock the cluster idle
     
    892894
    893895        // Wake them up
     896        __cfadbg_print_safe(runtime_core, "Kernel : waking Processor %p\n", this->idles.head);
    894897        post( this->idles.head->idle );
    895898
     
    901904// Unconditionnaly wake a thread
    902905static bool __wake_proc(processor * this) {
     906        __cfadbg_print_safe(runtime_core, "Kernel : waking Processor %p\n", this);
    903907        return post( this->idle );
    904908}
Note: See TracChangeset for help on using the changeset viewer.