如何“休眠"在Linux中通过将其内存存储到磁盘中并稍后进行恢复来恢复进程? [英] How to "hibernate" a process in Linux by storing its memory to disk and restoring it later?

查看:113
本文介绍了如何“休眠"在Linux中通过将其内存存储到磁盘中并稍后进行恢复来恢复进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Linux中休眠"进程? 就像笔记本电脑中的休眠"一样,我会将进程使用的所有内存写入磁盘,从而释放RAM.然后稍后,我可以恢复该过程",即从内存中读取所有数据并将其放回RAM中,然后我就可以继续我的过程了吗?

Is it possible to 'hibernate' a process in linux? Just like 'hibernate' in laptop, I would to write all the memory used by a process to disk, free up the RAM. And then later on, I can 'resume the process', i.e, reading all the data from memory and put it back to RAM and I can continue with my process?

推荐答案

我曾经维护过 CryoPID ,是一个完全符合您所谈论内容的程序.它将程序的地址空间,VDSO,文件描述符引用和状态的内容写入文件,以便以后进行重构. CryoPID在Linux本身没有可用的钩子时启动,并且完全在用户空间中工作(实际上,它仍然可以工作,具体取决于发行版/内核/安全性设置).

I used to maintain CryoPID, which is a program that does exactly what you are talking about. It writes the contents of a program's address space, VDSO, file descriptor references and states to a file that can later be reconstructed. CryoPID started when there were no usable hooks in Linux itself and worked entirely from userspace (actually, it still does work, depending on your distro / kernel / security settings).

问题包括(确实)套接字,待处理的RT信号,许多X11问题,​​glibc缓存getpid()实现等.伯纳德(Bernard)离开随机存取技术后,对我们中的少数人来说,随机存取(尤其是VDSO)是无法克服的.但是,它很有趣,并成为了几篇硕士论文的主题.

Problems were (indeed) sockets, pending RT signals, numerous X11 issues, the glibc caching getpid() implementation amongst many others. Randomization (especially VDSO) turned out to be insurmountable for the few of us working on it after Bernard walked away from it. However, it was fun and became the topic of several masters thesis.

如果您只是想考虑一个可以保存其运行状态并直接重新启动进入该状态的程序,那么从程序本身内部保存信息(可能是在维修信号时)就容易多了.

If you are just contemplating a program that can save its running state and re-start directly into that state, its far .. far .. easier to just save that information from within the program itself, perhaps when servicing a signal.

这篇关于如何“休眠"在Linux中通过将其内存存储到磁盘中并稍后进行恢复来恢复进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆