Ignore:
File:
1 edited

Legend:

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

    rc1ee231 r8e9e9a2  
    3737// FwdDeclarations : timeout handlers
    3838static void preempt( processor   * this );
    39 static void timeout( $thread * this );
     39static void timeout( struct __processor_id_t * id, $thread * this );
    4040
    4141// FwdDeclarations : Signal handlers
     
    8888
    8989// Tick one frame of the Discrete Event Simulation for alarms
    90 static void tick_preemption() {
     90static void tick_preemption( struct __processor_id_t * id ) {
    9191        alarm_node_t * node = 0p;                                                       // Used in the while loop but cannot be declared in the while condition
    9292        alarm_list_t * alarms = &event_kernel->alarms;          // Local copy for ease of reading
     
    106106                }
    107107                else {
    108                         timeout( node->thrd );
     108                        timeout( id, node->thrd );
    109109                }
    110110
     
    119119        // If there are still alarms pending, reset the timer
    120120        if( & (*alarms)`first ) {
    121                 __cfaabi_dbg_print_buffer_decl( " KERNEL: @%ju(%ju) resetting alarm to %ju.\n", currtime.tv, __kernel_get_time().tv, (alarms->head->alarm - currtime).tv);
     121                __cfadbg_print_buffer_decl(preemption, " KERNEL: @%ju(%ju) resetting alarm to %ju.\n", currtime.tv, __kernel_get_time().tv, (alarms->head->alarm - currtime).tv);
    122122                Duration delta = (*alarms)`first.alarm - currtime;
    123123                Duration capped = max(delta, 50`us);
     
    186186        void enable_interrupts( __cfaabi_dbg_ctx_param ) {
    187187                processor   * proc = kernelTLS.this_processor; // Cache the processor now since interrupts can start happening after the atomic store
     188                /* paranoid */ verify( proc );
    188189
    189190                with( kernelTLS.preemption_state ){
     
    266267
    267268// reserved for future use
    268 static void timeout( $thread * this ) {
    269         __unpark( this __cfaabi_dbg_ctx2 );
     269static void timeout( struct __processor_id_t * id, $thread * this ) {
     270        #if !defined( __CFA_NO_STATISTICS__ )
     271                kernelTLS.this_stats = this->curr_cluster->stats;
     272        #endif
     273        __unpark( id, this __cfaabi_dbg_ctx2 );
    270274}
    271275
     
    403407// Waits on SIGALRM and send SIGUSR1 to whom ever needs it
    404408static void * alarm_loop( __attribute__((unused)) void * args ) {
     409        __processor_id_t id;
     410        id.id = doregister(&id);
     411
    405412        // Block sigalrms to control when they arrive
    406413        sigset_t mask;
     
    447454                        // __cfaabi_dbg_print_safe( "Kernel : Preemption thread tick\n" );
    448455                        lock( event_kernel->lock __cfaabi_dbg_ctx2 );
    449                         tick_preemption();
     456                        tick_preemption( &id );
    450457                        unlock( event_kernel->lock );
    451458                        break;
     
    460467EXIT:
    461468        __cfaabi_dbg_print_safe( "Kernel : Preemption thread stopping\n" );
     469        unregister(&id);
    462470        return 0p;
    463471}
Note: See TracChangeset for help on using the changeset viewer.