Could you recommend books on concurrent programming?
Concurrent programming is easy, synchronisation is hard.
Have a look at this video for an alternative to synchronisation: https://www.youtube.com/watch?v=2yXtZ8x7TXw
When you have to synchronize
Use easy (High level) synchronization. see:

Scoop from Eiffel.
Transactions
Pipelines / message passing
coroutines (for when you don't need parallelisation)

See also no lock / zero lock structures: Most pipes that are thread safe use locking. Or are not thread safe, and expect the user to do the locking. However it is possible to get thread safe zero lock queues. There rely on a few atomic instructions. (I prefer the name minimal lock, because the atomic instructions do locking).
Only use low-level synchronization to implement high-level synchronisation.
If you need synchronisation, and if you do not have high-level synchronisation, then find a good library that implements high-level synchronisation, using the existing low-level synchronisation.
Don't write it your self, except as an exercise (and do to it as an exercise, it is fun and you will learn a lot), as it is very hard and you will get it wrong.