Ignore:
Timestamp:
Dec 1, 2017, 11:58:32 AM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
3ca540f, 86ad276
Parents:
d16d159 (diff), 3d560060 (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:/u/cforall/software/cfa/cfa-cc

File:
1 edited

Legend:

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

    rd16d159 r5da9d6a  
    1414//
    1515
    16 #include "libhdr.h"
    17 
    1816//C Includes
    1917#include <stddef.h>
     
    150148
    151149        this.runner = &runner;
    152         LIB_DEBUG_PRINT_SAFE("Kernel : constructing main processor context %p\n", &runner);
     150        __cfaabi_dbg_print_safe("Kernel : constructing main processor context %p\n", &runner);
    153151        runner{ &this };
    154152}
     
    156154void ^?{}(processor & this) {
    157155        if( ! this.do_terminate ) {
    158                 LIB_DEBUG_PRINT_SAFE("Kernel : core %p signaling termination\n", &this);
     156                __cfaabi_dbg_print_safe("Kernel : core %p signaling termination\n", &this);
    159157                this.do_terminate = true;
    160158                P( this.terminated );
     
    181179        processor * this = runner.proc;
    182180
    183         LIB_DEBUG_PRINT_SAFE("Kernel : core %p starting\n", this);
     181        __cfaabi_dbg_print_safe("Kernel : core %p starting\n", this);
    184182
    185183        {
     
    187185                preemption_scope scope = { this };
    188186
    189                 LIB_DEBUG_PRINT_SAFE("Kernel : core %p started\n", this);
     187                __cfaabi_dbg_print_safe("Kernel : core %p started\n", this);
    190188
    191189                thread_desc * readyThread = NULL;
     
    213211                }
    214212
    215                 LIB_DEBUG_PRINT_SAFE("Kernel : core %p stopping\n", this);
     213                __cfaabi_dbg_print_safe("Kernel : core %p stopping\n", this);
    216214        }
    217215
    218216        V( this->terminated );
    219217
    220         LIB_DEBUG_PRINT_SAFE("Kernel : core %p terminated\n", this);
     218        __cfaabi_dbg_print_safe("Kernel : core %p terminated\n", this);
    221219}
    222220
     
    292290        processorCtx_t proc_cor_storage = { proc, &info };
    293291
    294         LIB_DEBUG_PRINT_SAFE("Coroutine : created stack %p\n", proc_cor_storage.__cor.stack.base);
     292        __cfaabi_dbg_print_safe("Coroutine : created stack %p\n", proc_cor_storage.__cor.stack.base);
    295293
    296294        //Set global state
     
    299297
    300298        //We now have a proper context from which to schedule threads
    301         LIB_DEBUG_PRINT_SAFE("Kernel : core %p created (%p, %p)\n", proc, proc->runner, &ctx);
     299        __cfaabi_dbg_print_safe("Kernel : core %p created (%p, %p)\n", proc, proc->runner, &ctx);
    302300
    303301        // SKULLDUGGERY: Since the coroutine doesn't have its own stack, we can't
     
    310308
    311309        // Main routine of the core returned, the core is now fully terminated
    312         LIB_DEBUG_PRINT_SAFE("Kernel : core %p main ended (%p)\n", proc, proc->runner);
     310        __cfaabi_dbg_print_safe("Kernel : core %p main ended (%p)\n", proc, proc->runner);
    313311
    314312        return NULL;
     
    316314
    317315void start(processor * this) {
    318         LIB_DEBUG_PRINT_SAFE("Kernel : Starting core %p\n", this);
     316        __cfaabi_dbg_print_safe("Kernel : Starting core %p\n", this);
    319317
    320318        pthread_create( &this->kernel_thread, NULL, CtxInvokeProcessor, (void*)this );
    321319
    322         LIB_DEBUG_PRINT_SAFE("Kernel : core %p started\n", this);
     320        __cfaabi_dbg_print_safe("Kernel : core %p started\n", this);
    323321}
    324322
     
    334332        verifyf( thrd->next == NULL, "Expected null got %p", thrd->next );
    335333
    336         lock(   this_processor->cltr->ready_queue_lock DEBUG_CTX2 );
     334        lock(   this_processor->cltr->ready_queue_lock __cfaabi_dbg_ctx2 );
    337335        append( this_processor->cltr->ready_queue, thrd );
    338336        unlock( this_processor->cltr->ready_queue_lock );
     
    343341thread_desc * nextThread(cluster * this) {
    344342        verify( disable_preempt_count > 0 );
    345         lock( this->ready_queue_lock DEBUG_CTX2 );
     343        lock( this->ready_queue_lock __cfaabi_dbg_ctx2 );
    346344        thread_desc * head = pop_head( this->ready_queue );
    347345        unlock( this->ready_queue_lock );
     
    355353        suspend();
    356354        verify( disable_preempt_count > 0 );
    357         enable_interrupts( DEBUG_CTX );
     355        enable_interrupts( __cfaabi_dbg_ctx );
    358356}
    359357
     
    367365        verify( disable_preempt_count > 0 );
    368366
    369         enable_interrupts( DEBUG_CTX );
     367        enable_interrupts( __cfaabi_dbg_ctx );
    370368}
    371369
     
    381379        verify( disable_preempt_count > 0 );
    382380
    383         enable_interrupts( DEBUG_CTX );
     381        enable_interrupts( __cfaabi_dbg_ctx );
    384382}
    385383
     
    395393        verify( disable_preempt_count > 0 );
    396394
    397         enable_interrupts( DEBUG_CTX );
     395        enable_interrupts( __cfaabi_dbg_ctx );
    398396}
    399397
     
    408406        verify( disable_preempt_count > 0 );
    409407
    410         enable_interrupts( DEBUG_CTX );
     408        enable_interrupts( __cfaabi_dbg_ctx );
    411409}
    412410
     
    423421        verify( disable_preempt_count > 0 );
    424422
    425         enable_interrupts( DEBUG_CTX );
     423        enable_interrupts( __cfaabi_dbg_ctx );
    426424}
    427425
     
    441439// Kernel boot procedures
    442440void kernel_startup(void) {
    443         LIB_DEBUG_PRINT_SAFE("Kernel : Starting\n");
     441        __cfaabi_dbg_print_safe("Kernel : Starting\n");
    444442
    445443        // Start by initializing the main thread
     
    450448        (*mainThread){ &info };
    451449
    452         LIB_DEBUG_PRINT_SAFE("Kernel : Main thread ready\n");
     450        __cfaabi_dbg_print_safe("Kernel : Main thread ready\n");
    453451
    454452        // Initialize the main cluster
     
    456454        (*mainCluster){};
    457455
    458         LIB_DEBUG_PRINT_SAFE("Kernel : main cluster ready\n");
     456        __cfaabi_dbg_print_safe("Kernel : main cluster ready\n");
    459457
    460458        // Initialize the main processor and the main processor ctx
     
    483481
    484482        // THE SYSTEM IS NOW COMPLETELY RUNNING
    485         LIB_DEBUG_PRINT_SAFE("Kernel : Started\n--------------------------------------------------\n\n");
    486 
    487         enable_interrupts( DEBUG_CTX );
     483        __cfaabi_dbg_print_safe("Kernel : Started\n--------------------------------------------------\n\n");
     484
     485        enable_interrupts( __cfaabi_dbg_ctx );
    488486}
    489487
    490488void kernel_shutdown(void) {
    491         LIB_DEBUG_PRINT_SAFE("\n--------------------------------------------------\nKernel : Shutting down\n");
     489        __cfaabi_dbg_print_safe("\n--------------------------------------------------\nKernel : Shutting down\n");
    492490
    493491        disable_interrupts();
     
    513511        ^(mainThread){};
    514512
    515         LIB_DEBUG_PRINT_SAFE("Kernel : Shutdown complete\n");
     513        __cfaabi_dbg_print_safe("Kernel : Shutdown complete\n");
    516514}
    517515
     
    523521        // abort cannot be recursively entered by the same or different processors because all signal handlers return when
    524522        // the globalAbort flag is true.
    525         lock( kernel_abort_lock DEBUG_CTX2 );
     523        lock( kernel_abort_lock __cfaabi_dbg_ctx2 );
    526524
    527525        // first task to abort ?
     
    548546
    549547        int len = snprintf( abort_text, abort_text_size, "Error occurred while executing task %.256s (%p)", thrd->self_cor.name, thrd );
    550         __lib_debug_write( abort_text, len );
     548        __cfaabi_dbg_bits_write( abort_text, len );
    551549
    552550        if ( thrd != this_coroutine ) {
    553551                len = snprintf( abort_text, abort_text_size, " in coroutine %.256s (%p).\n", this_coroutine->name, this_coroutine );
    554                 __lib_debug_write( abort_text, len );
     552                __cfaabi_dbg_bits_write( abort_text, len );
    555553        }
    556554        else {
    557                 __lib_debug_write( ".\n", 2 );
     555                __cfaabi_dbg_bits_write( ".\n", 2 );
    558556        }
    559557}
    560558
    561559extern "C" {
    562         void __lib_debug_acquire() {
    563                 lock( kernel_debug_lock DEBUG_CTX2 );
    564         }
    565 
    566         void __lib_debug_release() {
     560        void __cfaabi_dbg_bits_acquire() {
     561                lock( kernel_debug_lock __cfaabi_dbg_ctx2 );
     562        }
     563
     564        void __cfaabi_dbg_bits_release() {
    567565                unlock( kernel_debug_lock );
    568566        }
     
    582580
    583581void P(semaphore & this) {
    584         lock( this.lock DEBUG_CTX2 );
     582        lock( this.lock __cfaabi_dbg_ctx2 );
    585583        this.count -= 1;
    586584        if ( this.count < 0 ) {
     
    598596void V(semaphore & this) {
    599597        thread_desc * thrd = NULL;
    600         lock( this.lock DEBUG_CTX2 );
     598        lock( this.lock __cfaabi_dbg_ctx2 );
    601599        this.count += 1;
    602600        if ( this.count <= 0 ) {
Note: See TracChangeset for help on using the changeset viewer.