Forum Discussion
Altera_Forum
Honored Contributor
14 years agoThe mutex will allow you to protect the variable, so that two CPUs don't try to write it at the same time, or have one CPU read it while another one is writing to it.
In theory you could also use it to synchronize the CPUs on a change on the variable with the mutex (i.e. have CPU1 and CPU2 lock the mutex, and when CPU1 changes the variable it realeases the mutex, allowing CPU2 to run and read the value) but this would completely freeze CPU2 until the variable has been changed, which may not be what you want. It would only work with two CPUs but you could solve this problem by creating another separate mutex for the CPU1/CPU3 couple. Maybe a better solution would be to use interrupts. Create one PIO component on each CPU (output for CPU1 and inputs for CPU2 and CPU3) and connect them together outside the SOPC system. Have the CPU1 change the PIO output after it changed the variable value, and have the PIO components on CPU2 and 3 trigger an interrupt on PIO change. You should still use the mutex in parallel to protect the variable access. I hope this helps