Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
SMP Tests

Tests for SMP. More...

Functions

void test_smp_coop_threads (void)
 Verify SMP with 2 cooperative threads. More...
 
void test_cpu_id_threads (void)
 Verify CPU IDs of threads in SMP. More...
 
void test_coop_resched_threads (void)
 Test cooperative threads non-preemption. More...
 
void test_preempt_resched_threads (void)
 Test preemptness of preemptive thread. More...
 
void test_yield_threads (void)
 Validate behavior of thread when it yields. More...
 
void test_sleep_threads (void)
 Test behavior of thread when it sleeps. More...
 
void test_wakeup_threads (void)
 Test behavior of wakeup() in SMP case. More...
 
void test_smp_release_global_lock (void)
 Test scenairo that a thread release the global lock. More...
 
void test_inc_concurrency (void)
 Test if the concurrency of SMP works or not. More...
 

Detailed Description

Tests for SMP.

Function Documentation

◆ test_coop_resched_threads()

void test_coop_resched_threads ( void  )

#include <tests/kernel/smp/src/main.c>

Test cooperative threads non-preemption.

Spawn cooperative threads equal to number of cores supported. Main thread will already be running on 1 core. Check if the last thread created preempts any threads already running.

◆ test_cpu_id_threads()

void test_cpu_id_threads ( void  )

#include <tests/kernel/smp/src/main.c>

Verify CPU IDs of threads in SMP.

Verify whether thread running on other core is parent thread from child thread

◆ test_inc_concurrency()

void test_inc_concurrency ( void  )

#include <tests/kernel/smp/src/main.c>

Test if the concurrency of SMP works or not.

Validate the global lock and unlock API of SMP are thread-safe. We make 3 thread to increase the global count in differenet cpu and they both do locking then unlocking for LOOP_COUNT times. It shall be no deadlock happened and total global count shall be 3 * LOOP COUNT.

We show the 4 kinds of scenairo:

  • No any lock used
  • Use global irq lock
  • Use semaphore
  • Use mutex

◆ test_preempt_resched_threads()

void test_preempt_resched_threads ( void  )

#include <tests/kernel/smp/src/main.c>

Test preemptness of preemptive thread.

Create preemptive thread and let it run on another core and verify if it gets preempted if another thread of higher priority is spawned

◆ test_sleep_threads()

void test_sleep_threads ( void  )

#include <tests/kernel/smp/src/main.c>

Test behavior of thread when it sleeps.

Spawn cooperative thread and call sleep() from main thread. After timeout, all threads has to be scheduled.

◆ test_smp_coop_threads()

void test_smp_coop_threads ( void  )

#include <tests/kernel/smp/src/main.c>

Verify SMP with 2 cooperative threads.

Multi processing is verified by checking whether 2 cooperative threads run simultaneously at different cores

◆ test_smp_release_global_lock()

void test_smp_release_global_lock ( void  )

#include <tests/kernel/smp/src/main.c>

Test scenairo that a thread release the global lock.

Validate the scenario that make the internal APIs of SMP z_smp_release_global_lock() to be called.

◆ test_wakeup_threads()

void test_wakeup_threads ( void  )

#include <tests/kernel/smp/src/main.c>

Test behavior of wakeup() in SMP case.

Spawn number of threads equal to number of remaining cores and let them sleep for a while. Call wakeup() of those threads from parent thread and check if they are all running

◆ test_yield_threads()

void test_yield_threads ( void  )

#include <tests/kernel/smp/src/main.c>

Validate behavior of thread when it yields.

Spawn cooperative threads equal to number of cores, so last thread would be pending, call yield() from main thread. Now, all threads must be executed