Multi-core shared memory problem

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Multi-core shared memory problem

908 次查看
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 项奖励
回复
2 回复数

889 次查看
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 项奖励
回复

880 次查看
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 项奖励
回复