samples: prod_consumer: don't reuse main stack for app_b
With demand paging, the main stack is not user mode capable and it would fail k_thread_user_mode_enter() under app_b_entry(). So create another thread and stack for app_b as this stack can be used in user mode. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
6a58c34aa6
commit
fa3267165c
1 changed files with 16 additions and 5 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include "app_b.h"
|
#include "app_b.h"
|
||||||
|
|
||||||
#define APP_A_STACKSIZE 2048
|
#define APP_A_STACKSIZE 2048
|
||||||
|
#define APP_B_STACKSIZE 2048
|
||||||
|
|
||||||
LOG_MODULE_REGISTER(app_main);
|
LOG_MODULE_REGISTER(app_main);
|
||||||
|
|
||||||
|
@ -45,8 +46,13 @@ K_QUEUE_DEFINE(shared_queue_outgoing);
|
||||||
struct k_thread app_a_thread;
|
struct k_thread app_a_thread;
|
||||||
K_THREAD_STACK_DEFINE(app_a_stack, APP_A_STACKSIZE);
|
K_THREAD_STACK_DEFINE(app_a_stack, APP_A_STACKSIZE);
|
||||||
|
|
||||||
|
struct k_thread app_b_thread;
|
||||||
|
K_THREAD_STACK_DEFINE(app_b_stack, APP_B_STACKSIZE);
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
|
k_tid_t thread_a, thread_b;
|
||||||
|
|
||||||
LOG_INF("APP A partition: %p %zu", (void *)app_a_partition.start,
|
LOG_INF("APP A partition: %p %zu", (void *)app_a_partition.start,
|
||||||
(size_t)app_a_partition.size);
|
(size_t)app_a_partition.size);
|
||||||
LOG_INF("Shared partition: %p %zu", (void *)shared_partition.start,
|
LOG_INF("Shared partition: %p %zu", (void *)shared_partition.start,
|
||||||
|
@ -58,10 +64,15 @@ void main(void)
|
||||||
sys_heap_init(&shared_pool, shared_pool_mem, HEAP_BYTES);
|
sys_heap_init(&shared_pool, shared_pool_mem, HEAP_BYTES);
|
||||||
|
|
||||||
/* Spawn supervisor entry for application A */
|
/* Spawn supervisor entry for application A */
|
||||||
k_thread_create(&app_a_thread, app_a_stack, APP_A_STACKSIZE,
|
thread_a = k_thread_create(&app_a_thread, app_a_stack, APP_A_STACKSIZE,
|
||||||
app_a_entry, NULL, NULL, NULL,
|
app_a_entry, NULL, NULL, NULL,
|
||||||
-1, K_INHERIT_PERMS, K_NO_WAIT);
|
-1, K_INHERIT_PERMS, K_NO_WAIT);
|
||||||
|
|
||||||
/* Re-use main for app B supervisor mode setup */
|
/* Spawn supervisor entry for application B */
|
||||||
app_b_entry(NULL, NULL, NULL);
|
thread_b = k_thread_create(&app_b_thread, app_b_stack, APP_A_STACKSIZE,
|
||||||
|
app_b_entry, NULL, NULL, NULL,
|
||||||
|
-1, K_INHERIT_PERMS, K_NO_WAIT);
|
||||||
|
|
||||||
|
k_thread_join(thread_a, K_FOREVER);
|
||||||
|
k_thread_join(thread_b, K_FOREVER);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue