Robert Lee wrote:
But what if the process's state is dependant on its envirnment. Examples:
ProcessA is transfering data to ProcessB. Can ProcessB's state really be restored once saved/killed? Assume ProcessA is on another machine connected over tcp/ip.
Ok, strictly speaking this is well off-topic, but I'll address it anyhow. Kindly bear in mind this is only relevant to my own OS design and likely to be different to anyone else's take on the situation.
There are three stages in completing any given task with a computer.
- The Input Phase
- The Calculation Phase
- The Results Phase
During the input phase information is fed into the program, during the calculation phase that information is manipulated in some fashion, and during the output phase that information is returned to the user.
I presume that all programs that will ever run on my system are deterministic in nature. Meaning that providing the same inputs to the program the same result will be produced no matter how many times the program is run.
The big problem with storing a program's state is, as you have pointed out, a problem of missing inputs.
The instinctive means of storing program state is to store the result phase, and the current state of the calculation phase making the tacit assumption that the input phase is over, or can be resumed without considering prior inputs. This works well for something like a text editor when the inputs are user driven, generally not related, and happen sequentially. However for other applications, such as your tcp/ip example, it isn't very helpful.
Now what I am proposing is that instead of storing the results/calculation phase state the only thing that needs to be tracked is the input phase. Any result phase can be reconstructed from the relevant input phase simply by running the task against the stored inputs. This provides total rollback capability to every single application running on the system. Any application can rollback to any previous state at will.
That's the principle anyhow. In practise things get a little more complicated. The scheme I'm working on involves determining states of rest for a program, ie those points at which it has completed a results phase and is waiting for a new input phase. At this point the entirety of the old input phase is stored and a new input phase record begun. I'm trying to work out a decent balance between maximising rollback (Ie number of input phase records stored) and minimising the space taken. The mechanism I'm currently toying with is to store the calculation/results phase every X input phases and removing the stored input phase records up to that point. This is purely down to the amount of space keeping permanent track of input phases would take, and the amount of time it would take to reproduce the current result phase from the zeroth input phase when the application resumes. The other problem is, of course, figuring out which inputs should register as a new input phase. Eg You don't want every single mouse movement being a new input phase for the desktop, rolling back mouse position is fairly irrelevant.
So how does this affect your tcp/ip problem?
Let's say, as an example, it's a web browser:
The browser got closed halfway through a transfer, so it lost half a page. Now the rollback mechanism allows the application to simply rewind the application to the start of the transfer (The "GET yadadada" operation) and continue where it left off. Whereas if I were simply stored the calculation/result phases I wouldn't know where this transfer began and the last one finished.
Or let's say it's a web server that got closed:
The server got shutdown halfway through a transfer to someone else. Now on resumption of the web server it rolls back to the input phase preceding that transfer request, a state in which it is waiting for requests. The user requesting the transfer has lost data, but the server has resumed in a viable state.
Sorry if that explanation isn't really great, I'm still working through the principles of this on paper and it confuses me as well sometimes.