Subversion Repositories HelenOS-historic

Rev

Rev 452 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 452 Rev 458
Line 59... Line 59...
59
 *
59
 *
60
 */
60
 */
61
void before_thread_runs(void)
61
void before_thread_runs(void)
62
{
62
{
63
    before_thread_runs_arch();
63
    before_thread_runs_arch();
64
#ifdef FPU_LAZY
64
#ifdef CONFIG_FPU_LAZY
65
    if(THREAD==CPU->fpu_owner)
65
    if(THREAD==CPU->fpu_owner)
66
        fpu_enable();
66
        fpu_enable();
67
    else
67
    else
68
        fpu_disable();
68
        fpu_disable();
69
#else
69
#else
Line 75... Line 75...
75
        THREAD->fpu_context_exists=1;
75
        THREAD->fpu_context_exists=1;
76
    }
76
    }
77
#endif
77
#endif
78
}
78
}
79
 
79
 
80
#ifdef FPU_LAZY
80
#ifdef CONFIG_FPU_LAZY
81
void scheduler_fpu_lazy_request(void)
81
void scheduler_fpu_lazy_request(void)
82
{
82
{
83
    fpu_enable();
83
    fpu_enable();
84
    if (CPU->fpu_owner != NULL) {  
84
    if (CPU->fpu_owner != NULL) {  
85
        fpu_context_save(&CPU->fpu_owner->saved_fpu_context);
85
        fpu_context_save(&CPU->fpu_owner->saved_fpu_context);
Line 132... Line 132...
132
    spinlock_unlock(&CPU->lock);
132
    spinlock_unlock(&CPU->lock);
133
 
133
 
134
    interrupts_enable();
134
    interrupts_enable();
135
   
135
   
136
    if (n == 0) {
136
    if (n == 0) {
137
        #ifdef __SMP__
137
        #ifdef CONFIG_SMP
138
        /*
138
        /*
139
         * If the load balancing thread is not running, wake it up and
139
         * If the load balancing thread is not running, wake it up and
140
         * set CPU-private flag that the kcpulb has been started.
140
         * set CPU-private flag that the kcpulb has been started.
141
         */
141
         */
142
        if (test_and_set(&CPU->kcpulbstarted) == 0) {
142
        if (test_and_set(&CPU->kcpulbstarted) == 0) {
143
            waitq_wakeup(&CPU->kcpulb_wq, 0);
143
            waitq_wakeup(&CPU->kcpulb_wq, 0);
144
            goto loop;
144
            goto loop;
145
        }
145
        }
146
        #endif /* __SMP__ */
146
        #endif /* CONFIG_SMP */
147
       
147
       
148
        /*
148
        /*
149
         * For there was nothing to run, the CPU goes to sleep
149
         * For there was nothing to run, the CPU goes to sleep
150
         * until a hardware interrupt or an IPI comes.
150
         * until a hardware interrupt or an IPI comes.
151
         * This improves energy saving and hyperthreading.
151
         * This improves energy saving and hyperthreading.
Line 410... Line 410...
410
    if (haltstate)
410
    if (haltstate)
411
        halt();
411
        halt();
412
 
412
 
413
    if (THREAD) {
413
    if (THREAD) {
414
        spinlock_lock(&THREAD->lock);
414
        spinlock_lock(&THREAD->lock);
415
#ifndef FPU_LAZY
415
#ifndef CONFIG_FPU_LAZY
416
        fpu_context_save(&(THREAD->saved_fpu_context));
416
        fpu_context_save(&(THREAD->saved_fpu_context));
417
#endif
417
#endif
418
        if (!context_save(&THREAD->saved_context)) {
418
        if (!context_save(&THREAD->saved_context)) {
419
            /*
419
            /*
420
             * This is the place where threads leave scheduler();
420
             * This is the place where threads leave scheduler();
Line 460... Line 460...
460
 
460
 
461
 
461
 
462
 
462
 
463
 
463
 
464
 
464
 
465
#ifdef __SMP__
465
#ifdef CONFIG_SMP
466
/** Load balancing thread
466
/** Load balancing thread
467
 *
467
 *
468
 * SMP load balancing thread, supervising thread supplies
468
 * SMP load balancing thread, supervising thread supplies
469
 * for the CPU it's wired to.
469
 * for the CPU it's wired to.
470
 *
470
 *
Line 621... Line 621...
621
     */
621
     */
622
    CPU->kcpulbstarted = 0;
622
    CPU->kcpulbstarted = 0;
623
    goto loop;
623
    goto loop;
624
}
624
}
625
 
625
 
626
#endif /* __SMP__ */
626
#endif /* CONFIG_SMP */