Zephyr Project API  3.3.0
A Scalable Open Source RTOS
SMP Tests

SMP. More...

Modules

 SMP Integration Tests
 
 SMP Module Tests
 

Functions

 ZTEST (smp, test_smp_coop_threads)
 Verify SMP with 2 cooperative threads. More...
 
 ZTEST (smp, test_cpu_id_threads)
 Verify CPU IDs of threads in SMP. More...
 
 ZTEST (smp, test_coop_resched_threads)
 Test cooperative threads non-preemption. More...
 
 ZTEST (smp, test_preempt_resched_threads)
 Test preemptness of preemptive thread. More...
 
 ZTEST (smp, test_yield_threads)
 Validate behavior of thread when it yields. More...
 
 ZTEST (smp, test_sleep_threads)
 Test behavior of thread when it sleeps. More...
 
 ZTEST (smp, test_wakeup_threads)
 Test behavior of wakeup() in SMP case. More...
 
 ZTEST (smp, test_smp_release_global_lock)
 Test scenario that a thread release the global lock. More...
 
 ZTEST (smp, test_inc_concurrency)
 Test if the concurrency of SMP works or not. More...
 
static void process_events (void *arg0, void *arg1, void *arg2)
 Torture test for context switching code. More...
 

Detailed Description

SMP.

Function Documentation

◆ process_events()

static void process_events ( void *  arg0,
void *  arg1,
void *  arg2 
)
static

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

Torture test for context switching code.

Leverage the polling API to stress test the context switching code. This test will hammer all the CPUs with thread swapping requests.

◆ ZTEST() [1/9]

ZTEST ( smp  ,
test_coop_resched_threads   
)

#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.

◆ ZTEST() [2/9]

ZTEST ( smp  ,
test_cpu_id_threads   
)

#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

◆ ZTEST() [3/9]

ZTEST ( smp  ,
test_inc_concurrency   
)

#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 different 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 scenario:

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

◆ ZTEST() [4/9]

ZTEST ( smp  ,
test_preempt_resched_threads   
)

#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

◆ ZTEST() [5/9]

ZTEST ( smp  ,
test_sleep_threads   
)

#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.

◆ ZTEST() [6/9]

ZTEST ( smp  ,
test_smp_coop_threads   
)

#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

◆ ZTEST() [7/9]

ZTEST ( smp  ,
test_smp_release_global_lock   
)

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

Test scenario 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.

◆ ZTEST() [8/9]

ZTEST ( smp  ,
test_wakeup_threads   
)

#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

◆ ZTEST() [9/9]

ZTEST ( smp  ,
test_yield_threads   
)

#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