Rev 258 | Rev 378 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 258 | Rev 309 | ||
---|---|---|---|
Line 58... | Line 58... | ||
58 | * tread is passed control. |
58 | * tread is passed control. |
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 |
|
- | 65 | if(THREAD==CPU->fpu_owner) |
|
- | 66 | fpu_enable(); |
|
- | 67 | else |
|
- | 68 | fpu_disable(); |
|
- | 69 | #else |
|
- | 70 | fpu_enable(); |
|
- | 71 | if (THREAD->fpu_context_exists) |
|
64 | fpu_context_restore(&(THREAD->saved_fpu_context)); |
72 | fpu_context_restore(&(THREAD->saved_fpu_context)); |
- | 73 | else { |
|
- | 74 | fpu_init(); |
|
- | 75 | THREAD->fpu_context_exists=1; |
|
- | 76 | } |
|
- | 77 | #endif |
|
65 | } |
78 | } |
66 | 79 | ||
- | 80 | #ifdef FPU_LAZY |
|
- | 81 | void scheduler_fpu_lazy_request(void) |
|
- | 82 | { |
|
- | 83 | fpu_enable(); |
|
- | 84 | if (CPU->fpu_owner != NULL) { |
|
- | 85 | fpu_context_save(&CPU->fpu_owner->saved_fpu_context); |
|
- | 86 | /* don't prevent migration */ |
|
- | 87 | CPU->fpu_owner->fpu_context_engaged=0; |
|
- | 88 | } |
|
- | 89 | if (THREAD->fpu_context_exists) |
|
- | 90 | fpu_context_restore(&THREAD->saved_fpu_context); |
|
- | 91 | else { |
|
- | 92 | fpu_init(); |
|
- | 93 | THREAD->fpu_context_exists=1; |
|
- | 94 | } |
|
- | 95 | CPU->fpu_owner=THREAD; |
|
- | 96 | THREAD->fpu_context_engaged = 1; |
|
- | 97 | } |
|
- | 98 | #endif |
|
67 | 99 | ||
68 | /** Initialize scheduler |
100 | /** Initialize scheduler |
69 | * |
101 | * |
70 | * Initialize kernel scheduler. |
102 | * Initialize kernel scheduler. |
71 | * |
103 | * |
Line 238... | Line 270... | ||
238 | if (haltstate) |
270 | if (haltstate) |
239 | halt(); |
271 | halt(); |
240 | 272 | ||
241 | if (THREAD) { |
273 | if (THREAD) { |
242 | spinlock_lock(&THREAD->lock); |
274 | spinlock_lock(&THREAD->lock); |
- | 275 | #ifndef FPU_LAZY |
|
243 | fpu_context_save(&(THREAD->saved_fpu_context)); |
276 | fpu_context_save(&(THREAD->saved_fpu_context)); |
- | 277 | #endif |
|
244 | if (!context_save(&THREAD->saved_context)) { |
278 | if (!context_save(&THREAD->saved_context)) { |
245 | /* |
279 | /* |
246 | * This is the place where threads leave scheduler(); |
280 | * This is the place where threads leave scheduler(); |
247 | */ |
281 | */ |
248 | before_thread_runs(); |
282 | before_thread_runs(); |