Changeset d23712e in mainline for kernel/generic/src/proc/scheduler.c


Ignore:
Timestamp:
2024-01-21T16:23:24Z (17 months ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
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)
Message:

Use thread state variable instead of a cpu local variable to pass state

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/proc/scheduler.c

    rdfa4be62 rd23712e  
    383383static void thread_requeue_preempted(thread_t *thread)
    384384{
     385        assert(interrupts_disabled());
    385386        assert(atomic_get_unordered(&thread->state) == Running);
    386387        assert(atomic_get_unordered(&thread->cpu) == CPU);
     
    420421}
    421422
    422 static void cleanup_after_thread(thread_t *thread, state_t out_state)
     423static void cleanup_after_thread(thread_t *thread)
    423424{
    424425        assert(CURRENT->mutex_locks == 0);
     
    427428        int expected;
    428429
    429         switch (out_state) {
     430        switch (atomic_get_unordered(&thread->state)) {
    430431        case Running:
    431432                thread_requeue_preempted(thread);
     
    462463                 */
    463464                panic("tid%" PRIu64 ": unexpected state %s.",
    464                     thread->tid, thread_states[out_state]);
     465                    thread->tid, thread_states[atomic_get_unordered(&thread->state)]);
    465466                break;
    466467        }
     
    501502         */
    502503        after_thread_ran_arch();
    503 
    504         CPU_LOCAL->exiting_state = new_state;
    505504
    506505        if (new_thread) {
     
    527526        /* Check if we need to clean up after another thread. */
    528527        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);
    530529                CPU_LOCAL->prev_thread = NULL;
    531530        }
     
    573572                assert(interrupts_disabled());
    574573
    575                 cleanup_after_thread(THREAD, CPU_LOCAL->exiting_state);
     574                cleanup_after_thread(THREAD);
    576575
    577576                /*
     
    601600        /* Check if we need to clean up after another thread. */
    602601        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);
    604603                CPU_LOCAL->prev_thread = NULL;
    605604        }
Note: See TracChangeset for help on using the changeset viewer.