18 Sep, 2010, Bojack wrote in the 1st comment:
Votes: 0
Im trying to write a mprog pause code which will just pause the running prog for a set time then move onto the next line, like mpsleep.c. I figured out an easier way to do it but my question is this, if I use a buffer to take the remaining code and set it into that buffer and someone does a copyover later. Does this buffer become floating memory assuming you set aside memory for it or would the memory set aside die?
18 Sep, 2010, bbailey wrote in the 2nd comment:
Votes: 0
Bojack said:
Im trying to write a mprog pause code which will just pause the running prog for a set time then move onto the next line, like mpsleep.c. I figured out an easier way to do it but my question is this, if I use a buffer to take the remaining code and set it into that buffer and someone does a copyover later. Does this buffer become floating memory assuming you set aside memory for it or would the memory set aside die?


It will 'die'. Data such as the above will need to be saved externally and reloaded in some other manner. Copyover (in all the implementations I've seen) uses exec() to spawn a new process which will 'replace' the current process. From a man page for exec():
Quote
The exec() family of functions replaces the current process image with a new process image. The functions described in this manual page are front-ends for the function execve(2). (See the manual page for execve() for detailed information about the replacement of the current process.)

And from the execve() man page:
Quote
execve() does not return on success, and the text, data, bss, and stack of the calling process are overwritten by that of the program loaded. The program invoked inherits the calling process's PID, and any open file descriptors that are not set to close-on-exec.
18 Sep, 2010, Runter wrote in the 3rd comment:
Votes: 0
In those same implementatuons its writing intermediate data already. My point is adding additional selective persistence this way is trivial. You just need to write a function to serialize the state of a running prog. Dump all active progs to a file. Later read the file with a reverse serialization function to marker. ??? Profit.
30 Sep, 2010, Sorressean wrote in the 4th comment:
Votes: 0
As was noted, you will need to serialize the progs, but make sure this matches up with your mud. if nothing else saves it's state through copyover, should mprogs save their state, too? Maybe have a state-saving flag that can be set to determine if the prog gets serialized. Also note this could cause some problems later if you change progs and copyover and the prog is running old code.
This said, you can serialize when everything else does, then deserialize in the copyover recovery function.
HTh,
0.0/4