As Solaris has many-to-many threading model/two level threading model, can you tell me how the user thread is mapped to a LWPs exactly? What is the algorithm that is is being followed? Is there any limit (that these many no of threads can only be mapped to one LWP & vice versa)?
Created Mar 8, 2001
The algorithm that is used is based on a combination of Solaris' doors IPC model and a simpler signals protocol. When you start a program that is linked with the thread library libpthread.so, the thread library automatically starts a background process - the dynamiclwps() or dynamic LWP scheduler which maps available LWPs to unbound user threads. It runs a tight loop and blocks on signotifywait(). Additionally, a small number of LWPs are shared between the kernel and the thread library. This is the doors thread pool.
As long as there are free LWPs, the unbound user threads are bound to a LWP. If a user thread blocks on some condition variable e.g I/O read, a LWP from the door thread pool will be dispatched to run any available user threads. If there are none, the LWP will wait on a timed (def. 5 minutes) condition variable before terminating/returning to the door thread pool. If the door thread pool is empty, the the kernel generates a SIGWAITING signal to the dynamiclwps().On receipt of a SIGWAITING signal, the dynamiclwps thread will create a new LWP.
I hope that that was not too obscure!