On Wed, Sep 26, 2012 at 03:24:51AM +0200, Igor Stasenko wrote:
As i understood, this features doing a snaphot in forked child process. Is this involves doing #shutdown on image side in forked process, or shutdown done in parent image?
It just forks an identical copy of the VM and image in a background process running at lower priority, and does the image save in the background process so there is no effect on the main image. Each of the two images knows if it is parent or child, so the child evaluates a block (to do the image save) then exits.
Alas, the complexity of VM works against us in this case :/ It is not just object memory, but open files, sockets and god knows what else (other external resources used by image).
It is not the Cog VM that is too complex, it's the use of pthreads in the support code for basic timer support that makes it tricky. I'm sure it can be done, but it's not trivial. Handling the socket connection to the X11 server was a challenge, but I was able to do that with XDisplayControlPlugin. The remaining file handles are just shared between the processes and do not cause any immediate problem. Signal handlers were also an issue, mainly for the timer interrupts. I don't think you should be surprised that it does not work in Cog, instead you should be surprised that it works at all on any VM ;) Dave