On 09/22/2011 10:12 AM, Holger Hans Peter Freyther wrote:
Okay, how to move forward then:

a)

we keep track of alarms and we expire them on image resume? this will probably
require modifications to the image format? We use addDependent on Time to
save/restore the millisecondsClockValue?

No modifications to the image, try the attached patch.

b)

We just let each Delay expire after a image restoration?

I'm not sure I like this.  Let the Delays expire in due time.

different:
Looking at the code, it appears that Process signal: atMilliseconds can only
be used by one user on the VM?

Yes, the delay process multiplexes it.

Paolo
>From f711b657b29bf94792da89612328b5d32a5ebf70 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <[email protected]>
Date: Thu, 22 Sep 2011 10:33:36 +0200
Subject: [PATCH] improve Delay and millisecondClock behavior across image
 save

2011-09-22  Paolo Bonzini  <[email protected]>

	* kernel/Delay.st: Restart pending delays when the image restarts.
	* kernel/Time.st: Make the millisecondClockValue monotonic across
	image save.

libgst:
2011-09-22  Paolo Bonzini  <[email protected]>

	* libgst/dict.c: Add the ClockOnImageSave class variable to time.
---
 ChangeLog        |    6 ++++++
 kernel/Delay.st  |    8 +++++++-
 kernel/Time.st   |    9 +++++++--
 libgst/ChangeLog |    4 ++++
 libgst/dict.c    |    2 +-
 5 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 05d960e..67caa84 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-09-22  Paolo Bonzini  <[email protected]>
+
+	* kernel/Delay.st: Restart pending delays when the image restarts.
+	* kernel/Time.st: Make the millisecondClockValue monotonic across
+	image save.
+
 2011-08-24  Gwenael Casaccio  <[email protected]>
 
 	* kernel/ObjDumper.st: Fix VersionableObjectProxy.
diff --git a/kernel/Delay.st b/kernel/Delay.st
index fbb46ec..65f21e9 100644
--- a/kernel/Delay.st
+++ b/kernel/Delay.st
@@ -166,7 +166,13 @@ created.'>
 		    sortBlock: [:d1 :d2 | d1 resumptionTime >= d2 resumptionTime].
 	TimeoutSem := Semaphore new.
 	DelayProcess := [self runDelayProcess] forkAt: Processor timingPriority.
-	TimeoutSem signal	"get going"
+        ObjectMemory addDependent: self.
+        self update: #returnFromSnapshot
+    ]
+
+    Delay class >> update: aspect [
+	"Prime the timer event loop when the image starts running."
+	aspect == #returnFromSnapshot ifTrue: [TimeoutSem signal]
     ]
 
     Delay class >> initialize [
diff --git a/kernel/Time.st b/kernel/Time.st
index 71926d9..d3810e7 100644
--- a/kernel/Time.st
+++ b/kernel/Time.st
@@ -42,6 +42,7 @@ time value, and a block execution timing facility.'>
 
     SecondClockAdjustment := nil.
     ClockOnStartup := nil.
+    ClockOnImageSave := nil.
 
     Time class >> utcSecondClock [
 	"Answer the number of seconds since the midnight of 1/1/1901 (unlike
@@ -143,6 +144,7 @@ time value, and a block execution timing facility.'>
 
 	<category: 'initialization'>
 	SecondClockAdjustment := 86400 * 36159.
+        ClockOnImageSave := 0.
 	ObjectMemory addDependent: self
     ]
 
@@ -150,8 +152,11 @@ time value, and a block execution timing facility.'>
 	"Private - Initialize the receiver's instance variables"
 
 	<category: 'initialization'>
-	aspect == #returnFromSnapshot 
-	    ifTrue: [ClockOnStartup := Time primMillisecondClock]
+        | time |
+	aspect == #returnFromSnapshot ifTrue: [
+            ClockOnStartup := Time primMillisecondClock - ClockOnImageSave].
+	aspect == #aboutToSnapshot ifTrue: [
+            ClockOnImageSave := Time millisecondClock].
     ]
 
     Time class >> now [
diff --git a/libgst/ChangeLog b/libgst/ChangeLog
index a494db1..b1a4e13 100644
--- a/libgst/ChangeLog
+++ b/libgst/ChangeLog
@@ -1,3 +1,7 @@
+2011-09-22  Paolo Bonzini  <[email protected]>
+
+	* libgst/dict.c: Add the ClockOnImageSave class variable to time.
+
 2011-08-13  Paolo Bonzini  <[email protected]>
 
 	* libgst/prims.def: Atomically nil the file descriptor field
diff --git a/libgst/dict.c b/libgst/dict.c
index 806aabe..42b5b6e 100644
--- a/libgst/dict.c
+++ b/libgst/dict.c
@@ -337,7 +337,7 @@ static const class_definition class_info[] = {
   {&_gst_time_class, &_gst_magnitude_class,
    GST_ISP_FIXED, false, 1,
    "Time", "seconds",
-   "SecondClockAdjustment ClockOnStartup", NULL },
+   "SecondClockAdjustment ClockOnStartup ClockOnImageSave", NULL },
 
   {&_gst_date_class, &_gst_magnitude_class,
    GST_ISP_FIXED, false, 4,
-- 
1.7.6

_______________________________________________
help-smalltalk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to