是线程内核对象?线程、内核、对象

2023-09-03 04:16:31 作者:君臨天下

在这本书我读了类的每个实例实际上是分配一个内核对象 - 这是使用的开销一主题

In this book I read that each instance of the Thread class is actually allocating a kernel object - and this is one of the overheads of using Thread.

据我所知,线程没有内核对象(只有过程是在这种情况下一个内核对象。该过程包含未内核对象的线程?)

As far as I know, the thread is not kernel object (only the process is a kernel object in this case. The thread that the process contains are not kernel objects?)

有人能解释一下吗?

推荐答案

主题是管理对象首先,你知道System.Threading.Thread类。这是一个内部CLR对象旁边,一个C ++类也叫主题。有相当的管道了大量的参与了,冰山风格。该管道肯定使用内核对象,其中五人。有些东西你可以在的TaskMgr.exe 看到。其中之一是本机操作系统线程处理,其他四个都有点神秘,但可能是同步对象的句柄。

Thread is a managed object first, you know the System.Threading.Thread class. It is an internal CLR object next, a C++ class also named Thread. There's rather a massive amount of plumbing involved with it, iceberg style. That plumbing certainly uses kernel objects, five of them. Something you can see in Taskmgr.exe. One of them is the native operating system thread handle, the other four are a bit mysterious but probably are synchronization object handles.

主题与实际的Windows线程去耦对象在.NET 2.0 pretty的臭名昭著。只有技术上是可行的,没有人熟知却从不执行,使得其工作的一个CLR主机。这是对SQL Server团队来实现螺纹与纤维的一个重要项目,他们放弃了它。不能让它不够可靠。一直没有尝试过,因为我知道的。

The decoupling of Thread with actual Windows thread objects in .NET 2.0 is pretty infamous. It is only technically possible, nobody well known actually ever implemented a CLR host that made it work. It was an important project for the SQL Server team to implement Thread with fibers and they gave up on it. Couldn't make it reliable enough. Hasn't been tried since that I know of.