[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] [PATCH] #returnFromSnapshot tweaks

From: Paolo Bonzini
Subject: [Help-smalltalk] [PATCH] #returnFromSnapshot tweaks
Date: Thu, 17 Apr 2008 08:46:04 +0200
User-agent: Thunderbird (Macintosh/20080213)

This includes two tweaks that are necessary to be able to restore the Cairo demo from a saved image. First, #returnFromSnapshot callbacks should run at a high priority. Because it reloads shared libraries and modules, a concurrent process might start using the shared library before it's been loaded. With the heavy usage of Delay in the SDL demos, this was routinely happening. However, this does not protect against other #returnFromSnapshot callbacks. To do so, I hacked a little and run the DLD callback separately, rather than with Object>>#changed:.

Another point, not covered by the patch, is that it is not necessary to call SDL_VideoQuit. Doing so actually can cause dangling pointers all over the place. :-)

2008-04-17  Paolo Bonzini  <address@hidden>

        * kernel/ Don't register DLD with ObjectMemory.
        * kernel/ Execute #returnFromSnapshot callback
        at high priority, and pass it to DLD before anything else.

diff --git a/NEWS b/NEWS
index 78e33aa..104d732 100644
--- a/NEWS
+++ b/NEWS
@@ -59,6 +59,9 @@ o   The semantics of #on:do: were changed: executing off the 
end of an
     Older versions of GNU Smalltalk either returned or resumed depending
     on the resumability of the exception.
+o   The callback for the #returnFromSnapshot event is executed as a
+    high-priority process.  Remember this!
 o   New tool gst-remote allows remote control of a GNU Smalltalk VM
     via a TCP socket.
diff --git a/kernel/ b/kernel/
index 9533412..b5c50ca 100644
--- a/kernel/
+++ b/kernel/
@@ -227,7 +227,6 @@ in CFunctionDescriptor.'>
        libraryList := OrderedCollection new.
        libraryStream := Kernel.RoundRobinStream on: libraryList readStream.
        moduleList := OrderedCollection new.
-       ObjectMemory addDependent: DLD
     DLD class >> update: aspect [
diff --git a/kernel/ b/kernel/
index d2b0742..15a6b47 100644
--- a/kernel/
+++ b/kernel/
@@ -47,14 +47,29 @@ class-side method to take a look at statistics on the 
memory manager''s
     ObjectMemory class >> changed: aSymbol [
-       "Before quitting, wait until all processes are done."
        <category: 'initialization'>
-       aSymbol == #aboutToQuit 
-           ifTrue: 
-               [
-               Processor activeProcess priority: Processor rockBottomPriority.
-               [super changed: aSymbol] forkAt: Processor 
-           ifFalse: [super changed: aSymbol]
+       | sema prio |
+       prio := aSymbol == #returnFromSnapshot
+           ifTrue: [Processor highIOPriority]
+           ifFalse: [Processor userSchedulingPriority].
+       Processor activePriority < prio
+           ifTrue: [
+               sema := Semaphore new.
+               "Ensure that modules and libraries are initialized before
+                anything else happens."
+               [DLD update: aSymbol. super changed: aSymbol. 
+               sema signal]
+                   forkAt: prio.
+               sema wait]
+           ifFalse: [
+               DLD update: aSymbol. super changed: aSymbol].
+       "Before quitting, wait until all processes are done."
+       aSymbol == #aboutToQuit ifTrue: [
+           Processor activeProcess priority: Processor rockBottomPriority.
+           Processor yield].
     ObjectMemory class >> initialize [

reply via email to

[Prev in Thread] Current Thread [Next in Thread]