Changeset d23712e in mainline
- Timestamp:
- 2024-01-21T16:23:24Z (11 months ago)
- Branches:
- master
- Children:
- a5b5f17
- Parents:
- dfa4be62
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2024-01-20 18:01:21)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2024-01-21 16:23:24)
- Location:
- kernel/generic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/cpu.h
rdfa4be62 rd23712e 78 78 79 79 struct thread *prev_thread; 80 state_t exiting_state;81 80 } cpu_local_t; 82 81 -
kernel/generic/include/proc/thread.h
rdfa4be62 rd23712e 193 193 bool stolen; 194 194 195 /** Thread state. */ 195 /** 196 * Thread state (state_t). 197 * This is atomic because we read it via some commands for debug output, 198 * otherwise it could just be a regular local. 199 */ 196 200 atomic_int_fast32_t state; 197 201 -
kernel/generic/src/proc/scheduler.c
rdfa4be62 rd23712e 383 383 static void thread_requeue_preempted(thread_t *thread) 384 384 { 385 assert(interrupts_disabled()); 385 386 assert(atomic_get_unordered(&thread->state) == Running); 386 387 assert(atomic_get_unordered(&thread->cpu) == CPU); … … 420 421 } 421 422 422 static void cleanup_after_thread(thread_t *thread , state_t out_state)423 static void cleanup_after_thread(thread_t *thread) 423 424 { 424 425 assert(CURRENT->mutex_locks == 0); … … 427 428 int expected; 428 429 429 switch ( out_state) {430 switch (atomic_get_unordered(&thread->state)) { 430 431 case Running: 431 432 thread_requeue_preempted(thread); … … 462 463 */ 463 464 panic("tid%" PRIu64 ": unexpected state %s.", 464 thread->tid, thread_states[ out_state]);465 thread->tid, thread_states[atomic_get_unordered(&thread->state)]); 465 466 break; 466 467 } … … 501 502 */ 502 503 after_thread_ran_arch(); 503 504 CPU_LOCAL->exiting_state = new_state;505 504 506 505 if (new_thread) { … … 527 526 /* Check if we need to clean up after another thread. */ 528 527 if (CPU_LOCAL->prev_thread) { 529 cleanup_after_thread(CPU_LOCAL->prev_thread , CPU_LOCAL->exiting_state);528 cleanup_after_thread(CPU_LOCAL->prev_thread); 530 529 CPU_LOCAL->prev_thread = NULL; 531 530 } … … 573 572 assert(interrupts_disabled()); 574 573 575 cleanup_after_thread(THREAD , CPU_LOCAL->exiting_state);574 cleanup_after_thread(THREAD); 576 575 577 576 /* … … 601 600 /* Check if we need to clean up after another thread. */ 602 601 if (CPU_LOCAL->prev_thread) { 603 cleanup_after_thread(CPU_LOCAL->prev_thread , CPU_LOCAL->exiting_state);602 cleanup_after_thread(CPU_LOCAL->prev_thread); 604 603 CPU_LOCAL->prev_thread = NULL; 605 604 }
Note:
See TracChangeset
for help on using the changeset viewer.