Changeset bb252ca in mainline for kernel/generic/src/proc/scheduler.c


Ignore:
Timestamp:
2010-05-02T20:58:27Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4872160
Parents:
4ce914d4 (diff), 1624aae (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 the scheduler fix.

File:
1 edited

Legend:

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

    r4ce914d4 rbb252ca  
    11/*
    2  * Copyright (c) 2001-2007 Jakub Jermar
     2 * Copyright (c) 2010 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;
    384386
    385387        ASSERT(CPU != NULL);
    386388       
     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
    387399        if (THREAD) {
    388400                /* must be run after the switch to scheduler stack */
     
    476488         */
    477489        if (TASK != THREAD->task) {
    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);
     490                as_t *new_as = THREAD->task->as;
    490491               
    491492                /*
     
    493494                 * space.
    494495                 */
    495                 if (as1 != as2) {
     496                if (old_as != new_as) {
    496497                        /*
    497498                         * Both tasks and address spaces are different.
    498499                         * Replace the old one with the new one.
    499500                         */
    500                         as_switch(as1, as2);
     501                        as_switch(old_as, new_as);
    501502                }
     503
    502504                TASK = THREAD->task;
    503505                before_task_runs();
    504506        }
    505507
     508        if (old_task)
     509                task_release(old_task);
     510        if (old_as)
     511                as_release(old_as);
     512       
    506513        spinlock_lock(&THREAD->lock);   
    507514        THREAD->state = Running;
Note: See TracChangeset for help on using the changeset viewer.