Alex Rivera | Logout

Serialization of objects: no thread state can be involved, right?

Asked 2008-10-08T18:03:17.810
9

I am looking hard at the basic principles of storing the state of an executing program to disk, and bringing it back in again. In the current design that we have, each object (which is a C-level thingy with function pointer lists, kind of low-level home-made object-orientation -- and there are very good reasons for doing it this way) will be called to export its explicit state to a writable and restorable format. The key property to make this work is that all state related to an object is indeed encapsulated in the object data structures.

There are other solutions where you work with active objects, where there is a user-level thread attached to some objects. And thus, the program counter, register contents, and stack contents suddenly become part of the program state. As far as I can see, there is no good way to serialize such things to disk at an arbitrary point in time. The threads have to go park themselves in some special state where nothing is represented by the program counter et al, and thus basically "save" their execution state machine state to the explicit object state.

I have looked at a range of serialization libraries, and as far as I can tell this is a universal property.

The core quesion is this: Or is this actually not so? Are there save/restore solutions out there that can include thread state, in terms of where in its code a thread is executing?

Note that saving an entire system state in a virtual machine does not count, that is not really serializing the state, but just freezing a machine and moving it. It is an obvious solution, but a bit heavyweight most of the time.

Some questions made it clear that I was not clear enough in explaining the idea of how we do things. We are working on a simulator system, with very strict rules for code running inside it is allowed to be written. In particular, we make a complete divide between object construction and object state. The inte

Edit
Report

2 Answers

0

I consider the thread state to be an implementation detail which is probably not appropriate to be serialized. You want to save the state of your objects--not necessarily how they got to be the way they are.

As an example for why you want to take this approach, consider hitless upgrade. If you're running version N of your application and want to upgrade to version N+1, you can do so using object serialization. However, the "version N+1" threads are going ot be different from the version N threads.

answered 2008-10-08T18:58:10.977
0

Something like this was actually proposed for Java in JSR 323:

http://tech.puredanger.com/2008/01/09/strong-mobility-for-java/

but was not accepted as being too theoretical:

http://tech.puredanger.com/2008/01/24/jcp-votes-down-jsr-323/

If you follow the links, you can find some interesting research on this problem.

answered 2008-10-08T21:47:51.133

Your Answer