Subversion Repositories HelenOS

Rev

Rev 3798 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3798 Rev 4679
Line 59... Line 59...
59
#include <adt/list.h>
59
#include <adt/list.h>
60
#include <panic.h>
60
#include <panic.h>
61
#include <cpu.h>
61
#include <cpu.h>
62
#include <print.h>
62
#include <print.h>
63
#include <debug.h>
63
#include <debug.h>
-
 
64
#include <arch/smp/sun4v/smp.h>
64
 
65
 
65
static void before_task_runs(void);
66
static void before_task_runs(void);
66
static void before_thread_runs(void);
67
static void before_thread_runs(void);
67
static void after_thread_ran(void);
68
static void after_thread_ran(void);
68
static void scheduler_separated_stack(void);
69
static void scheduler_separated_stack(void);
Line 218... Line 219...
218
            continue;
219
            continue;
219
        }
220
        }
220
 
221
 
221
        atomic_dec(&CPU->nrdy);
222
        atomic_dec(&CPU->nrdy);
222
        atomic_dec(&nrdy);
223
        atomic_dec(&nrdy);
-
 
224
        if (CPU->arch.exec_unit)
-
 
225
            atomic_dec(&(CPU->arch.exec_unit->nrdy));
223
        r->n--;
226
        r->n--;
224
 
227
 
225
        /*
228
        /*
226
         * Take the first thread from the queue.
229
         * Take the first thread from the queue.
227
         */
230
         */
Line 563... Line 566...
563
     * passes. Each time get the most up to date counts.
566
     * passes. Each time get the most up to date counts.
564
     */
567
     */
565
    average = atomic_get(&nrdy) / config.cpu_active + 1;
568
    average = atomic_get(&nrdy) / config.cpu_active + 1;
566
    count = average - atomic_get(&CPU->nrdy);
569
    count = average - atomic_get(&CPU->nrdy);
567
 
570
 
-
 
571
    /* calculate number of threads to be stolen from other exec. units */
-
 
572
    spinlock_lock(&(CPU->arch.exec_unit->proposed_nrdy_lock));
-
 
573
    bool eu_busy = calculate_optimal_nrdy(CPU->arch.exec_unit);
-
 
574
    unsigned int count_other_eus = CPU->arch.proposed_nrdy
-
 
575
        - atomic_get(&(CPU->nrdy));
-
 
576
    spinlock_unlock(&(CPU->arch.exec_unit->proposed_nrdy_lock));
-
 
577
 
-
 
578
    /*
-
 
579
     * If the CPU's parent core is overloaded, do not do the load
-
 
580
     * balancing, otherwise we would migrate threads which should be
-
 
581
     * migrated to other cores and since a thread cannot be migrated
-
 
582
     * multiple times, it would not be migrated to the other core
-
 
583
     * in the future.
-
 
584
     */
-
 
585
    if (eu_busy)
-
 
586
        return;
-
 
587
 
-
 
588
    /*
-
 
589
     * get the maximum - stole enough threads to satisfy both the need to
-
 
590
     * have all virtual CPUs equally busy and the need to have all the
-
 
591
     * cores equally busy
-
 
592
     */
-
 
593
    if (((int) count_other_eus) > count)
-
 
594
        count = count_other_eus;
-
 
595
 
568
    if (count <= 0)
596
    if (count <= 0)
569
        goto satisfied;
597
        goto satisfied;
570
 
598
 
571
    /*
599
    /*
572
     * Searching least priority queues on all CPU's first and most priority
600
     * Searching least priority queues on all CPU's first and most priority
Line 620... Line 648...
620
                     */
648
                     */
621
                    spinlock_unlock(&t->lock);
649
                    spinlock_unlock(&t->lock);
622
                   
650
                   
623
                    atomic_dec(&cpu->nrdy);
651
                    atomic_dec(&cpu->nrdy);
624
                    atomic_dec(&nrdy);
652
                    atomic_dec(&nrdy);
-
 
653
                    if (cpu->arch.exec_unit)
-
 
654
                        atomic_dec(&(cpu->arch.exec_unit->nrdy));
625
 
655
 
626
                    r->n--;
656
                    r->n--;
627
                    list_remove(&t->rq_link);
657
                    list_remove(&t->rq_link);
628
 
658
 
629
                    break;
659
                    break;