Changeset f2b12406


Ignore:
Timestamp:
Jul 12, 2017, 10:14:11 AM (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:
f73f5f4
Parents:
0322865c
Message:

Preemption is now stable enough to push, some clean-up needed

Location:
src/libcfa/concurrency
Files:
5 edited

Legend:

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

    r0322865c rf2b12406  
    8080      // 2 - Leave its monitor
    8181      // 3 - Disable the interupts
    82       // The order of these 3 operations is very important
     82      // 4 - Final suspend
     83      // The order of these 4 operations is very important
     84      //Final suspend, should never return
    8385      __leave_thread_monitor( thrd );
    84 
    85       //Final suspend, should never return
    86       __suspend_internal();
    8786      abortf("Resumed dead thread");
    8887}
  • src/libcfa/concurrency/kernel.c

    r0322865c rf2b12406  
    4242//-----------------------------------------------------------------------------
    4343// Kernel storage
    44 #define KERNEL_STORAGE(T,X) static char X##_storage[sizeof(T)]
     44#define KERNEL_STORAGE(T,X) static char X##Storage[sizeof(T)]
    4545
    4646KERNEL_STORAGE(processorCtx_t, systemProcessorCtx);
     
    4848KERNEL_STORAGE(system_proc_t, systemProcessor);
    4949KERNEL_STORAGE(thread_desc, mainThread);
    50 KERNEL_STORAGE(machine_context_t, mainThread_context);
     50KERNEL_STORAGE(machine_context_t, mainThreadCtx);
    5151
    5252cluster * systemCluster;
     
    8484
    8585        this->limit = (void *)(((intptr_t)this->base) - this->size);
    86         this->context = &mainThread_context_storage;
     86        this->context = &mainThreadCtxStorage;
    8787        this->top = this->base;
    8888}
     
    432432}
    433433
     434void LeaveThread(spinlock * lock, thread_desc * thrd) {
     435        verify( disable_preempt_count > 0 );
     436        this_processor->finish.action_code = thrd ? Release_Schedule : Release;
     437        this_processor->finish.lock = lock;
     438        this_processor->finish.thrd = thrd;
     439
     440        suspend();
     441}
     442
    434443//=============================================================================================
    435444// Kernel Setup logic
     
    443452        // SKULLDUGGERY: the mainThread steals the process main thread
    444453        // which will then be scheduled by the systemProcessor normally
    445         mainThread = (thread_desc *)&mainThread_storage;
     454        mainThread = (thread_desc *)&mainThreadStorage;
    446455        current_stack_info_t info;
    447456        mainThread{ &info };
     
    450459
    451460        // Initialize the system cluster
    452         systemCluster = (cluster *)&systemCluster_storage;
     461        systemCluster = (cluster *)&systemClusterStorage;
    453462        systemCluster{};
    454463
     
    457466        // Initialize the system processor and the system processor ctx
    458467        // (the coroutine that contains the processing control flow)
    459         systemProcessor = (system_proc_t *)&systemProcessor_storage;
    460         systemProcessor{ systemCluster, (processorCtx_t *)&systemProcessorCtx_storage };
     468        systemProcessor = (system_proc_t *)&systemProcessorStorage;
     469        systemProcessor{ systemCluster, (processorCtx_t *)&systemProcessorCtxStorage };
    461470
    462471        // Add the main thread to the ready queue
  • src/libcfa/concurrency/kernel_private.h

    r0322865c rf2b12406  
    5151void BlockInternal(spinlock ** locks, unsigned short count);
    5252void BlockInternal(spinlock ** locks, unsigned short count, thread_desc ** thrds, unsigned short thrd_count);
     53void LeaveThread(spinlock * lock, thread_desc * thrd);
    5354
    5455//-----------------------------------------------------------------------------
  • src/libcfa/concurrency/monitor.c

    r0322865c rf2b12406  
    124124                thread_desc * new_owner = next_thread( this );
    125125
    126                 //We can now let other threads in safely
    127                 unlock( &this->lock );
    128 
    129                 //We need to wake-up the thread
    130                 if( new_owner) ScheduleThread( new_owner );
     126                LeaveThread( &this->lock, new_owner );
    131127        }
    132128}
  • src/libcfa/concurrency/preemption.c

    r0322865c rf2b12406  
    209209        LIB_DEBUG_PRINT_SAFE("Kernel : Starting preemption\n");
    210210        __kernel_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO );
    211         __kernel_sigaction( SIGSEGV, sigHandler_segv     , SA_SIGINFO );
    212         __kernel_sigaction( SIGBUS , sigHandler_segv     , SA_SIGINFO );
     211        // __kernel_sigaction( SIGSEGV, sigHandler_segv     , SA_SIGINFO );
     212        // __kernel_sigaction( SIGBUS , sigHandler_segv     , SA_SIGINFO );
    213213
    214214        signal_block( SIGALRM );
     
    417417)
    418418
    419 void sigHandler_segv( __CFA_SIGPARMS__ ) {
    420         LIB_DEBUG_DO(
    421                 #ifdef __USE_STREAM__
    422                 serr    | "*CFA runtime error* program cfa-cpp terminated with"
    423                         | (sig == SIGSEGV ? "segment fault." : "bus error.")
    424                         | endl;
    425                 #else
    426                 fprintf( stderr, "*CFA runtime error* program cfa-cpp terminated with %s\n", sig == SIGSEGV ? "segment fault." : "bus error." );
    427                 #endif
    428 
    429                 // skip first 2 stack frames
    430                 __kernel_backtrace( 1 );
    431         )
    432         exit( EXIT_FAILURE );
    433 }
     419// void sigHandler_segv( __CFA_SIGPARMS__ ) {
     420//      LIB_DEBUG_DO(
     421//              #ifdef __USE_STREAM__
     422//              serr    | "*CFA runtime error* program cfa-cpp terminated with"
     423//                      | (sig == SIGSEGV ? "segment fault." : "bus error.")
     424//                      | endl;
     425//              #else
     426//              fprintf( stderr, "*CFA runtime error* program cfa-cpp terminated with %s\n", sig == SIGSEGV ? "segment fault." : "bus error." );
     427//              #endif
     428
     429//              // skip first 2 stack frames
     430//              __kernel_backtrace( 1 );
     431//      )
     432//      exit( EXIT_FAILURE );
     433// }
    434434
    435435// void sigHandler_abort( __CFA_SIGPARMS__ ) {
Note: See TracChangeset for help on using the changeset viewer.