Changeset 444ec64 in mainline


Ignore:
Timestamp:
2006-02-05T14:15:51Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
328e0d3
Parents:
248fc1a
Message:

Cleanup of scheduler code

File:
1 edited

Legend:

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

    r248fc1a r444ec64  
    132132                 * until a hardware interrupt or an IPI comes.
    133133                 * This improves energy saving and hyperthreading.
     134                 *
     135                 * - we might get an interrupt here that makes some thread runnable,
     136                 *   in such a case we must wait for the next quantum to come
    134137                 */
    135138                 cpu_sleep();
     
    220223                CPU->needs_relink = 0;
    221224        }
    222         spinlock_unlock(&CPU->lock);                           
     225        spinlock_unlock(&CPU->lock);
    223226
    224227}
     
    463466         * passes. Each time get the most up to date counts.
    464467         */
    465         average = atomic_get(&nrdy) / config.cpu_active;
     468        average = atomic_get(&nrdy) / config.cpu_active + 1;
    466469        count = average - atomic_get(&CPU->nrdy);
    467470
    468         if (count < 0)
     471        if (count <= 0)
    469472                goto satisfied;
    470 
    471         if (!count) { /* Try to steal threads from CPU's that have more then average count */
    472                 count = 1;
    473                 average += 1;
    474         }
    475473
    476474        /*
     
    494492                                continue;
    495493
    496 restart:                ipl = interrupts_disable();
     494                        ipl = interrupts_disable();
    497495                        r = &cpu->rq[j];
    498496                        spinlock_lock(&r->lock);
     
    514512                                spinlock_lock(&t->lock);
    515513                                if ( (!(t->flags & (X_WIRED | X_STOLEN))) && (!(t->fpu_context_engaged)) ) {
    516                                
    517514                                        /*
    518515                                         * Remove t from r.
    519516                                         */
    520 
    521517                                        spinlock_unlock(&t->lock);
    522518                                       
    523                                         /*
    524                                          * Here we have to avoid deadlock with relink_rq(),
    525                                          * because it locks cpu and r in a different order than we do.
    526                                          */
    527                                         if (!spinlock_trylock(&cpu->lock)) {
    528                                                 /* Release all locks and try again. */
    529                                                 spinlock_unlock(&r->lock);
    530                                                 interrupts_restore(ipl);
    531                                                 goto restart;
    532                                         }
    533519                                        atomic_dec(&cpu->nrdy);
    534                                         spinlock_unlock(&cpu->lock);
    535 
    536520                                        atomic_dec(&nrdy);
    537521
Note: See TracChangeset for help on using the changeset viewer.