不同的“组件”有哪些?组成进程、应用程序域、上下文和线程(以及它们之间的关系是什么)?
我真的希望得到这个问题的明确答案。
我之前有一个问题,我问“什么是线程(真的)?”我得到了一些非常好的答案,我从中得到的结论是,线程是:
线程是处理器寄存器的一组独立值(对于单核)。由于这包括指令指针(又名程序计数器),因此它控制按什么顺序执行。它还包括堆栈指针,它最好指向每个线程的唯一内存区域,否则它们会相互干扰。
IE
线程并不比一组寄存器值更“具体”
,
CPU 寄存器的确切列表取决于体系结构,但指令指针和堆栈指针几乎是通用的。它们定义了一个线程,当该线程(寄存器值集)加载到处理器核心中时,该线程正在运行。处理器正在获取线程所需的指令并更新线程寄存器。当需要上下文切换时,处理器会将这组寄存器值保存到内存中,并加载属于不同线程的一组寄存器值,通常作为中断服务逻辑的一部分。
此外,我了解线程有 TLS(线程本地存储)和自己的调用堆栈。
所以重申一下,为了澄清我的问题,线程的组件(正如我在标题中所说的那样)是寄存器值、其 TLS 及其调用堆栈。我想知道我的标题中其他项目的组成部分(进程、应用程序域和上下文)。
这是我正在阅读的书中的一个图表(Pro C# 2008 和 .NET Platform)
我理解此图适用于 Win32 进程,但我认为相同的 TLS、调用堆栈思想也适用于 .NET。另外,我认为如果该图包含定义这些线程(A 和 B)的寄存器值(或表明存在寄存器值的内容),那么它会更好。
现在我正在继续调查,我想一次性问清楚。我想知道进程、应用程序域和上下文的相同信息(这是我理解的托管“层次结构”的顺序,即进程主机应用程序域、应用程序域主机上下文、上下文主机线程)。
我的最终目标是获得足够的信息,以便我可以绘制所有这些实体(或它们是什么)之间的关系,以及实际组成它们的组件(例如,在线程的情况下,有寄存器值、TLS、以及实际组成它们的调用堆栈)。当我这样做时,我会将图表作为最后的编辑发布在这个问题上。现在,这是我正在阅读的书中的一个图表(关于进程、应用程序域和上下文):
PS,如果有人知道已经解释了这一切的图表,我很乐意看到它。如果不 。 。 。到底为什么没有一个?
编辑:这是我到目前为止的图表
I am really hoping to get a definitive answer to this.
I have a previous question where I asked "What is a thread (really)?" I got some really good answers and my takeaway from this was that a Thread is:
A thread is an independent set of values for the processor registers (for a single core). Since this includes the Instruction Pointer (aka Program Counter), it controls what executes in what order. It also includes the Stack Pointer, which had better point to a unique area of memory for each thread or else they will interfere with each other.
i.e.
A thread isn't anything more "concrete" than a set of register values
and
The exact list of CPU registers depends on the architecture, but instruction pointer and stack pointer are pretty much universal. They define a thread insofar as when this thread (set of register values) is loaded in the processor core, the thread is running. The processor is fetching instructions demanded by the thread and updating the thread registers. When a context switch is needed, the processor saves this set of register values into memory and loads a set belonging to a different thread, typically as part of the interrupt servicing logic.
In addition, I understand threads have TLS (Thread Local Storage) and their own Call Stack.
So to reiterate, to clarify my question, a thread's components (as I have put in my title) are the register values, its TLS, and its call stack. I want to know the components of the other items in my title (processes, appdomains, and contexts).
Here is a diagram from the book I am reading (Pro C# 2008 and the .NET Platform)
I understand this diagram pertains to Win32 Processes, but I think the same TLS, call Stack idea holds for .NET. Also, I think this diagram would be much better if it included thhe register values (or something to indicate that there were register values) that defined these threads (A and B).
Now I am continuing my investigation, and I want to just ask this all at once. I want to know the same information for Processes, AppDomains, and Contexts (and this is the order that I understand as the "hierarchy" of hosting, i.e. processes host appdomains, appdomains host contexts, contexts host threads).
My ultimate goal is to get enough information that I can diagram the relationships between all these entities (or whatever they are), but also the components that actually make them up (for instance in the case of threads, there are register values, TLS, and call stack that actually make them up). When I do, I will post the diagram up on this question as an edit at the end. For now, here is a diagram taken from the book I am reading (as regards processes, app domains, and contexts):
P.S. if someone knows of a diagram out there that already explains all this I would love to see it. If not . . . why the heck is there not one??
EDIT: HERE IS WHAT I HAVE SO FAR AS A DIAGRAM
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在在线论坛上发布大量信息并保持其可读性是很困难的。
相反,我建议您阅读两本书:
It's difficult to post a lot of information in an online forum and keep it readable.
Rather, I recommend that you read two books: