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


Ignore:
Timestamp:
2010-05-21T07:50:04Z (16 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d51ee2b
Parents:
cf8cc36 (diff), 15b592b (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 mainline changes (rev. 451)

File:
1 edited

Legend:

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

    rcf8cc36 rc47e1a8  
    11/*
    2  * Copyright (c) 2001-2007 Jakub Jermar
     2 * Copyright (c) 2010 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    187187
    188188loop:
    189         interrupts_enable();
    190189       
    191190        if (atomic_get(&CPU->nrdy) == 0) {
     
    196195                 */
    197196
    198                 /*
     197                 /* Mark CPU as it was idle this clock tick */
     198                 spinlock_lock(&CPU->lock);
     199                 CPU->idle = true;
     200                 spinlock_unlock(&CPU->lock);
     201
     202                 interrupts_enable();
     203                 /*
    199204                 * An interrupt might occur right now and wake up a thread.
    200205                 * In such case, the CPU will continue to go to sleep
    201206                 * even though there is a runnable thread.
    202207                 */
    203 
    204208                 cpu_sleep();
     209                 interrupts_disable();
    205210                 goto loop;
    206211        }
    207 
    208         interrupts_disable();
    209212       
    210213        for (i = 0; i < RQ_COUNT; i++) {
     
    313316                spinlock_lock(&THREAD->lock);
    314317               
    315                 /* Update thread accounting */
    316                 THREAD->cycles += get_cycle() - THREAD->last_cycle;
     318                /* Update thread kernel accounting */
     319                THREAD->kcycles += get_cycle() - THREAD->last_cycle;
    317320               
    318321#ifndef CONFIG_FPU_LAZY
     
    379382        int priority;
    380383        DEADLOCK_PROBE_INIT(p_joinwq);
     384        task_t *old_task = TASK;
     385        as_t *old_as = AS;
    381386
    382387        ASSERT(CPU != NULL);
    383388       
     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
    384399        if (THREAD) {
    385400                /* must be run after the switch to scheduler stack */
     
    473488         */
    474489        if (TASK != THREAD->task) {
    475                 as_t *as1 = NULL;
    476                 as_t *as2;
    477 
    478                 if (TASK) {
    479                         spinlock_lock(&TASK->lock);
    480                         as1 = TASK->as;
    481                         spinlock_unlock(&TASK->lock);
    482                 }
    483 
    484                 spinlock_lock(&THREAD->task->lock);
    485                 as2 = THREAD->task->as;
    486                 spinlock_unlock(&THREAD->task->lock);
     490                as_t *new_as = THREAD->task->as;
    487491               
    488492                /*
     
    490494                 * space.
    491495                 */
    492                 if (as1 != as2) {
     496                if (old_as != new_as) {
    493497                        /*
    494498                         * Both tasks and address spaces are different.
    495499                         * Replace the old one with the new one.
    496500                         */
    497                         as_switch(as1, as2);
     501                        as_switch(old_as, new_as);
    498502                }
     503
    499504                TASK = THREAD->task;
    500505                before_task_runs();
    501506        }
    502507
     508        if (old_task)
     509                task_release(old_task);
     510        if (old_as)
     511                as_release(old_as);
     512       
    503513        spinlock_lock(&THREAD->lock);   
    504514        THREAD->state = Running;
     
    542552{
    543553        thread_t *t;
    544         int count, average, j, k = 0;
     554        int count;
     555        atomic_count_t average;
    545556        unsigned int i;
     557        int j;
     558        int k = 0;
    546559        ipl_t ipl;
    547560
Note: See TracChangeset for help on using the changeset viewer.