I don’t think this is realistically possible without running it in a virtual machine
Seems like a Linux kernel specially developed to have this feature could potentially pull it off. You wouldn’t need to stop all processes or store the entire contents of RAM, just pause the processes involved in the game and store the contents of the memory currently assigned to those processes. Since the kernel is already in charge of process management and memory management, this seems theoretically possible. Just don’t allow the game to use any more CPU cycles at all until all game-related RAM is copied onto a save file on disk. The game will appear to freeze for an appreciable amount of time while this happens, but after that it should resume … basically the same as if you were running a CPU-intensive game on a CPU that was woefully inadequate for it and the game froze/stuttered due to waiting on the CPU. Then, the save state could be loaded by the kernel just creating a new process with the same parameters as the original one, loading that information from disk into memory, then un-pausing that process.
It would have to be done at a very deep level and be baked right into the kernel, though.
(If you have sufficient RAM, the same basic process could maybe be done more quickly and efficiently by copying all game-assigned RAM into a new allocation in unused RAM, rather than saving it to disk. There will probably still be a noticeable stutter, but the game should spend much less time ‘frozen’ that way. I guess, come to think of it, this technique could also be used as a write cache for writing to disk, so you could save states to disk without needing to pause the game for as long. Would only work if your system has enough RAM to hold everything the game is using twice, plus overhead for the OS. But in systems with 32GB or more, that’s unlikely to be a problem. Even 16GB systems could do it, depending on how RAM-intensive the game is.)
Seems like a Linux kernel specially developed to have this feature could potentially pull it off. You wouldn’t need to stop all processes or store the entire contents of RAM, just pause the processes involved in the game and store the contents of the memory currently assigned to those processes. Since the kernel is already in charge of process management and memory management, this seems theoretically possible. Just don’t allow the game to use any more CPU cycles at all until all game-related RAM is copied onto a save file on disk. The game will appear to freeze for an appreciable amount of time while this happens, but after that it should resume … basically the same as if you were running a CPU-intensive game on a CPU that was woefully inadequate for it and the game froze/stuttered due to waiting on the CPU. Then, the save state could be loaded by the kernel just creating a new process with the same parameters as the original one, loading that information from disk into memory, then un-pausing that process.
It would have to be done at a very deep level and be baked right into the kernel, though.
(If you have sufficient RAM, the same basic process could maybe be done more quickly and efficiently by copying all game-assigned RAM into a new allocation in unused RAM, rather than saving it to disk. There will probably still be a noticeable stutter, but the game should spend much less time ‘frozen’ that way. I guess, come to think of it, this technique could also be used as a write cache for writing to disk, so you could save states to disk without needing to pause the game for as long. Would only work if your system has enough RAM to hold everything the game is using twice, plus overhead for the OS. But in systems with 32GB or more, that’s unlikely to be a problem. Even 16GB systems could do it, depending on how RAM-intensive the game is.)