Changeset 23f36a3 in mainline
- Timestamp:
- 2024-01-14T18:24:05Z (13 months ago)
- Branches:
- master
- Children:
- 6e49dab
- Parents:
- 5663872
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-03-04 20:11:55)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2024-01-14 18:24:05)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/proc/scheduler.c
r5663872 r23f36a3 67 67 68 68 static void scheduler_separated_stack(void); 69 static void fpu_restore(void); 69 70 70 71 atomic_size_t nrdy; /**< Number of ready threads in the system. */ … … 83 84 before_thread_runs_arch(); 84 85 85 #ifdef CONFIG_FPU_LAZY 86 /* 87 * The only concurrent modification possible for fpu_owner here is 88 * another thread changing it from itself to NULL in its destructor. 89 */ 90 thread_t *owner = atomic_load_explicit(&CPU->fpu_owner, 91 memory_order_relaxed); 92 93 if (THREAD == owner) 94 fpu_enable(); 95 else 96 fpu_disable(); 97 #elif defined CONFIG_FPU 98 fpu_enable(); 99 if (THREAD->fpu_context_exists) 100 fpu_context_restore(&THREAD->fpu_context); 101 else { 102 fpu_init(); 103 THREAD->fpu_context_exists = true; 104 } 105 #endif 86 fpu_restore(); 106 87 107 88 #ifdef CONFIG_UDEBUG … … 341 322 } 342 323 324 /** 325 * Do whatever needs to be done with current FPU state before we switch to 326 * another thread. 327 */ 328 static void fpu_cleanup(void) 329 { 330 #if (defined CONFIG_FPU) && (!defined CONFIG_FPU_LAZY) 331 fpu_context_save(&THREAD->fpu_context); 332 #endif 333 } 334 335 /** 336 * Set correct FPU state for this thread after switch from another thread. 337 */ 338 static void fpu_restore(void) 339 { 340 #ifdef CONFIG_FPU_LAZY 341 /* 342 * The only concurrent modification possible for fpu_owner here is 343 * another thread changing it from itself to NULL in its destructor. 344 */ 345 thread_t *owner = atomic_load_explicit(&CPU->fpu_owner, 346 memory_order_relaxed); 347 348 if (THREAD == owner) 349 fpu_enable(); 350 else 351 fpu_disable(); 352 353 #elif defined CONFIG_FPU 354 fpu_enable(); 355 if (THREAD->fpu_context_exists) 356 fpu_context_restore(&THREAD->fpu_context); 357 else { 358 fpu_init(); 359 THREAD->fpu_context_exists = true; 360 } 361 #endif 362 } 363 343 364 void scheduler(void) 344 365 { … … 370 391 THREAD->kcycles += get_cycle() - THREAD->last_cycle; 371 392 372 #if (defined CONFIG_FPU) && (!defined CONFIG_FPU_LAZY) 373 fpu_context_save(&THREAD->fpu_context); 374 #endif 393 fpu_cleanup(); 394 375 395 if (!context_save(&THREAD->saved_context)) { 376 396 /*
Note:
See TracChangeset
for help on using the changeset viewer.