unified: cache the next thread to run
When adding a thread to the ready queue, it is often known at that time if the thread added will be the next one to run or not. So, instead of simply updating the ready queues and the bitmask, also cache what that thread is, so that when the scheduler is invoked, it can simply fetch it from there. This is only done if there is a thread in the cache, since the way the cache is updated is by comparing the priorities of the thread being added and the cached thread. When a thread is removed from the ready queue, if it is currently the cached thread, it is also removed from the cache. The cache is not updated at this time, since this would be a preemptive fetching that could be overriden before the newly cached thread would even be scheduled in. Finally, when a thread is scheduled in, it now becomes the cached thread since the fact that it is running means that by definition it was the next one to run. Doing this can speed up considerably some context switch times, especially when a thread is preempted by an interrupt and the same thread is scheduled when the interrupt exits. Change-Id: I6dc8391cfca566699bb9b217eafe6bc6a063c8bb Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
This commit is contained in:
parent
7bc86c0344
commit
35497d6c5e
5 changed files with 67 additions and 8 deletions
|
@ -32,6 +32,7 @@ extern void k_sched_unlock(void);
|
|||
extern void _pend_thread(struct tcs *thread,
|
||||
_wait_q_t *wait_q, int32_t timeout);
|
||||
extern void _pend_current_thread(_wait_q_t *wait_q, int32_t timeout);
|
||||
extern void _move_thread_to_end_of_prio_q(struct k_thread *thread);
|
||||
extern struct tcs *_get_next_ready_thread(void);
|
||||
extern int __must_switch_threads(void);
|
||||
extern void k_thread_priority_set(struct tcs *thread, int32_t priority);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue