Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
inherit.c File Reference
#include "mem_protect.h"
#include <syscall_handler.h>
#include <syscalls/ret_resource_pool_ptr_mrsh.c>

Functions

static void dummy_start (struct k_timer *timer)
 
static void dummy_end (struct k_timer *timer)
 
 K_THREAD_STACK_DEFINE (test_1_stack, CONFIG_MAIN_STACK_SIZE)
 
 K_THREAD_STACK_DEFINE (parent_thr_stack,(512+CONFIG_TEST_EXTRA_STACKSIZE))
 
 K_THREAD_STACK_DEFINE (child_thr_stack,(512+CONFIG_TEST_EXTRA_STACKSIZE))
 
 K_HEAP_DEFINE (heap_mem, 64 *2)
 
 K_SEM_DEFINE (inherit_sem,(0),(10))
 
 K_SEM_DEFINE (sync_sem,(0U),(1U))
 
 K_MUTEX_DEFINE (inherit_mutex)
 
 K_TIMER_DEFINE (inherit_timer, dummy_start, dummy_end)
 
 K_MSGQ_DEFINE (inherit_msgq,(10),(10),(2))
 
 K_MEM_PARTITION_DEFINE (inherit_memory_partition, inherit_buf, sizeof(inherit_buf), K_MEM_PARTITION_P_RW_U_RW)
 
static void access_test (void)
 
static void test_thread_1_for_user (void *p1, void *p2, void *p3)
 
static void test_thread_1_for_SU (void *p1, void *p2, void *p3)
 
void test_permission_inheritance (void)
 Test object permission inheritance except of the parent thread object. More...
 
void child_handler (void *p1, void *p2, void *p3)
 
void parent_handler (void *p1, void *p2, void *p3)
 
void test_inherit_resource_pool (void)
 Test child thread inherits parent's thread resource pool. More...
 

Variables

struct k_thread test_1_tid parent_thr child_thr
 
k_tid_t parent_tid
 
uint8_t inherit_buf [MEM_REGION_ALLOC]
 
struct k_mem_partitioninherit_memory_partition_array []
 
struct k_mem_domain inherit_mem_domain
 
struct k_heapchild_heap_mem_ptr
 
struct k_heapparent_heap_mem_ptr
 

Function Documentation

◆ access_test()

static void access_test ( void  )
static

◆ child_handler()

void child_handler ( void p1,
void p2,
void p3 
)

◆ dummy_end()

static void dummy_end ( struct k_timer *  timer)
inlinestatic

◆ dummy_start()

static void dummy_start ( struct k_timer *  timer)
inlinestatic

◆ K_HEAP_DEFINE()

K_HEAP_DEFINE ( heap_mem  ,
64 *  2 
)

◆ K_MEM_PARTITION_DEFINE()

K_MEM_PARTITION_DEFINE ( inherit_memory_partition  ,
inherit_buf  ,
sizeof(inherit_buf ,
K_MEM_PARTITION_P_RW_U_RW   
)

◆ K_MSGQ_DEFINE()

K_MSGQ_DEFINE ( inherit_msgq  ,
(10)  ,
(10)  ,
(2)   
)

◆ K_MUTEX_DEFINE()

K_MUTEX_DEFINE ( inherit_mutex  )

◆ K_SEM_DEFINE() [1/2]

K_SEM_DEFINE ( inherit_sem  ,
(0)  ,
(10)   
)

◆ K_SEM_DEFINE() [2/2]

K_SEM_DEFINE ( sync_sem  ,
(0U)  ,
(1U)   
)

◆ K_THREAD_STACK_DEFINE() [1/3]

K_THREAD_STACK_DEFINE ( child_thr_stack  ,
(512+CONFIG_TEST_EXTRA_STACKSIZE)   
)

◆ K_THREAD_STACK_DEFINE() [2/3]

K_THREAD_STACK_DEFINE ( parent_thr_stack  ,
(512+CONFIG_TEST_EXTRA_STACKSIZE)   
)

◆ K_THREAD_STACK_DEFINE() [3/3]

K_THREAD_STACK_DEFINE ( test_1_stack  ,
CONFIG_MAIN_STACK_SIZE   
)

◆ K_TIMER_DEFINE()

K_TIMER_DEFINE ( inherit_timer  ,
dummy_start  ,
dummy_end   
)

◆ parent_handler()

void parent_handler ( void p1,
void p2,
void p3 
)

◆ test_inherit_resource_pool()

void test_inherit_resource_pool ( void  )

Test child thread inherits parent's thread resource pool.

  • Create a memory heap heap_mem for the parent thread.
  • Then special system call ret_resource_pool_ptr() returns pointer to the resource pool of the current thread.
  • Call it in the parent_handler() and in the child_handler()
  • Then in the main test function test_inherit_resource_pool() compare returned addresses
  • If the addresses are the same, it means that child thread inherited resource pool of the parent's thread -test passed.
See also
z_thread_heap_assign()

◆ test_permission_inheritance()

void test_permission_inheritance ( void  )

Test object permission inheritance except of the parent thread object.

  • To the parent current thread grant permissions on kernel objects.
  • Create a child thread and check that it inherited permissions on that kernel objects.
  • Then check child thread can't access to the parent thread object using API command k_thread_priority_get()
  • At the same moment that test verifies that child thread was granted permission on a kernel objects. That meanis child user thread caller already has permission on the thread objects being granted.
See also
k_mem_domain_init(), k_mem_domain_add_thread(), k_thread_access_grant()

◆ test_thread_1_for_SU()

static void test_thread_1_for_SU ( void p1,
void p2,
void p3 
)
static

◆ test_thread_1_for_user()

static void test_thread_1_for_user ( void p1,
void p2,
void p3 
)
static

Variable Documentation

◆ child_heap_mem_ptr

struct k_heap* child_heap_mem_ptr

◆ child_thr

struct k_thread test_1_tid parent_thr child_thr

◆ inherit_buf

uint8_t inherit_buf[MEM_REGION_ALLOC]

◆ inherit_mem_domain

struct k_mem_domain inherit_mem_domain

◆ inherit_memory_partition_array

struct k_mem_partition* inherit_memory_partition_array[]
Initial value:
= {
&inherit_memory_partition,
}
struct k_mem_partition ztest_mem_partition

◆ parent_heap_mem_ptr

struct k_heap* parent_heap_mem_ptr

◆ parent_tid

k_tid_t parent_tid