Ignore:
File:
1 edited

Legend:

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

    rb4b63e8 r5afb49a  
    252252                /* paranoid */ verify( kernelTLS.this_thread == thrd_dst );
    253253                /* paranoid */ verify( thrd_dst->context.SP );
     254                /* paranoid */ verify( thrd_dst->state != Halted );
    254255                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) < ((uintptr_t)__get_stack(thrd_dst->curr_cor)->base ) || thrd_dst->curr_cor == proc_cor, "ERROR : Destination $thread %p has been corrupted.\n StackPointer too small.\n", thrd_dst ); // add escape condition if we are setting up the processor
    255256                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) > ((uintptr_t)__get_stack(thrd_dst->curr_cor)->limit) || thrd_dst->curr_cor == proc_cor, "ERROR : Destination $thread %p has been corrupted.\n StackPointer too large.\n", thrd_dst ); // add escape condition if we are setting up the processor
     
    287288                if(unlikely(thrd_dst->state == Halted)) {
    288289                        // The thread has halted, it should never be scheduled/run again
    289                         // We may need to wake someone up here since
    290                         unpark( this->destroyer );
    291                         this->destroyer = 0p;
     290                        // finish the thread
     291                        __thread_finish( thrd_dst );
    292292                        break RUNNING;
    293293                }
     
    448448}
    449449
    450 // KERNEL ONLY
    451 void __leave_thread() {
    452         /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    453         returnToKernel();
    454         abort();
     450extern "C" {
     451        // Leave the thread monitor
     452        // last routine called by a thread.
     453        // Should never return
     454        void __cfactx_thrd_leave() {
     455                $thread * thrd = TL_GET( this_thread );
     456                $monitor * this = &thrd->self_mon;
     457
     458                // Lock the monitor now
     459                lock( this->lock __cfaabi_dbg_ctx2 );
     460
     461                disable_interrupts();
     462
     463                thrd->state = Halted;
     464
     465                if( thrd != this->owner || this->recursion != 1) { abort( "Thread internal monitor has unbalanced recursion" ); }
     466
     467                // Leave the thread
     468                /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
     469                returnToKernel();
     470                abort();
     471
     472                // Control flow should never reach here!
     473        }
    455474}
    456475
Note: See TracChangeset for help on using the changeset viewer.