gpt4 book ai didi

.net - 异常处理上下文切换和 SEH

转载 作者:行者123 更新时间:2023-12-04 06:40:45 24 4
gpt4 key购买 nike

我最近读了一些关于异常处理和 .Net 框架的书,这似乎让我在开始时更加困惑。

在 CLR 中通过 C# 第四次添加我读到:

Also, the .NET Framework exception-handling mechanism is built using the Structured Exception Handling (SEH) mechanism offered by Microsoft Windows. SEH has been discussed in many resources, including my own book, Windows via C/C++, 5th ed. (Microsoft Press, 2007), which contains three chapters devoted to SEH.



现在,这就是我的困惑开始的地方。如果 .Net 框架是使用 SEH 构建的,但它仅用于未处理的异常,还是立即用于 .NET 中的所有异常处理,如果是这样,CLR 在哪里适合,是从 SEH 获取队列还是它自行运作并使用 SEH如果当 unhandled exception Occurs? .

第二 Context 从 Kerrnal 模式切换到 User 模式如何适应?我知道创建线程时它具有(来自 CLR 通过 C#)

Thread environment block (TEB) The TEB is a block of memory allocated and initialized in user mode (address space that application code can quickly access). The TEB consumes 1 page of memory (4 KB on x86 and x64 CPUs, 8 KB on an IA64 CPU). The TEB contains the head of the thread’s exception-handling chain. Each try block that the thread enters inserts a node in the head of this chain; the node is removed from the chain when the thread exists in the try block. In addition, the TEB contains the thread’s thread-local storage data as well as some data structures for use by Graphics Device Interface (GDI) and OpenGL graphics.



以及用户模式堆栈和内核模式堆栈。但是为什么上下文切换需要在任何时候发生,因为它们需要处理的所有内容都在同一个线程上?

最佳答案

以下是关于 CLR 如何处理异常的非常详细的解释(我相信是一位 CLR 架构师):http://blogs.msdn.com/b/cbrumme/archive/2003/10/01/51524.aspx

关于.net - 异常处理上下文切换和 SEH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4277661/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com