问题描述
是否可以暂停进程,将内存内容保存到文件中,然后重新加载文件,以便继续执行程序?
Is it possible to pause a process, save the memory contents to a file, and then later reload the file so you can continue the program?
编辑我一直在读这个:
http://en.wikipedia.org/wiki/Setcontext
是否可以转储结构体的内容,并以某种方式强制 malloc 分配相同的内存区域?
Is it possible to dump the contents of the struct, and somehow force malloc to allocate the same memory regions?
推荐答案
从技术上讲这是可能的,但它也需要保存所有系统分配的资源状态 - 例如文件描述符,然后恢复它们.所以这是一项具有挑战性的任务.
Technically it is possible, but it would require saving all the system-allocated resources state too - like file descriptors for example and then restoring them. So it's a challenging task.
实现您想要的最简单方法是使用像 VMWare 这样的虚拟机.当你暂停它时,你实际上保存了整个机器状态以及所有正在运行的程序.
The easiest way to achieve what you want is to use a virtual machine like VMWare. When you pause it you actually save the whole machine state together with all programs running.
这篇关于保存进程的内存以备后用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!