C Linux Multithreading – Using Locks with Multi Cores/CPUs

clinuxmultithreading

I'm not sure how the locks will work with multi processors/cores, I'm going to use shared memory in my application or FIFO, what worries me is the locks, I have a server with 2-CPU, how the lock will be able to lock a variable on one CPU while the another operation went to the 2nd CPU for the same variable?
I'm in Linux environment using C, I've searched the web for some useful info, appreciate your help

Best Answer

Intel articles offers a good point of view about this.

Also there is a small article about the top 3 solutions in multithreading programming.

You didn't specify this, but if you are on Linux and you are programming in C you are probably talking about pthreads and this is a beginner tutorial that covers the main aspects of this topic.