Changeset dc5c303 in mainline for kernel/generic/src/proc/thread.c
- Timestamp:
- 2023-12-28T13:59:23Z (2 years ago)
- Children:
- 6b66de6b
- Parents:
- 42c2e65 (diff), f87ff8e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - git-author:
- boba-buba <120932204+boba-buba@…> (2023-12-28 13:59:23)
- git-committer:
- GitHub <noreply@…> (2023-12-28 13:59:23)
- File:
-
- 1 edited
-
kernel/generic/src/proc/thread.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/proc/thread.c
r42c2e65 rdc5c303 62 62 #include <arch/faddr.h> 63 63 #include <atomic.h> 64 #include <mem .h>64 #include <memw.h> 65 65 #include <stdio.h> 66 66 #include <stdlib.h> … … 231 231 irq_spinlock_lock(&thread->lock, true); 232 232 thread->cpu = cpu; 233 thread-> wired = true;233 thread->nomigrate++; 234 234 irq_spinlock_unlock(&thread->lock, true); 235 235 } … … 259 259 ++thread->priority : thread->priority; 260 260 261 cpu_t *cpu; 262 if (thread->wired || thread->nomigrate || thread->fpu_context_engaged) { 263 /* Cannot ready to another CPU */ 264 assert(thread->cpu != NULL); 265 cpu = thread->cpu; 266 } else if (thread->stolen) { 267 /* Ready to the stealing CPU */ 268 cpu = CPU; 269 } else if (thread->cpu) { 270 /* Prefer the CPU on which the thread ran last */ 271 assert(thread->cpu != NULL); 272 cpu = thread->cpu; 273 } else { 274 cpu = CPU; 275 } 261 /* Prefer the CPU on which the thread ran last */ 262 cpu_t *cpu = thread->cpu ? thread->cpu : CPU; 276 263 277 264 thread->state = Ready; … … 348 335 thread->priority = -1; /* Start in rq[0] */ 349 336 thread->cpu = NULL; 350 thread->wired = false;351 337 thread->stolen = false; 352 338 thread->uspace = … … 369 355 370 356 thread->fpu_context_exists = false; 371 thread->fpu_context_engaged = false;372 357 373 358 odlink_initialize(&thread->lthreads); … … 426 411 427 412 assert((thread->state == Exiting) || (thread->state == Lingering)); 428 assert(thread->cpu);429 413 430 414 /* Clear cpu->fpu_owner if set to this thread. */ 431 irq_spinlock_lock(&thread->cpu->lock, false); 432 if (thread->cpu->fpu_owner == thread) 433 thread->cpu->fpu_owner = NULL; 434 irq_spinlock_unlock(&thread->cpu->lock, false); 415 #ifdef CONFIG_FPU_LAZY 416 if (thread->cpu) { 417 /* 418 * We need to lock for this because the old CPU can concurrently try 419 * to dump this thread's FPU state, in which case we need to wait for 420 * it to finish. An atomic compare-and-swap wouldn't be enough. 421 */ 422 irq_spinlock_lock(&thread->cpu->fpu_lock, false); 423 424 thread_t *owner = atomic_load_explicit(&thread->cpu->fpu_owner, 425 memory_order_relaxed); 426 427 if (owner == thread) { 428 atomic_store_explicit(&thread->cpu->fpu_owner, NULL, 429 memory_order_relaxed); 430 } 431 432 irq_spinlock_unlock(&thread->cpu->fpu_lock, false); 433 } 434 #endif 435 435 436 436 interrupts_restore(ipl);
Note:
See TracChangeset
for help on using the changeset viewer.
