kernel: Begin abstracting out _sched_spinlock

In a uniprocessor system, _sched_spinlock may not need to be
held in all the same cases that it does in a multiprocessor
system. Removing those unnecessary usages can lead to better
performance on UP systems. In the case of uncontested taking
and giving of a semaphore, this can be as much as a +14%
performance gain.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This commit is contained in:
Peter Mitsis 2024-10-17 13:37:04 -07:00 committed by Maureen Helm
commit cedd36106b
2 changed files with 20 additions and 1 deletions

View file

@ -106,7 +106,10 @@ int main(void)
uint64_t tot = 0U;
uint32_t runs = 0U;
int key;
for (int i = 0; i < N_RUNS + N_SETTLE; i++) {
key = arch_irq_lock();
stamp(UNPENDING);
z_unpend_first_thread(&waitq);
stamp(UNPENDED_READYING);
@ -121,6 +124,7 @@ int main(void)
*/
k_yield();
stamp(YIELDED);
arch_irq_unlock(key);
uint32_t avg, whole = stamps[4] - stamps[0];