Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

storing program state for restarting

9 views
Skip to first unread message

Edward Peschko

unread,
Apr 22, 2003, 6:26:56 PM4/22/03
to perl6-l...@perl.org
everyone,

I just thought I'd throw out a programming problem that I have, and see about people's
ideas on how to implement it in perl6.

I'm making an engine to do process restart.. That is, at each 'commit' step, the state of
the process is stored, and at the first failure, the process dies, able to be restarted
with a 'restart' flag. It looks like this:

spaghetti_process.p
-----

commit('start');

_sh('/etc/mknod export_pipe p');
...

commit('shell');

_sql('drop table....');

If the mknod succeeded and the 'drop table' command failed, restarting this with:

perl spaghetti_process.p -restart


should skip straight to commit('shell'); and start with _sql().

Right now, I'm doing this with a perl wrapper. ie: I autogenerate a 'goto' tag for each
step, then do a lookup at the beginning to see which tag to start at. The above becomes:

my $tag = gettag();
start: commit('start');

main_3: _sh('/etc/mknod export_pipe p');

shell: commit('shell');

main_5: _sql('drop table...');

But still this is a bloody pain to do when it gets to handling foreach, while, etc, loops.
In that case, I need to store both the location *and* the last element that was processed
in the foreach, and I need to generate a 'next' statement to skip all of the elements that
I have processed so far.

All of this is pointing to the fact that there has *got* to be a better way. In
particular, the fact that perl5's syntax needs to be bent in order to do this effectively
is frustrating.

Anyone got any ideas on effective syntax for doing this better in perl6? Or maybe a
generic method for dumping program state?

Ed

David Storrs

unread,
Apr 23, 2003, 9:45:09 AM4/23/03
to perl6-l...@perl.org
On Tue, Apr 22, 2003 at 03:26:56PM -0700, Edward Peschko wrote:

[want to be able to die from program, then restart at the very spot
you died, even if that was, e.g., inside a loop]

Well, if there is an easy way to serialize the current continuation,
your problem becomes trivial. So, addressing the Great Perl Gods with
a restatement of your original question:

"Hey folks--how do you serialize a continuation?"


--Dks

Sean O'Rourke

unread,
Apr 23, 2003, 9:52:01 AM4/23/03
to David Storrs, perl6-l...@perl.org
On Wed, 23 Apr 2003, David Storrs wrote:
> "Hey folks--how do you serialize a continuation?"

I'm guessing the answer is "with great difficulty, or not at all",
unfortunately. I think the Scheme folks are busy here, though.

http://archive.develooper.com/perl6-l...@perl.org/msg10280.html

/s

Steffen Mueller

unread,
Apr 26, 2003, 6:14:19 PM4/26/03
to perl6-l...@perl.org
David Storrs wrote:
> On Tue, Apr 22, 2003 at 03:26:56PM -0700, Edward Peschko wrote:
>
> [want to be able to die from program, then restart at the very spot
> you died, even if that was, e.g., inside a loop]

[...]

> "Hey folks--how do you serialize a continuation?"

Sorry, no Perl Gods at this end, but I suppose you'll be able to do that
by saving the current state of your memory, your hard-drive, and any
network or peripheral hardware your computer may currently be connected to.

Anything simpler than that really is ingenuity.

Steffen
--
@n=([283488072,6076],[2105905181,8583184],[1823729722,9282996],[281232,
1312416],[1823790605,791604],[2104676663,884944]);$b=6;@c=' -/\_|'=~/./g
;for(@n){for$n(@$_){map{$h=int$n/$b**$_;$n-=$b**$_*$h;$c[@c]=$h}reverse
0..11;push@p,map{$c[$_]}@c[reverse$b..$#c];$#c=$b-1}$p[@p]="\n"}print@p;

0 new messages