Changeset 6a0e568 in mainline for kernel/generic/src/proc/thread.c


Ignore:
Timestamp:
2024-01-19T16:56:48Z (18 months ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master
Children:
286da52
Parents:
c1eaec4
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-22 18:04:40)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2024-01-19 16:56:48)
Message:

Allow fast-switch to another runnable thread

When a thread is available that can be switched to immediately
without having to block, do so without a detour through CPU
scheduler context. The new thread will handle whatever cannot
be done while the previous context is active on a CPU, such as
requeuing the thread or deallocation.

File:
1 edited

Legend:

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

    rc1eaec4 r6a0e568  
    108108static int threads_cmp(void *, void *);
    109109
    110 /** Thread wrapper.
    111  *
    112  * This wrapper is provided to ensure that every thread makes a call to
    113  * thread_exit() when its implementing function returns.
    114  *
    115  * interrupts_disable() is assumed.
    116  *
    117  */
    118 static void cushion(void)
    119 {
    120         void (*f)(void *) = THREAD->thread_code;
    121         void *arg = THREAD->thread_arg;
    122 
    123         /* This is where each thread wakes up after its creation */
    124         interrupts_enable();
    125 
    126         f(arg);
    127 
    128         thread_exit();
    129 
    130         /* Not reached */
    131 }
    132 
    133110/** Initialization and allocation for thread_t structure
    134111 *
     
    309286        irq_spinlock_unlock(&tidlock, true);
    310287
    311         context_create(&thread->saved_context, cushion, thread->kstack, STACK_SIZE);
     288        context_create(&thread->saved_context, thread_main_func,
     289            thread->kstack, STACK_SIZE);
    312290
    313291        current_initialize((current_t *) thread->kstack);
Note: See TracChangeset for help on using the changeset viewer.