[squeak-dev] The Inbox: System-jar.1367.mcz
commits at source.squeak.org
commits at source.squeak.org
Mon Jul 11 11:21:42 UTC 2022
A new version of System was added to project The Inbox:
http://source.squeak.org/inbox/System-jar.1367.mcz
==================== Summary ====================
Name: System-jar.1367
Author: jar
Time: 11 July 2022, 1:21:36.615972 pm
UUID: 403676fc-9569-c542-ae88-f17030bb70c5
Ancestors: System-mt.1366
protect LowSpaceWatcher against concurrent invocations
Currently #installLowSpaceWatcher runs unprotected against multiple concurrent invocations; try to run this example in the Workspace:
p1 := [Smalltalk installLowSpaceWatcher] fork.
p2 := [Smalltalk installLowSpaceWatcher] fork
Expected behavior is that the LowSpaceWatcher gets reinstalled twice in a row; what's happening now is both invocations will run concurrently, both will block in terminate and then install two LowSpaceWatchers (actually, at the moment there's a little bug in terminate so the concurrent invocations will end up with one process stuck at a semaphore but that's about to be fixed soon)
Alternatively, this could be fixed by running #installLowSpaceWatcher's code as a critical section but that would mean a new class variable which may not be entirely justifiable - but let me know if #critical would be preferable.
=============== Diff against System-mt.1366 ===============
Item was changed:
----- Method: SmalltalkImage>>installLowSpaceWatcher (in category 'memory space') -----
installLowSpaceWatcher
"Start a process to watch for low-space conditions."
"Smalltalk installLowSpaceWatcher"
+
+ "Run with the highest priority to avoid concurrency issues.
+ Workspce example:
+ p1 := [Smalltalk installLowSpaceWatcher] fork.
+ p2 := [Smalltalk installLowSpaceWatcher] fork
+ Here both proceses are scheduled in the run queue, then p1 wakes up, starts the LowSpaceProcess
+ termination and waits on a semaphore until the termination is finished. Before the LowSpaceProcess
+ can proceed, process p2 wakes up and starts the LowSpaceProcess termination just like p1 and waits
+ on a semaphore until the termination is finished. Finally the LowSpaceProcess wakes up, unwinds,
+ unblocks p1 a p2 and terminates. p1 now continues and installs a new LowSpaceProcess and then
+ p2 does the same. The result will be two processes running the #lowSpaceWatcher method.
+ Please note this describes the behavior in Squeak 6 using direct process termination; see #terminate."
+ [
+ self primSignalAtBytesLeft: 0. "disable low-space interrupts"
+ LowSpaceProcess == nil ifFalse: [LowSpaceProcess terminate].
+ LowSpaceProcess := [self lowSpaceWatcher] newProcess.
+ LowSpaceProcess priority: Processor lowIOPriority.
+ LowSpaceProcess resume
+ ] valueUnpreemptively!
- self primSignalAtBytesLeft: 0. "disable low-space interrupts"
- LowSpaceProcess == nil ifFalse: [LowSpaceProcess terminate].
- LowSpaceProcess := [self lowSpaceWatcher] newProcess.
- LowSpaceProcess priority: Processor lowIOPriority.
- LowSpaceProcess resume.
-
- !
More information about the Squeak-dev
mailing list
|