简体   繁体   中英

In a many-to-one threading model, when does the mapping actually start?

From my understanding on the many-to-one model, all user threads are bound to a LWP which is then bound to a kernel thread. The threading library is responsible for scheduling the threads onto the LWP and the kernel only sees a single threaded application.

So, does the mapping happen the moment the program starts(main thread is executed) or it happens somewhere in between the program execution?

To execute a user (multi or single threaded process), we need a kernel thread because the kernel thread is the minimum scheduling entity for the kernel scheduler. It is the job of the threads library to choose the right thread and schedule it on the LWP. Note that this includes the main thread as well. So, my guess would be that the binding happens at program exec time. Since I am guessing, I will wait for others to chime in as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM