内核和用户线程之间的关系 [英] Relationship between a kernel and a user thread

查看:137
本文介绍了内核和用户线程之间的关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

内核和用户线程之间有关系吗?

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?

推荐答案

当他们说map时,意味着每个内核线程都被分配给一定数量的用户模式线程.

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.

这篇关于内核和用户线程之间的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆