How does one use mutexes between modules?
I have a module that creates threads that run functions from another module.
I need to read a variable in the thread creating module and the threads that execute functions from other #included modules modify the variable. How does locking and unlocking of the mutexes occur in a system like this?
e.g. Logic module spawns 2 threads, each run a function from another module. There is a variable called current position that needs to be read from the logic module if e.g. another module calls getCurrentPosition. How do these threaded functions that are existing outside of the logic module use the mutexes defined in the logic module?
The thread running functions need to lock and unlock the mutex that is defined in the logic module.
You can use mutex just like you declare and use extern variable “current position”. No big difference here.