Skip to content

Commit

Permalink
samples: shared_mem: re-use default memory domain
Browse files Browse the repository at this point in the history
Saves quite a bit of memory on MMU-based systems which manage
page tables at the memory domain level.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
  • Loading branch information
Andrew Boie authored and ioannisg committed Oct 26, 2020
1 parent 449278c commit 7e9b136
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions samples/userspace/shared_mem/src/main.c
Expand Up @@ -29,7 +29,7 @@
/* prepare the memory partition structures */
FOR_EACH(K_APPMEM_PARTITION_DEFINE, (;), user_part, red_part, enc_part, blk_part, ct_part);
/* prepare the memory domain structures */
struct k_mem_domain pt_domain, enc_domain, ct_domain;
struct k_mem_domain pt_domain, enc_domain;
/* each variable starts with a name defined in main.h
* the names are symbolic for the memory partitions
* purpose.
Expand Down Expand Up @@ -99,7 +99,6 @@ _app_ct_d char ctMSG[] = "CT!\n";
void main(void)
{
struct k_mem_partition *enc_parts[] = {&enc_part, &red_part, &blk_part};
struct k_mem_partition *ct_parts[] = {&ct_part, &blk_part};
struct k_mem_partition *pt_parts[] = {&user_part, &red_part};
k_tid_t tPT, tENC, tCT;

Expand Down Expand Up @@ -147,9 +146,10 @@ void main(void)
K_FOREVER);
k_thread_access_grant(tCT, &allforone);
printk("CT Thread Created %p\n", tCT);
k_mem_domain_init(&ct_domain, 2, ct_parts);
k_mem_domain_add_thread(&ct_domain, tCT);
printk("ct_domain Created\n");
/* Re-using the default memory domain for CT */
k_mem_domain_add_partition(&k_mem_domain_default, &ct_part);
k_mem_domain_add_partition(&k_mem_domain_default, &blk_part);
printk("ct partitions installed\n");

k_thread_start(&enc_thread);
/* need to start all three threads. let enc go first to perform init step */
Expand Down

0 comments on commit 7e9b136

Please sign in to comment.