Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the model of boost threading library

Which is the threading model of c++ boost threading library use ?
1:1 (Kernel-level threading)
N:1 (User-level threading)
M:N (Hybrid threading)

The difference between these models (from wiki): http://en.wikipedia.org/wiki/Thread_(computing)#Models

I checked the boost site and it does not mentioned about the threading model it uses.
I guess it is a 1:1, because it does not provide function like yield or reschedule ,but i'm not sure...

like image 544
pgplus1628 Avatar asked Nov 10 '22 02:11

pgplus1628


1 Answers

It is native threads, namely, it will use platform threads, at least in Linux, Windows and Mac.

As far as I know, the thread mapping is going to be 1:1 with a kernel thread in Windows, Linux and MAC for each spawned thread.

I am not sure if for other platforms it could be implemented in other ways, but I don't know of any non-kernel thread implemenation with boost.thread API.

For user-level "threads", with cooperative multitasking, boost.coroutine can be used. There is also the upcoming boost.fiber library, which is almost like boost.coroutine, but it adds a user-level "thread" (which is a fiber in library terminology) API and a user-level fiber scheduler.

  • You can find boost.fiber here.
  • You can find boost.coroutine here.
like image 155
Germán Diago Avatar answered Nov 15 '22 07:11

Germán Diago