Skip to content
TopicTracker
来自 devblogs.microsoft.com/oldnewthing查看原文
译文语言译文语言

Windows 栈限制检查回顾:后续篇

本文是 Windows 栈限制检查回顾的后续篇,探讨了在选择寄存器来传递所需栈分配大小时的设计考量。

背景速读

- 这篇文章是《The Old New Thing》系列的一部分,作者是微软资深工程师Raymond Chen,他长期撰文解释Windows底层设计决策和历史沿革。 - 文中讨论的是Windows内核在栈分配(stack allocation)时,如何选择用哪个寄存器来传递请求分配的栈大小。这是操作系统内核中极底层的寄存器分配(register allocation)问题。 - 这个话题的背景是Windows的栈限制检查(stack limit checking)机制——系统需要确保线程不会超出其分配的栈空间,否则会导致栈溢出崩溃。在x86/x64架构上,寄存器数量有限且各有约定用途,因此选择哪个来传递“请求大小”会涉及性能、与既有调用约定的兼容性等因素。 - 对普通读者来说,这篇文章的意义在于它展示了一个最成熟的操作系统在内核关键路径上做微观优化时的权衡思维——哪怕是“用哪个寄存器”这样的细节,背后都有历史包袱和性能考量。

相关报道

  • Cancellation of Windows Runtime activities is inherently asynchronous, meaning that after requesting cancellation, the operation may not terminate immediately. This requires developers to properly handle the asynchronous nature of cancellation in their code.

  • The article compares three approaches to serving files over HTTP in Linux: synchronous blocking I/O, epoll-based asynchronous I/O, and io_uring. It benchmarks each method using a simple file server, showing that io_uring offers the highest throughput and lowest latency, especially under high concurrency.

  • PHP typically sends HTTP headers only when a script finishes, causing delays for redirects after long operations. The article notes this issue and mentions that complex workarounds exist for sending headers before script completion.