Are std :: threads managed in user space or kernel?

As I wrote in the header, I would like to know if stantard C ++ threads are managed in user space or kernel.

Thanks.

+7
source share
2 answers

As this happens almost always, the standard does not provide for any specific implementation, it simply requires that the exposed behavior conform to its rules.

Thus, a particular implementation is free to choose; on the other hand, it is likely that many implementations will be based on boost.thread (on which the std::thread clause is based), so we can consider it to have an idea.

This library uses pthreads in POSIX and Windows threads on Win32. Win32 threads are, of course, kernel threads, but pthreads themselves are another interface that can be implemented both in user space and in kernel space (although almost any recent UNIX kernel provides opportunities for their implementation in space kernels).

So: std::thread can be anything, although on the β€œmain” PC operating systems / implementations it is very likely that you will get kernel threads. If for some reason you need to know more, check your compiler documentation.

+13
source

The interface is designed around pthreads , but the libC ++ developer can decide what to use.

+4
source

All Articles