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
|
@ -66,12 +66,13 @@
|
|||
#if !defined(_ASMLANGUAGE)
|
||||
|
||||
struct _ready_q {
|
||||
|
||||
#ifndef CONFIG_SMP
|
||||
/* always contains next thread to run: cannot be NULL */
|
||||
struct k_thread *cache;
|
||||
|
||||
/* bitmap of priorities that contain at least one ready thread */
|
||||
u32_t prio_bmap[K_NUM_PRIO_BITMAPS];
|
||||
#endif
|
||||
|
||||
/* ready queues, one per priority */
|
||||
sys_dlist_t q[K_NUM_PRIORITIES];
|
||||
|
@ -88,6 +89,8 @@ struct _cpu {
|
|||
|
||||
/* currently scheduled thread */
|
||||
struct k_thread *current;
|
||||
|
||||
int id;
|
||||
};
|
||||
|
||||
typedef struct _cpu _cpu_t;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue