Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relationship between a kernel and a user thread

Is there a relationship between a kernel and a user thread?

Some operating system textbooks said that "maps one (many) user thread to one (many) kernel thread". What does map means here?

like image 998
Pwn Avatar asked Jul 24 '09 16:07

Pwn


1 Answers

When they say map, they mean that each kernel thread is assigned to a certain number of user mode threads.

Kernel threads are used to provide privileged services to applications (such as system calls ). They are also used by the kernel to keep track of what all is running on the system, how much of which resources are allocated to what process, and to schedule them.

If your applications make heavy use of system calls, more user threads per kernel thread, and your applications will run slower. This is because the kernel thread will become a bottleneck, since all system calls will pass through it.

On the flip side though, if your programs rarely use system calls (or other kernel services), you can assign a large number of user threads to a kernel thread without much performance penalty, other than overhead.

You can increase the number of kernel threads, but this adds overhead to the kernel in general, so while individual threads will be more responsive with respect to system calls, the system as a whole will become slower.

That is why it is important to find a good balance between the number of kernel threads and the number of user threads per kernel thread.

like image 63
samoz Avatar answered Oct 18 '22 08:10

samoz