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

Macros

#define STACKSIZE   1024
 
#define DEFINE_PARTICIPANT_THREAD(id)
 
#define PARTICIPANT_THREAD_OPTIONS   (0)
 
#define CREATE_PARTICIPANT_THREAD(id, pri, entry)
 
#define START_PARTICIPANT_THREAD(id)   k_thread_start(&(thread_##id##_thread_data));
 
#define JOIN_PARTICIPANT_THREAD(id)   k_thread_join(&(thread_##id##_thread_data), K_FOREVER);
 
#define WAIT_MS   10 /* Time to wait/sleep between actions */
 
#define LOOP_CNT   4 /* Number of times low priority thread waits */
 

Functions

 K_SEM_DEFINE (metairq_sem, 0, 1)
 
 K_SEM_DEFINE (coop_sem1, 0, 1)
 
 K_SEM_DEFINE (coop_sem2, 0, 1)
 
void metairq_thread (void *p1, void *p2, void *p3)
 
void coop_thread1 (void *p1, void *p2, void *p3)
 
void coop_thread2 (void *p1, void *p2, void *p3)
 
 K_THREAD_STACK_DEFINE (thread_metairq_thread_id_stack_area, 1024)
 
 K_THREAD_STACK_DEFINE (thread_coop_thread1_id_stack_area, 1024)
 
 K_THREAD_STACK_DEFINE (thread_coop_thread2_id_stack_area, 1024)
 
void create_participant_threads (void)
 
void start_participant_threads (void)
 
void join_participant_threads (void)
 
 ZTEST (suite_preempt_metairq, test_preempt_metairq)
 
 ZTEST_SUITE (suite_preempt_metairq, NULL, NULL, NULL, NULL, NULL)
 

Variables

volatile int coop_cnt1
 
volatile int coop_cnt2
 
struct k_thread thread_metairq_thread_id_thread_data
 
k_tid_t thread_metairq_thread_id_tid
 
struct k_thread thread_coop_thread1_id_thread_data
 
k_tid_t thread_coop_thread1_id_tid
 
struct k_thread thread_coop_thread2_id_thread_data
 
k_tid_t thread_coop_thread2_id_tid
 

Macro Definition Documentation

◆ CREATE_PARTICIPANT_THREAD

#define CREATE_PARTICIPANT_THREAD (   id,
  pri,
  entry 
)
Value:
k_thread_create(&thread_##id##_thread_data, thread_##id##_stack_area, \
K_THREAD_STACK_SIZEOF(thread_##id##_stack_area), \
entry, \
NULL, NULL, NULL, \
#define K_FOREVER
Generate infinite timeout delay.
Definition kernel.h:1363
k_tid_t k_thread_create(struct k_thread *new_thread, k_thread_stack_t *stack, size_t stack_size, k_thread_entry_t entry, void *p1, void *p2, void *p3, int prio, uint32_t options, k_timeout_t delay)
Create a thread.
#define K_THREAD_STACK_SIZEOF(sym)
Return the size in bytes of a stack memory region.
Definition thread_stack.h:437
#define PARTICIPANT_THREAD_OPTIONS
Definition main.c:78

◆ DEFINE_PARTICIPANT_THREAD

#define DEFINE_PARTICIPANT_THREAD (   id)
Value:
K_THREAD_STACK_DEFINE(thread_##id##_stack_area, STACKSIZE); \
struct k_thread thread_##id##_thread_data; \
k_tid_t thread_##id##_tid;
#define K_THREAD_STACK_DEFINE(sym, size)
Define a toplevel thread stack memory region.
Definition thread_stack.h:517
#define STACKSIZE
Definition main.c:53
Thread Structure.
Definition thread.h:259

◆ JOIN_PARTICIPANT_THREAD

#define JOIN_PARTICIPANT_THREAD (   id)    k_thread_join(&(thread_##id##_thread_data), K_FOREVER);

◆ LOOP_CNT

#define LOOP_CNT   4 /* Number of times low priority thread waits */

◆ PARTICIPANT_THREAD_OPTIONS

#define PARTICIPANT_THREAD_OPTIONS   (0)

◆ STACKSIZE

#define STACKSIZE   1024

◆ START_PARTICIPANT_THREAD

#define START_PARTICIPANT_THREAD (   id)    k_thread_start(&(thread_##id##_thread_data));

◆ WAIT_MS

#define WAIT_MS   10 /* Time to wait/sleep between actions */

Function Documentation

◆ coop_thread1()

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

◆ coop_thread2()

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

◆ create_participant_threads()

void create_participant_threads ( void  )

◆ join_participant_threads()

void join_participant_threads ( void  )

◆ K_SEM_DEFINE() [1/3]

K_SEM_DEFINE ( coop_sem1  ,
,
 
)

◆ K_SEM_DEFINE() [2/3]

K_SEM_DEFINE ( coop_sem2  ,
,
 
)

◆ K_SEM_DEFINE() [3/3]

K_SEM_DEFINE ( metairq_sem  ,
,
 
)

◆ K_THREAD_STACK_DEFINE() [1/3]

K_THREAD_STACK_DEFINE ( thread_coop_thread1_id_stack_area  ,
1024   
)

◆ K_THREAD_STACK_DEFINE() [2/3]

K_THREAD_STACK_DEFINE ( thread_coop_thread2_id_stack_area  ,
1024   
)

◆ K_THREAD_STACK_DEFINE() [3/3]

K_THREAD_STACK_DEFINE ( thread_metairq_thread_id_stack_area  ,
1024   
)

◆ metairq_thread()

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

◆ start_participant_threads()

void start_participant_threads ( void  )

◆ ZTEST()

ZTEST ( suite_preempt_metairq  ,
test_preempt_metairq   
)

◆ ZTEST_SUITE()

ZTEST_SUITE ( suite_preempt_metairq  ,
NULL  ,
NULL  ,
NULL  ,
NULL  ,
NULL   
)

Variable Documentation

◆ coop_cnt1

volatile int coop_cnt1

◆ coop_cnt2

volatile int coop_cnt2

◆ thread_coop_thread1_id_thread_data

struct k_thread thread_coop_thread1_id_thread_data

◆ thread_coop_thread1_id_tid

k_tid_t thread_coop_thread1_id_tid

◆ thread_coop_thread2_id_thread_data

struct k_thread thread_coop_thread2_id_thread_data

◆ thread_coop_thread2_id_tid

k_tid_t thread_coop_thread2_id_tid

◆ thread_metairq_thread_id_thread_data

struct k_thread thread_metairq_thread_id_thread_data

◆ thread_metairq_thread_id_tid

k_tid_t thread_metairq_thread_id_tid