Multi-core shared memory problem

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

Multi-core shared memory problem

915 Views
xiha
Contributor II

Now, my Z4 core is responsible for Ethernet communication and Z2 core is responsible for CANFD communication.CANFD has a shared memory for receiving data, and Ethernet has a shared memory for receiving data.So I used two mutex locks to protect these two shared memory Spaces.But it triggers a deadlock.The brief code is as follows:

xiha_1-1719328411674.png

 

When the z4 core main program obtains the can_mutex, the Z2 core main program also obtains the enet_mutex. Both cores then trigger an interrupt when the mutex is not released, and both are stuck where the lock was obtained.

If I am not clear, please tell me what else you would like to know.Finally, I would like to ask if there is any good advice for me.Than you very much!!!

0 Kudos
Reply
2 Replies

896 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @xiha 

yes, it makes sense that this does not work. Of course, the program will never leave the interrupt handler to finish the critical section in main function. You can do something like this in operating system between different tasks but not here. This must be solved on application level. For example, you can set just some SW flag in the interrupt handler and then build some state machine in main which can handle this.

Regards,

Lukas

0 Kudos
Reply

887 Views
xiha
Contributor II

I've changed my plan to not use mutex.I have found that when using a shared memory area with two cores, it occurs that the cache is not updated. Using two locks solves the cache problem, but it deadlocks. My colleague used the assembly code msync to solve this caching problem, so I can not use the lock, thank you for your help

0 Kudos
Reply