Ignore:
Timestamp:
Jul 7, 2021, 6:24:42 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
d83b266
Parents:
1f45c7d (diff), b1a2c4a (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:software/cfa/cfa-cc

File:
1 edited

Legend:

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

    r1f45c7d rc86ee4c  
    110110#endif
    111111
    112 extern $thread * mainThread;
     112extern thread$ * mainThread;
    113113extern processor * mainProcessor;
    114114
    115115//-----------------------------------------------------------------------------
    116116// Kernel Scheduling logic
    117 static $thread * __next_thread(cluster * this);
    118 static $thread * __next_thread_slow(cluster * this);
    119 static inline bool __must_unpark( $thread * thrd ) __attribute((nonnull(1)));
    120 static void __run_thread(processor * this, $thread * dst);
     117static thread$ * __next_thread(cluster * this);
     118static thread$ * __next_thread_slow(cluster * this);
     119static inline bool __must_unpark( thread$ * thrd ) __attribute((nonnull(1)));
     120static void __run_thread(processor * this, thread$ * dst);
    121121static void __wake_one(cluster * cltr);
    122122
     
    181181                __cfadbg_print_safe(runtime_core, "Kernel : core %p started\n", this);
    182182
    183                 $thread * readyThread = 0p;
     183                thread$ * readyThread = 0p;
    184184                MAIN_LOOP:
    185185                for() {
     
    388388// runThread runs a thread by context switching
    389389// from the processor coroutine to the target thread
    390 static void __run_thread(processor * this, $thread * thrd_dst) {
     390static void __run_thread(processor * this, thread$ * thrd_dst) {
    391391        /* paranoid */ verify( ! __preemption_enabled() );
    392392        /* paranoid */ verifyf( thrd_dst->state == Ready || thrd_dst->preempted != __NO_PREEMPTION, "state : %d, preempted %d\n", thrd_dst->state, thrd_dst->preempted);
     
    406406        __cfadbg_print_safe(runtime_core, "Kernel : core %p running thread %p (%s)\n", this, thrd_dst, thrd_dst->self_cor.name);
    407407
    408         $coroutine * proc_cor = get_coroutine(this->runner);
     408        coroutine$ * proc_cor = get_coroutine(this->runner);
    409409
    410410        // set state of processor coroutine to inactive
     
    425425                /* paranoid */ verify( thrd_dst->context.SP );
    426426                /* paranoid */ verify( thrd_dst->state != Halted );
    427                 /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) < ((uintptr_t)__get_stack(thrd_dst->curr_cor)->base ) || thrd_dst->curr_cor == proc_cor || thrd_dst->corctx_flag, "ERROR : Destination $thread %p has been corrupted.\n StackPointer too small.\n", thrd_dst ); // add escape condition if we are setting up the processor
    428                 /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) > ((uintptr_t)__get_stack(thrd_dst->curr_cor)->limit) || thrd_dst->curr_cor == proc_cor || thrd_dst->corctx_flag, "ERROR : Destination $thread %p has been corrupted.\n StackPointer too large.\n", thrd_dst ); // add escape condition if we are setting up the processor
     427                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) < ((uintptr_t)__get_stack(thrd_dst->curr_cor)->base ) || thrd_dst->curr_cor == proc_cor || thrd_dst->corctx_flag, "ERROR : Destination thread$ %p has been corrupted.\n StackPointer too small.\n", thrd_dst ); // add escape condition if we are setting up the processor
     428                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) > ((uintptr_t)__get_stack(thrd_dst->curr_cor)->limit) || thrd_dst->curr_cor == proc_cor || thrd_dst->corctx_flag, "ERROR : Destination thread$ %p has been corrupted.\n StackPointer too large.\n", thrd_dst ); // add escape condition if we are setting up the processor
    429429                /* paranoid */ verify( 0x0D15EA5E0D15EA5Ep == thrd_dst->canary );
    430430
     
    438438
    439439                /* paranoid */ verify( 0x0D15EA5E0D15EA5Ep == thrd_dst->canary );
    440                 /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) > ((uintptr_t)__get_stack(thrd_dst->curr_cor)->limit) || thrd_dst->corctx_flag, "ERROR : Destination $thread %p has been corrupted.\n StackPointer too large.\n", thrd_dst );
    441                 /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) < ((uintptr_t)__get_stack(thrd_dst->curr_cor)->base ) || thrd_dst->corctx_flag, "ERROR : Destination $thread %p has been corrupted.\n StackPointer too small.\n", thrd_dst );
     440                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) > ((uintptr_t)__get_stack(thrd_dst->curr_cor)->limit) || thrd_dst->corctx_flag, "ERROR : Destination thread$ %p has been corrupted.\n StackPointer too large.\n", thrd_dst );
     441                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) < ((uintptr_t)__get_stack(thrd_dst->curr_cor)->base ) || thrd_dst->corctx_flag, "ERROR : Destination thread$ %p has been corrupted.\n StackPointer too small.\n", thrd_dst );
    442442                /* paranoid */ verify( thrd_dst->context.SP );
    443443                /* paranoid */ verify( thrd_dst->curr_cluster == this->cltr );
     
    505505void returnToKernel() {
    506506        /* paranoid */ verify( ! __preemption_enabled() );
    507         $coroutine * proc_cor = get_coroutine(kernelTLS().this_processor->runner);
    508         $thread * thrd_src = kernelTLS().this_thread;
     507        coroutine$ * proc_cor = get_coroutine(kernelTLS().this_processor->runner);
     508        thread$ * thrd_src = kernelTLS().this_thread;
    509509
    510510        __STATS( thrd_src->last_proc = kernelTLS().this_processor; )
     
    534534
    535535        /* paranoid */ verify( ! __preemption_enabled() );
    536         /* paranoid */ verifyf( ((uintptr_t)thrd_src->context.SP) < ((uintptr_t)__get_stack(thrd_src->curr_cor)->base ) || thrd_src->corctx_flag, "ERROR : Returning $thread %p has been corrupted.\n StackPointer too small.\n", thrd_src );
    537         /* paranoid */ verifyf( ((uintptr_t)thrd_src->context.SP) > ((uintptr_t)__get_stack(thrd_src->curr_cor)->limit) || thrd_src->corctx_flag, "ERROR : Returning $thread %p has been corrupted.\n StackPointer too large.\n", thrd_src );
     536        /* paranoid */ verifyf( ((uintptr_t)thrd_src->context.SP) < ((uintptr_t)__get_stack(thrd_src->curr_cor)->base ) || thrd_src->corctx_flag, "ERROR : Returning thread$ %p has been corrupted.\n StackPointer too small.\n", thrd_src );
     537        /* paranoid */ verifyf( ((uintptr_t)thrd_src->context.SP) > ((uintptr_t)__get_stack(thrd_src->curr_cor)->limit) || thrd_src->corctx_flag, "ERROR : Returning thread$ %p has been corrupted.\n StackPointer too large.\n", thrd_src );
    538538}
    539539
     
    541541// Scheduler routines
    542542// KERNEL ONLY
    543 static void __schedule_thread( $thread * thrd ) {
     543static void __schedule_thread( thread$ * thrd ) {
    544544        /* paranoid */ verify( ! __preemption_enabled() );
    545545        /* paranoid */ verify( ready_schedule_islocked());
     
    589589}
    590590
    591 void schedule_thread$( $thread * thrd ) {
     591void schedule_thread$( thread$ * thrd ) {
    592592        ready_schedule_lock();
    593593                __schedule_thread( thrd );
     
    596596
    597597// KERNEL ONLY
    598 static inline $thread * __next_thread(cluster * this) with( *this ) {
     598static inline thread$ * __next_thread(cluster * this) with( *this ) {
    599599        /* paranoid */ verify( ! __preemption_enabled() );
    600600
    601601        ready_schedule_lock();
    602                 $thread * thrd = pop_fast( this );
     602                thread$ * thrd = pop_fast( this );
    603603        ready_schedule_unlock();
    604604
     
    608608
    609609// KERNEL ONLY
    610 static inline $thread * __next_thread_slow(cluster * this) with( *this ) {
     610static inline thread$ * __next_thread_slow(cluster * this) with( *this ) {
    611611        /* paranoid */ verify( ! __preemption_enabled() );
    612612
    613613        ready_schedule_lock();
    614                 $thread * thrd;
     614                thread$ * thrd;
    615615                for(25) {
    616616                        thrd = pop_slow( this );
     
    626626}
    627627
    628 static inline bool __must_unpark( $thread * thrd ) {
     628static inline bool __must_unpark( thread$ * thrd ) {
    629629        int old_ticket = __atomic_fetch_add(&thrd->ticket, 1, __ATOMIC_SEQ_CST);
    630630        switch(old_ticket) {
     
    642642}
    643643
    644 void __kernel_unpark( $thread * thrd ) {
     644void __kernel_unpark( thread$ * thrd ) {
    645645        /* paranoid */ verify( ! __preemption_enabled() );
    646646        /* paranoid */ verify( ready_schedule_islocked());
     
    657657}
    658658
    659 void unpark( $thread * thrd ) {
     659void unpark( thread$ * thrd ) {
    660660        if( !thrd ) return;
    661661
     
    681681        // Should never return
    682682        void __cfactx_thrd_leave() {
    683                 $thread * thrd = active_thread();
    684                 $monitor * this = &thrd->self_mon;
     683                thread$ * thrd = active_thread();
     684                monitor$ * this = &thrd->self_mon;
    685685
    686686                // Lock the monitor now
     
    694694                /* paranoid */ verify( kernelTLS().this_thread == thrd );
    695695                /* paranoid */ verify( thrd->context.SP );
    696                 /* paranoid */ verifyf( ((uintptr_t)thrd->context.SP) > ((uintptr_t)__get_stack(thrd->curr_cor)->limit), "ERROR : $thread %p has been corrupted.\n StackPointer too large.\n", thrd );
    697                 /* paranoid */ verifyf( ((uintptr_t)thrd->context.SP) < ((uintptr_t)__get_stack(thrd->curr_cor)->base ), "ERROR : $thread %p has been corrupted.\n StackPointer too small.\n", thrd );
     696                /* paranoid */ verifyf( ((uintptr_t)thrd->context.SP) > ((uintptr_t)__get_stack(thrd->curr_cor)->limit), "ERROR : thread$ %p has been corrupted.\n StackPointer too large.\n", thrd );
     697                /* paranoid */ verifyf( ((uintptr_t)thrd->context.SP) < ((uintptr_t)__get_stack(thrd->curr_cor)->base ), "ERROR : thread$ %p has been corrupted.\n StackPointer too small.\n", thrd );
    698698
    699699                thrd->state = Halting;
     
    713713bool force_yield( __Preemption_Reason reason ) {
    714714        __disable_interrupts_checked();
    715                 $thread * thrd = kernelTLS().this_thread;
     715                thread$ * thrd = kernelTLS().this_thread;
    716716                /* paranoid */ verify(thrd->state == Active);
    717717
     
    825825//=============================================================================================
    826826void __kernel_abort_msg( char * abort_text, int abort_text_size ) {
    827         $thread * thrd = __cfaabi_tls.this_thread;
     827        thread$ * thrd = __cfaabi_tls.this_thread;
    828828
    829829        if(thrd) {
Note: See TracChangeset for help on using the changeset viewer.