Semaphores and shared memory issue

Showing results for 
Search instead for 
Did you mean: 

Semaphores and shared memory issue

Contributor III

Dear Martin Kovar

Thank you for your answer of my question ! But I still have some questions I want to consult you .

As we know , in a dual-processor chip, semaphores are used to let each processor know who has control of common memory.

I want to know whether the global variable is set default in both core's common memory. If not , can you ask me how to configure shared memory and make global variable in the shared memory .

Hope to get your help !

1 Reply

NXP Employee
NXP Employee

Hello, if you want to use semaphores and shared memory you have to do following steps:

1) create shared memory in linker file and place there your own section

    shared :    org = 0x40000000, len = 4k  

.sharedRAM (NOLOAD):
    } > shared

2) create global variable for first core and place it to the section in shared memory

tSharedStruct shared_struct __attribute__((section (".sharedRAM")));

3) for second memory, you have to create pointer to global variable

extern tSharedStruct __shared_struct[];
volatile tSharedStruct *px1 = __shared_struct;

 All necessary information regarding linker file are contained in the project I sent you.Please check ld files, c files with main function and sh_mem.h files.

All information about correct semaphores implementation are described in the app note.