Given that a function does use global and/or static variables, and the decision is to continue to use them (the second approach we mention in Table 1), obviously the places in the code where they are used constitute critical sections. As Chapter 15, Multithreading with Pthreads Part II - Synchronization, has shown in detail, we must protect these critical sections; here, we use the pthreads mutex lock to do so.
We apply this approach the addition of a pthread ...