Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Spinlock Tests

Tests for spinlock. More...

Functions

 ZTEST (spinlock, test_spinlock_basic)
 Test basic spinlock.
 
 ZTEST (spinlock, test_spinlock_bounce)
 Test spinlock with bounce.
 
 ZTEST (spinlock, test_spinlock_mutual_exclusion)
 Test basic mutual exclusion using interrupt masking.
 
 ZTEST (spinlock, test_trylock)
 Test k_spin_trylock()
 
 ZTEST (spinlock, test_spinlock_no_recursive)
 Test spinlock cannot be recursive.
 
 ZTEST (spinlock, test_spinlock_unlock_error)
 Test unlocking incorrect spinlock.
 
 ZTEST (spinlock, test_spinlock_release_error)
 Test unlocking incorrect spinlock.
 
 ZTEST (spinlock, test_spinlock_lock_time_limit)
 Test unlocking spinlock held over the time limit.
 
 ZTEST (spinlock, test_spinlock_fairness)
 Test spinlock acquisition fairness.
 

Detailed Description

Tests for spinlock.

Function Documentation

◆ ZTEST() [1/9]

ZTEST ( spinlock  ,
test_spinlock_basic   
)

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

Test basic spinlock.

See also
k_spin_lock(), k_spin_unlock()

◆ ZTEST() [2/9]

ZTEST ( spinlock  ,
test_spinlock_bounce   
)

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

Test spinlock with bounce.

See also
arch_cpu_start()

◆ ZTEST() [3/9]

ZTEST ( spinlock  ,
test_spinlock_fairness   
)

#include <tests/kernel/spinlock/src/spinlock_fairness.c>

Test spinlock acquisition fairness.

This test verifies a spinlock acquisition fairness in relation to the cores contending for the spinlock. Memory access latency may vary between the CPU cores, so that some CPUs reach the spinlock faster than the others and depending on spinlock implementation may get higher chance to win the contention for the spinlock than the other cores, making them to starve. This effect may become critical for some real-life platforms (e.g. NUMA) resulting in performance loss or even a live-lock, when a single CPU is continuously winning the contention. This test ensures that the probability to win the contention for a spinlock is evenly distributed between all of the contending cores.

See also
k_spin_lock(), k_spin_unlock()

◆ ZTEST() [4/9]

ZTEST ( spinlock  ,
test_spinlock_lock_time_limit   
)

#include <tests/kernel/spinlock/src/spinlock_error_case.c>

Test unlocking spinlock held over the time limit.

Validate unlocking spinlock held past the time limit will trigger assertion.

See also
k_spin_unlock()

◆ ZTEST() [5/9]

ZTEST ( spinlock  ,
test_spinlock_mutual_exclusion   
)

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

Test basic mutual exclusion using interrupt masking.

  • Spinlocks can be initialized at run-time.
  • Spinlocks in uniprocessor context should achieve mutual exclusion using interrupt masking.
See also
k_spin_lock(), k_spin_unlock()

◆ ZTEST() [6/9]

ZTEST ( spinlock  ,
test_spinlock_no_recursive   
)

#include <tests/kernel/spinlock/src/spinlock_error_case.c>

Test spinlock cannot be recursive.

Validate using spinlock recursive will trigger assertion.

See also
k_spin_lock()

◆ ZTEST() [7/9]

ZTEST ( spinlock  ,
test_spinlock_release_error   
)

#include <tests/kernel/spinlock/src/spinlock_error_case.c>

Test unlocking incorrect spinlock.

Validate unlocking incorrect spinlock will trigger assertion.

See also
k_spin_release()

◆ ZTEST() [8/9]

ZTEST ( spinlock  ,
test_spinlock_unlock_error   
)

#include <tests/kernel/spinlock/src/spinlock_error_case.c>

Test unlocking incorrect spinlock.

Validate unlocking incorrect spinlock will trigger assertion.

See also
k_spin_unlock()

◆ ZTEST() [9/9]

ZTEST ( spinlock  ,
test_trylock   
)