Changeset 286da52 in mainline for kernel/generic/src/proc/thread.c


Ignore:
Timestamp:
2024-01-20T15:56:45Z (4 months ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master
Children:
efed95a3
Parents:
6a0e568
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2023-03-27 17:37:59)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2024-01-20 15:56:45)
Message:

Streamline requeuing threads

Split thread_ready() into different functions for different circumstances,
since they can be simplified after.

File:
1 edited

Legend:

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

    r6a0e568 r286da52  
    210210{
    211211        assert(thread->state == Entering);
    212         thread_ready(thread_ref(thread));
    213 }
    214 
    215 /** Make thread ready
    216  *
    217  * Switch thread to the ready state. Consumes reference passed by the caller.
    218  *
    219  * @param thread Thread to make ready.
    220  *
    221  */
    222 void thread_ready(thread_t *thread)
    223 {
    224         // TODO: move this to scheduler.c
    225         irq_spinlock_lock(&thread->lock, true);
    226 
    227         assert(thread->state != Ready);
    228 
    229         int i = (thread->priority < RQ_COUNT - 1) ?
    230             ++thread->priority : thread->priority;
    231 
    232         /* Prefer the CPU on which the thread ran last */
    233         cpu_t *cpu = thread->cpu ? thread->cpu : CPU;
    234 
    235         thread->state = Ready;
    236 
    237         irq_spinlock_pass(&thread->lock, &(cpu->rq[i].lock));
    238 
    239         /*
    240          * Append thread to respective ready queue
    241          * on respective processor.
    242          */
    243 
    244         list_append(&thread->rq_link, &cpu->rq[i].rq);
    245         cpu->rq[i].n++;
    246         irq_spinlock_unlock(&(cpu->rq[i].lock), true);
    247 
    248         atomic_inc(&nrdy);
    249         atomic_inc(&cpu->nrdy);
     212        thread_requeue_sleeping(thread_ref(thread));
    250213}
    251214
     
    613576                 * the waking thread by the sleeper in thread_wait_finish().
    614577                 */
    615                 thread_ready(thread);
     578                thread_requeue_sleeping(thread);
    616579        }
    617580}
     
    10641027                thread_attach(thread, TASK);
    10651028#endif
    1066                 thread_ready(thread);
     1029                thread_start(thread);
     1030                thread_put(thread);
    10671031
    10681032                return 0;
Note: See TracChangeset for help on using the changeset viewer.