Can address space be recycled for multiple calls to MapViewOfFileEx without chance of failure?

前端 未结 4 735
自闭症患者
自闭症患者 2021-01-14 06:13

Consider a complex, memory hungry, multi threaded application running within a 32bit address space on windows XP.

Certain operations require n large buffers of fixed

4条回答
  •  粉色の甜心
    2021-01-14 06:23

    As the earlier post suggests, you can suspend every thread in the process while you change the memory mappings. You can use SuspendThread()/ResumeThread() for that. This has the disadvantage that your code has to know about all the other threads and hold thread handles for them.

    An alternative is to use the Windows debug API to suspend all threads. If a process has a debugger attached, then every time the process faults, Windows will suspend all of the process's threads until the debugger handles the fault and resumes the process.

    Also see this question which is very similar, but phrased differently: Replacing memory mappings atomically on Windows

提交回复
热议问题