Semaphores and shared memory issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Semaphores and shared memory issue

672 Views
1329306846
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

419 Views
martin_kovar
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):
    {
      *(.sharedRAM)
    } > 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.

Regards,

Martin