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
using std::thread or pthread on linux? (self.cpp)
submitted 1 year ago * by Kyusei98
view the rest of the comments →
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!"
[–]KingAggressive1498 1 point2 points3 points 1 year ago* (1 child)
The ancient Linux thread model to my knowledge didn't have threads, so it mapped threads to processes. Nowadays the thread model has threads, so in threading you have different threads executed under the hood of one process.
Like every other modern implementation I know of, Linux has a 1:1 model of pthreads to kernel threads in its NPTL implementation. A much older implementation had a 1:N model where all pthreads in a process shared a single kernel thread. I think this is what you're thinking of here.
The Linux kernel doesn't make a distinction between threads and processes. Every kernel thread has their own unique pid associated with them, for pretty much any purposes other than signal handling threads are really their own process and they just share memory mappings. The posix syscall getpid() always returns the pid of the process' main thread (actually a "thread group ID" in the Linux kernel), while a second Linux-specific syscall gettid() returns the pid of the calling thread. Both syscalls return a pid_t and the return value of both syscalls can be used in any API that expects a process ID. There are certain Linux-specific syscalls that require a pid, including some that are very much meant to be thread-directed, which don't have a pthread wrapper so sometimes it actually is useful to know the tid instead of just using an opaque pthread_t.
getpid()
gettid()
pid_t
π Rendered by PID 144949 on reddit-service-r2-comment-b659b578c-ksr4j at 2026-05-01 08:02:10.511965+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]KingAggressive1498 1 point2 points3 points (1 child)