Changeset 5c1a531


Ignore:
Timestamp:
Apr 11, 2019, 10:36:13 AM (2 years ago)
Author:
tdelisle <tdelisle@…>
Branches:
arm-eh, cleanup-dtors, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
3c06bba
Parents:
e8e457e
Message:

Fixed errno virtualization and enabled preemption during coroutine context switch

Location:
libcfa/src/concurrency
Files:
4 edited

Legend:

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

    re8e457e r5c1a531  
    126126// Wrapper for co
    127127void CoroutineCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {
    128         // Safety note : Preemption must be disabled since there is a race condition
    129         // kernelTLS.this_thread->curr_cor and $rsp/$rbp must agree at all times
    130         verify( TL_GET( preemption_state.enabled ) || TL_GET( this_processor )->do_terminate );
    131         disable_interrupts();
    132 
    133128        // set state of current coroutine to inactive
    134129        src->state = src->state == Halted ? Halted : Inactive;
     
    144139        // set state of new coroutine to active
    145140        src->state = Active;
    146 
    147         enable_interrupts( __cfaabi_dbg_ctx );
    148         verify( TL_GET( preemption_state.enabled ) || TL_GET( this_processor )->do_terminate );
    149141
    150142        if( unlikely(src->cancellation != NULL) ) {
  • libcfa/src/concurrency/invoke.c

    re8e457e r5c1a531  
    4646
    4747        cor->state = Active;
    48 
    49         enable_interrupts( __cfaabi_dbg_ctx );
    5048
    5149        main( this );
  • libcfa/src/concurrency/invoke.h

    re8e457e r5c1a531  
    6565                void * SP;
    6666                void * FP;
    67                 // copy of global UNIX variable errno
    68                 int errno_;
    6967        };
    7068
     
    168166                // current execution status for coroutine
    169167                enum coroutine_state state;
     168
     169                //SKULLDUGGERY errno is not save in the thread data structure because returnToKernel appears to be the only function to require saving and restoring it
    170170
    171171                // coroutine body used to store context
  • libcfa/src/concurrency/kernel.cfa

    re8e457e r5c1a531  
    9191
    9292void ?{}( coroutine_desc & this, current_stack_info_t * info) with( this ) {
    93         context.errno_ = 0;
    9493        stack.storage = info->storage;
    9594        with(*stack.storage) {
     
    237236}
    238237
     238static int * __volatile_errno() __attribute__((noinline));
     239static int * __volatile_errno() { asm(""); return &errno; }
     240
    239241// KERNEL ONLY
    240242// runThread runs a thread by context switching
     
    271273        thrd_src->state = thrd_src->state == Halted ? Halted : Inactive;
    272274        proc_cor->state = Active;
     275        int local_errno = *__volatile_errno();
    273276
    274277        // set new coroutine that the processor is executing
     
    280283        proc_cor->state = proc_cor->state == Halted ? Halted : Inactive;
    281284        thrd_src->state = Active;
     285        *__volatile_errno() = local_errno;
    282286}
    283287
     
    380384        src->state = src->state == Halted ? Halted : Inactive;
    381385
    382         // SKULLDUGGERY normally interrupts are enable before leaving a coroutine ctxswitch.
    383         // Therefore, when first creating a coroutine, interrupts are enable before calling the main.
    384         // This is consistent with thread creation. However, when creating the main processor coroutine,
    385         // we wan't interrupts to be disabled. Therefore, we double-disable interrupts here so they will
    386         // stay disabled.
    387         disable_interrupts();
    388 
    389386        // context switch to specified coroutine
    390387        verify( dst->context.SP );
Note: See TracChangeset for help on using the changeset viewer.