Locks and mutexes in C ++

I studied C ++ for a while and still have not found a good book that would explain what kind of animals they are? Are they an integral function of C ++? If so, how are they mentioned only in a book such as B. C ++? If not, where can you get reliable information about them - preferably a book (do not really like web tutorials), how to identify them, how to use them, etc. Thanks for any valuable help.

+6
c ++ mutex
source share
5 answers

Locks and mutexes are concurrency constructs used to ensure that two threads do not have access to the same shared data at the same time, while ensuring correctness.

There are no concurrency tools in the current C ++ standard.

Although you mentioned that you prefer books for online lessons, Herb Sutter Effective Concurrency Column is definitely a must read.

There is also an upcoming Anthony Williams book called C ++ concurrency in action . Anthony Williams is the author of the Boost.Thread library .

Another streaming library is Intel TBB .

+9
source share

Locks and mutexes are not part of the current C ++ standard, as they deal with concurrency, which is not part of the standard. They are included in several libraries, and different operating systems have different ways to deal with them (POSIX and Windows streams). If you take a book on concurrent programming for C ++, you will probably find what you are looking for. You can find implementations for them both in boost libraries and in ACE.

Themes are part of the C ++ 0x standard. I don't know any books for him yet, but on wikipedia there is an advertisement for the new Threading features here.

+5
source share

C ++ is currently unaware of threads, so mutex streams, etc. are not part of the language.
Typically, you need to use system libraries for streaming and mutexes, such as the pthread libraries on Linux.
Pthread-like libraries may be too c-like, but there are C ++ libraries that wrap them in a C ++ way, like ptypes or boost.

+3
source share

These are the basic constructs used to ensure the correctness of parallel programs. These include Boost and the new C ++ standard.

I can recommend this book, although it does not focus on C ++: http://www.amazon.com/Art-Multiprocessor-Programming- Maurice-Herlihy / dp / 0123705916 .

+1
source share

Locks and mutexes (I think: mutual exclusion) allow threads to interact to synchronize access to shared resources. For a brief overview of the concept, read the Wikipedia article on mutual exclusion .

These concepts are not part of the C ++ language. O'Reilly pthreads book would be a good link for you if you are on the POSIX platform. For Windows, you can go with Windows System Programming from Addison-Wesley.

+1
source share

All Articles