I understand the purpose of mutex in pthreads, but I often here that it is considered a bad practice to use mutex with a global variable as a shared resource (for example, like in the answer to this question: Mutex lock threads).
So, the questions:
- Is it really that bad to put the shared resource as a global variable?
- If you have only 1 shared variable, like in the example, would it be considered ok to use a global variable, or still no?
- What is the better way to share the variables between the processes?