Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
spinlock_fairness.c File Reference
#include "zephyr/ztest_test.h"
#include <zephyr/kernel.h>
#include <zephyr/ztest.h>
#include <zephyr/spinlock.h>

Macros

#define STACK_SIZE   (8 * 1024)
 
#define CORES_NUM   CONFIG_MP_MAX_NUM_CPUS
 
#define FAIRNESS_TEST_CYCLES_PER_CORE   1000
 

Functions

static K_THREAD_STACK_ARRAY_DEFINE (tstack, CONFIG_MP_MAX_NUM_CPUS,(8 *1024))
 
static struct k_threadget_thread (uint8_t core_id)
 
static void test_thread (void *arg1, void *arg2, void *arg3)
 Execution thread which runs concurrently on each CPU in the system.
 
static void test_init (void)
 
 ZTEST (spinlock, test_spinlock_fairness)
 Test spinlock acquisition fairness.
 

Variables

static struct k_thread tthread [CONFIG_MP_MAX_NUM_CPUS]
 
static uint32_t spinlock_grabbed [CONFIG_MP_MAX_NUM_CPUS]
 
static atomic_t fairness_test_cycles
 
static struct k_spinlock lock
 
static atomic_t start_sync
 

Macro Definition Documentation

◆ CORES_NUM

#define CORES_NUM   CONFIG_MP_MAX_NUM_CPUS

◆ FAIRNESS_TEST_CYCLES_PER_CORE

#define FAIRNESS_TEST_CYCLES_PER_CORE   1000

◆ STACK_SIZE

#define STACK_SIZE   (8 * 1024)

Function Documentation

◆ get_thread()

static struct k_thread * get_thread ( uint8_t  core_id)
inlinestatic

◆ K_THREAD_STACK_ARRAY_DEFINE()

static K_THREAD_STACK_ARRAY_DEFINE ( tstack  ,
CONFIG_MP_MAX_NUM_CPUS  ,
(8 *1024)   
)
static

◆ test_init()

static void test_init ( void  )
static

◆ test_thread()

static void test_thread ( void *  arg1,
void *  arg2,
void *  arg3 
)
static

Execution thread which runs concurrently on each CPU in the system.

Parameters
[in]arg1- thread argument 1
[in]arg2- thread argument 2
[in]arg3- thread argument 3

Variable Documentation

◆ fairness_test_cycles

atomic_t fairness_test_cycles
static

◆ lock

struct k_spinlock lock
static

◆ spinlock_grabbed

uint32_t spinlock_grabbed[CONFIG_MP_MAX_NUM_CPUS]
static

◆ start_sync

atomic_t start_sync
static

◆ tthread

struct k_thread tthread[CONFIG_MP_MAX_NUM_CPUS]
static