Synchronization Variable Storage

We know that all the threads in process share the process address space.
We have various synchronization mechanisms like semaphore, mutex, spinlock, critical sections etc . used for thread syncronization.
I want to know in which part of the process address space are these synchronization variables stored?
How one thread gets access to the syncronization variable declared in another thread? Pls correct me if this question is improper.

If you make them local variables, they're in stack space. If you make them global variables, they're in global variable space. If you allocate them with malloc, they're in heap space. They don't need to be stored anywhere in particular.

All threads in the same process have access to the process' entire memory space. As such, there is no more access to "get", they already have access to everything. The problem is how to access things safely, avoiding race conditions and cache effects. That's what mutexes and other IPC are for.

As for transferring variables from thread to thread, you could pass in pointers to both threads, transfer through a global data structure, communicate by pipes or sockets, or many other means.

They are just variables (ofcourse the pthread lib treat them specially) so where ever you declare/define them there they�d appear; the only thing is their scope and visibility to pthreads that should guide you the location to declare them.

Like to add a quick-tip:
You can look at the process (having pid = x) memory area at /proc/<pid>/maps

cat /proc/x/maps

Gives you all *.so and other memory area of the process (in terms of memory ranges).

If you have to see the location of a perticular variable; just print it's address from your program and while the process is running, look at the location (find the range slab) where the address is falling. That is the location of your variable in the program. This is true for any address your program uses.

Thanks.