Changeset c1eaec4 in mainline


Ignore:
Timestamp:
2024-01-19T16:21:20Z (6 months ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master
Children:
6a0e568
Parents:
25939997
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-19 10:27:42)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2024-01-19 16:21:20)
Message:

Shuffle some locks around

Location:
kernel/generic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/cpu.h

    r25939997 rc1eaec4  
    7676
    7777        context_t scheduler_context;
     78
     79        state_t exiting_state;
    7880} cpu_local_t;
    7981
  • kernel/generic/src/proc/scheduler.c

    r25939997 rc1eaec4  
    361361        /* Save current CPU cycle */
    362362        THREAD->last_cycle = get_cycle();
     363
     364        irq_spinlock_unlock(&THREAD->lock, false);
    363365}
    364366
     
    440442        }
    441443
    442         /*
    443          * Through the 'CURRENT' structure, we keep track of THREAD, TASK, CPU, AS
    444          * and preemption counter. At this point CURRENT could be coming either
    445          * from THREAD's or CPU's stack.
    446          *
    447          */
     444        irq_spinlock_unlock(&THREAD->lock, false);
     445
     446        CPU_LOCAL->exiting_state = new_state;
    448447
    449448        current_copy(CURRENT, (current_t *) CPU_LOCAL->stack);
    450449        context_swap(&THREAD->saved_context, &CPU_LOCAL->scheduler_context);
    451450
    452         irq_spinlock_unlock(&THREAD->lock, false);
     451        assert(CURRENT->mutex_locks == 0);
     452        assert(interrupts_disabled());
     453
    453454        interrupts_restore(ipl);
    454455}
     
    476477                int rq_index;
    477478                THREAD = find_best_thread(&rq_index);
    478 
    479479                prepare_to_run_thread(rq_index);
    480480
     
    488488                context_swap(&CPU_LOCAL->scheduler_context, &THREAD->saved_context);
    489489
    490                 /* Back from the thread. */
    491 
     490                /* Back from another thread. */
    492491                assert(CPU != NULL);
    493492                assert(THREAD != NULL);
    494                 assert(irq_spinlock_locked(&THREAD->lock));
     493                assert(CURRENT->mutex_locks == 0);
    495494                assert(interrupts_disabled());
    496495
    497                 state_t state = THREAD->state;
    498                 irq_spinlock_unlock(&THREAD->lock, false);
    499 
    500                 cleanup_after_thread(THREAD, state);
     496                cleanup_after_thread(THREAD, CPU_LOCAL->exiting_state);
    501497
    502498                /*
  • kernel/generic/src/proc/thread.c

    r25939997 rc1eaec4  
    122122
    123123        /* This is where each thread wakes up after its creation */
    124         irq_spinlock_unlock(&THREAD->lock, false);
    125124        interrupts_enable();
    126125
Note: See TracChangeset for help on using the changeset viewer.