Sleep / restart thread

I am looking for a way to restart a thread, either from within the context of the thread or from outside the thread, possibly from another process. (Any of these options will work.) I am aware of the difficulty of hibernation in all processes, and I am sure that the same difficulties are associated with threads. However, I still ask you to hope that someone has an understanding.

My goal is to pause, save to a file and restart the current stream from its exact context without any changes in this stream code or, rather, changes only in a small area - that is, I cannot write serialization functions in the entire code. The main block of code must be unmodified and will not have any global / system descriptors (file descriptors, sockets, mutexes, etc.). Really not requiring data storage, such as CPU registers, is not necessary; but basically the heap, stack and program counter should be saved, and everything else is necessary for the flow to execute logically from the save point. The resulting state of the program should not differ if it was saved or not.

This is for a debugging program for highly reliable software; the goal is to run software simulations with various input scripts and be able to pause the current simulation and then restart it again later - or force the sim to a branch point, save it, make many copies, and then run further the simulation from the general starting point. That is why the main program cannot be changed.

The main language of the stream is in C ++ and should work on Windows and Linux, however, if there is a way to do this on only one system, then this is also acceptable.

Thanks in advance.

+3
source share
4 answers

, , . Windows, , Linux.

, , . - . , , . , . , .

. "" . "" . ++ 0x ABI. , , . . , .

. . ( ) .

, . , , .. - - . , .

, . , , .

, , . , , , , , .

, linux - . . . , . .

fork, . .

.

+3

. , - , "" .

. . , ( boost:: serialize), . , , , , .

, , , , . , , , Xen.

+2

, .

, , . pthreads, , .

0

The way you should do this is VM snapshots; get a copy of the VMWare workstation, then you can write code to automate the start / stop / snapshot of the machine at different points. Any other approach is quite untenable, because as long as you can freeze and release the process, you cannot restore the state of the system that it expects (all the materials that Kaspan mentions as files and others).

0
source

Source: https://habr.com/ru/post/1715534/


All Articles