gpt4 book ai didi

windows - Windows 内核是否有读写 fork() 指令?

转载 作者:可可西里 更新时间:2023-11-01 11:20:00 24 4
gpt4 key购买 nike

Because POSIX.1 compliance was a mandatory goal for Windows, the operating system was designed to ensure that the required base system support was present to allow for the implementation of a POSIX.1 subsystem (such as the fork function, which is implemented in the Windows executive, and the support for hard file links in the Windows file system).

这个 fork 函数是写时复制的吗?如果是这样,它是否仍然存在于最新版本的 Windows 中?如果是这样,它是否也可以调用 Win32 应用程序(尽管是未记录的 API)?

最佳答案

根据 Windows Internals 的内存,fork 是一种写时复制实现。根据 Windows 内存管理器的其余部分的工作方式,它是其他任何东西都是不寻常和令人惊讶的。

我似乎还记得,实现 fork 的方式是将所有内存分配放入节对象中,以便可以使用写时复制设置跨进程复制节。

不幸的是,这意味着您可能无法在非 posix 子系统进程中使用它,因为您需要仔细设置地址空间以仅包含部分。标准 Win32 进程不会这样做。

此外,如果您要支持 fork(),那么每个人都需要支持它 - 从内核开始。对于可能会惊讶地得到 fork()-ed 的系统示例,请考虑窗口系统。在那种情况下它甚至会做什么? (我假设 X11 对此有答案,但我不知道它是什么)。由于在 Windows 上执行 fork() 是一件非常不寻常的事情,如果您对标准的 Win32 进程执行此操作,我希望您的进程会完全陷入困境。

关于windows - Windows 内核是否有读写 fork() 指令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16350784/

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