Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/proc/scheduler.c

    r481d4751 r37c9fc8  
    11/*
    2  * Copyright (c) 2010 Jakub Jermar
     2 * Copyright (c) 2001-2007 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    382382        int priority;
    383383        DEADLOCK_PROBE_INIT(p_joinwq);
    384         task_t *old_task = TASK;
    385         as_t *old_as = AS;
    386384
    387385        ASSERT(CPU != NULL);
    388386       
    389         /*
    390          * Hold the current task and the address space to prevent their
    391          * possible destruction should thread_destroy() be called on this or any
    392          * other processor while the scheduler is still using them.
    393          */
    394         if (old_task)
    395                 task_hold(old_task);
    396         if (old_as)
    397                 as_hold(old_as);
    398 
    399387        if (THREAD) {
    400388                /* must be run after the switch to scheduler stack */
     
    488476         */
    489477        if (TASK != THREAD->task) {
    490                 as_t *new_as = THREAD->task->as;
     478                as_t *as1 = NULL;
     479                as_t *as2;
     480
     481                if (TASK) {
     482                        spinlock_lock(&TASK->lock);
     483                        as1 = TASK->as;
     484                        spinlock_unlock(&TASK->lock);
     485                }
     486
     487                spinlock_lock(&THREAD->task->lock);
     488                as2 = THREAD->task->as;
     489                spinlock_unlock(&THREAD->task->lock);
    491490               
    492491                /*
     
    494493                 * space.
    495494                 */
    496                 if (old_as != new_as) {
     495                if (as1 != as2) {
    497496                        /*
    498497                         * Both tasks and address spaces are different.
    499498                         * Replace the old one with the new one.
    500499                         */
    501                         as_switch(old_as, new_as);
    502                 }
    503 
     500                        as_switch(as1, as2);
     501                }
    504502                TASK = THREAD->task;
    505503                before_task_runs();
    506504        }
    507505
    508         if (old_task)
    509                 task_release(old_task);
    510         if (old_as)
    511                 as_release(old_as);
    512        
    513506        spinlock_lock(&THREAD->lock);   
    514507        THREAD->state = Running;
Note: See TracChangeset for help on using the changeset viewer.