kernel: SMP-aware scheduler
The scheduler needs a few tweaks to work in SMP mode: 1. The "cache" field just doesn't work. With more than one CPU, caching the highest priority thread isn't useful as you may need N of them at any given time before another thread is returned to the scheduler. You could recalculate it at every change, but that provides no performance benefit. Remove. 2. The "bitmask" designed to prevent the need to individually check priorities is likewise dropped. This could work, but in fact on our only current SMP system and with current K_NUM_PRIOPRITIES values it provides no real benefit. 3. The individual threads now have a "current cpu" and "active" flag so that the choice of the next thread to run can correctly skip threads that are active on other CPUs. The upshot is that a decent amount of code gets #if'd out, and the new SMP implementations for _get_highest_ready_prio() and _get_next_ready_thread() are simpler and smaller, at the expense of having to drop older optimizations. Note that scheduler synchronization is unchanged: all scheduler APIs used to require that an irq_lock() be held, which means that they now require the global spinlock via the same API. This should be a very early candidate for lock granularity attention! Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
364cbae412
commit
2724fd11cb
7 changed files with 99 additions and 6 deletions
|
@ -392,6 +392,17 @@ struct _thread_base {
|
|||
u16_t preempt;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
/* True for the per-CPU idle threads */
|
||||
u8_t is_idle;
|
||||
|
||||
/* Non-zero when actively running on a CPU */
|
||||
u8_t active;
|
||||
|
||||
/* CPU index on which thread was last run */
|
||||
u8_t cpu;
|
||||
#endif
|
||||
|
||||
/* data returned by APIs */
|
||||
void *swap_data;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue