Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Atomic Operations

Functions

void test_atomic (void)
 Verify atomic functionalities.
 
void atomic_handler (void *p1, void *p2, void *p3)
 
void test_threads_access_atomic (void)
 Verify atomic operation with threads.
 
void test_atomic_overflow (void)
 Checks that the value of atomic_t will be the same in case of overflow if incremented in atomic and non-atomic manner.
 

Detailed Description

Function Documentation

◆ atomic_handler()

void atomic_handler ( void * p1,
void * p2,
void * p3 )

◆ test_atomic()

void test_atomic ( void )

#include </home/runner/work/safety-doc/zephyr/tests/kernel/common/src/atomic.c>

Verify atomic functionalities.

Test Objective:

  • Test the function of the atomic operation API is correct.

Test techniques:

  • Dynamic analysis and testing
  • Functional and black box testing
  • Interface testing

Prerequisite Conditions:

  • N/A

Input Specifications:

  • N/A

Test Procedure:

  1. Call the API interface of the following atomic operations in turn, judge the change of function return value and target operands.

Expected Test Result:

  • The change of function return value and target operands is correct.

Pass/Fail Criteria:

  • Successful if check points in test procedure are all passed, otherwise failure.

Assumptions and Constraints:

  • N/A
See also
atomic_cas(), atomic_add(), atomic_sub(), atomic_inc(), atomic_dec(), atomic_get(), atomic_set(), atomic_clear(), atomic_or(), atomic_and(), atomic_xor(), atomic_nand(), atomic_test_bit(), atomic_test_and_clear_bit(), atomic_test_and_set_bit(), atomic_clear_bit(), atomic_set_bit(), ATOMIC_DEFINE

◆ test_atomic_overflow()

void test_atomic_overflow ( void )

#include </home/runner/work/safety-doc/zephyr/tests/kernel/common/src/atomic.c>

Checks that the value of atomic_t will be the same in case of overflow if incremented in atomic and non-atomic manner.

According to C standard the value of a signed variable is undefined in case of overflow. This test checks that the value of atomic_t will be the same in case of overflow if incremented in atomic and non-atomic manner. This allows us to increment an atomic variable in a non-atomic manner (as long as it is logically safe) and expect its value to match the result of the similar atomic increment.

◆ test_threads_access_atomic()

void test_threads_access_atomic ( void )

#include </home/runner/work/safety-doc/zephyr/tests/kernel/common/src/atomic.c>

Verify atomic operation with threads.

Creat two preempt threads with equal priority to atomically access the same atomic value. Because these preempt threads are of equal priority, so enable time slice to make them scheduled. The thread will execute for some time. In this time, the two sub threads will be scheduled separately according to the time slice.