Ignore:
Timestamp:
Jan 19, 2017, 3:42:29 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
dcb42b8
Parents:
4a3386b4
Message:

Clean-up thread, kernel and examples

File:
1 edited

Legend:

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

    r4a3386b4 r8f49a54  
    119119        // context switch to specified coroutine
    120120        // Which is now the current_coroutine
    121         LIB_DEBUG_PRINTF("Kernel : switching to ctx %p (from %p, current %p)\n", thrd_ctx, proc_ctx, current_coroutine);
     121        // LIB_DEBUG_PRINTF("Kernel : switching to ctx %p (from %p, current %p)\n", thrd_ctx, proc_ctx, current_coroutine);
    122122        current_coroutine = thrd_ctx;
    123123        CtxSwitch( proc_ctx->stack.context, thrd_ctx->stack.context );
    124124        current_coroutine = proc_ctx;
    125         LIB_DEBUG_PRINTF("Kernel : returned from ctx %p (to %p, current %p)\n", thrd_ctx, proc_ctx, current_coroutine);
     125        // LIB_DEBUG_PRINTF("Kernel : returned from ctx %p (to %p, current %p)\n", thrd_ctx, proc_ctx, current_coroutine);
    126126
    127127        // when CtxSwitch returns we are back in the processor coroutine
     
    136136
    137137void scheduler_add( thread_h * thrd ) {
    138         LIB_DEBUG_PRINTF("Kernel : scheduling %p on core %p (%d spots)\n", thrd, systemProcessor, systemProcessor->thread_count);
    139138        for(int i = 0; i < systemProcessor->thread_count; i++) {
    140139                if(systemProcessor->threads[i] == NULL) {
     
    143142                }
    144143        }
    145         assert(false);
     144        assertf(false, "Scheduler full");
    146145}
    147146
    148147void scheduler_remove( thread_h * thrd ) {
    149         LIB_DEBUG_PRINTF("Kernel : unscheduling %p from core %p\n", thrd, systemProcessor);
    150148        for(int i = 0; i < systemProcessor->thread_count; i++) {
    151149                if(systemProcessor->threads[i] == thrd) {
    152150                        systemProcessor->threads[i] = NULL;
    153                         break;
    154                 }
    155         }
    156         for(int i = 0; i < systemProcessor->thread_count; i++) {
    157                 if(systemProcessor->threads[i] != NULL) {
    158151                        return;
    159152                }
    160153        }
    161         LIB_DEBUG_PRINTF("Kernel : terminating core %p\n", systemProcessor);   
    162         systemProcessor->terminated = true;
     154        assertf(false, "Trying to unschedule unkown thread");
    163155}
    164156
     
    229221
    230222        mainThread_info_t ctx;
    231         LIB_DEBUG_PRINTF("Kernel :    base : %p\n", ctx.base );
    232         LIB_DEBUG_PRINTF("Kernel :     top : %p\n", ctx.top );
    233         LIB_DEBUG_PRINTF("Kernel :   limit : %p\n", ctx.limit );
    234         LIB_DEBUG_PRINTF("Kernel :    size : %x\n", ctx.size );
    235         LIB_DEBUG_PRINTF("Kernel : storage : %p\n", ctx.storage );
    236         LIB_DEBUG_PRINTF("Kernel : context : %p\n", ctx.context );
     223        // LIB_DEBUG_PRINTF("Kernel :    base : %p\n", ctx.base );
     224        // LIB_DEBUG_PRINTF("Kernel :     top : %p\n", ctx.top );
     225        // LIB_DEBUG_PRINTF("Kernel :   limit : %p\n", ctx.limit );
     226        // LIB_DEBUG_PRINTF("Kernel :    size : %x\n", ctx.size );
     227        // LIB_DEBUG_PRINTF("Kernel : storage : %p\n", ctx.storage );
     228        // LIB_DEBUG_PRINTF("Kernel : context : %p\n", ctx.context );
    237229
    238230        // Start by initializing the main thread
     
    265257        scheduler_remove(mainThread);
    266258
    267         LIB_DEBUG_PRINTF("Suspending main\n");
     259        LIB_DEBUG_PRINTF("Kernel : Terminating system processor\n");           
     260        systemProcessor->terminated = true;
     261
    268262        suspend();
    269263
    270         LIB_DEBUG_PRINTF("Kernel : Control return to initial process thread\n");
     264        LIB_DEBUG_PRINTF("Kernel : Control returned to initial process thread\n");
    271265
    272266        ^(systemProcessor->ctx){};
Note: See TracChangeset for help on using the changeset viewer.