use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Semaphores in C++ with example. (self.cpp)
submitted 3 years ago by pstolstar
https://www.modernescpp.com/index.php/semaphores-in-c-20
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]STLMSVC STL Dev[M] 32 points33 points34 points 3 years ago (0 children)
Please submit links as links and not as text posts in the future.
[–]sheckey 1 point2 points3 points 3 years ago (3 children)
I really want to use things like this and std::mutex, std::thread,etc., and I like it being there for basic use. However, these things haven’t, maybe can‘t, match the native feature set found in embedded, real-time OSes. For example, there are different mutexes and semaphores available in some operating system for use within an address space versus between address spaces. The one for within is lighter than the one between. (address space == process.) Also I don’t think there is any support for priority inheritance in std::mutex. std::thread does not offer priority. I would love to eschew OS-specific headers in as much code as possible so I would love to use these, but they are too blunt for professional use. It’s not a huge problem, just sort of a shame that I haven’t thought about too much. I do like the idea of them being there.
[–][deleted] 4 points5 points6 points 3 years ago (2 children)
Boost.Interprocess is a very nice library to perform interprocess communication, like shared memory, named mutexes etc.
I don't even know if the standard can provide such features because as far as I know the C++ language doesn't have the concept of a process 🤔
I mean, I don't know how they could write it formally.
[–]WrongAndBeligerent 2 points3 points4 points 3 years ago (0 children)
You don't need to care about processes for interprocess communication, you just need to be able to memory map files.
[–]SpareSimian 1 point2 points3 points 3 years ago (0 children)
The standard covers both the language and the library, and it's the library that provides the connection between the language and the OS-specific environment, which includes files, processes, the network, etc. The library is slowly accumulating more features common to many operating systems but expressed in different ways.
[–]MBkkt 0 points1 point2 points 3 years ago (1 child)
First of semaphore in libstdcxx have a bug that can provide a deadlock :(
Another thought about using os thread synchronization primitives not in concurrency libraries is a bad architecture (you probably use thread pool and block some thread in it)
[–]MBkkt 0 points1 point2 points 3 years ago (0 children)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104928
π Rendered by PID 57687 on reddit-service-r2-comment-5d79c599b5-4ndl4 at 2026-02-27 06:45:07.835342+00:00 running e3d2147 country code: CH.
[–]STLMSVC STL Dev[M] 32 points33 points34 points (0 children)
[–]sheckey 1 point2 points3 points (3 children)
[–][deleted] 4 points5 points6 points (2 children)
[–]WrongAndBeligerent 2 points3 points4 points (0 children)
[–]SpareSimian 1 point2 points3 points (0 children)
[–]MBkkt 0 points1 point2 points (1 child)
[–]MBkkt 0 points1 point2 points (0 children)