Object subclass: #VMemory instanceVariableNames: 'dirty pages faults' classVariableNames: '' poolDictionaries: '' category: nil ! VMemory comment: 'I am an abstract memory manager system' ! !VMemory class methodsFor: 'instance creation'! new | r | r := super new. r init. ^r. ! new: aString | r sym | sym := ( aString replaceFrom: 1 to: 1 with: ( ( aString at: 1 ) asUppercase asString ) startingAt: 1 ) asSymbol. ( ( Smalltalk at: sym ifAbsent: [ ^self error: 'Invalid algorithm' ] ) inheritsFrom: self ) ifFalse: [ ^ self error: 'Invalid algorithm' ]. r := ( Smalltalk at: sym ) new. ^r. ! ! !VMemory methodsFor: 'instance initialization'! init dirty := Set new. pages := OrderedCollection new. faults := 0. ! ! !VMemory methodsFor: 'memory access'! read: page self touch: page. ! write: page self touch: page. ! touch: page dirty add: page. (pages includes: page) ifFalse: [ ((pages size) = (Simulator args numpages)) ifTrue: [ self replace: page ] ifFalse: [ self insert: page ]. faults := faults + 1. Simulator debug: 'PAGE FAULT'. ]. ! removePid: aPid pages := pages reject: [ :page | page pid = aPid ]. dirty := dirty reject: [ :page | page pid = aPid ]. ! replace: page self subclassResponsibility ! insert: page self subclassResponsibility ! ! !VMemory methodsFor: 'dirty page handling'! timestep (Simulator args verbose) ifTrue: [ 'Timestep' displayNl. ]. "Emptry the dirty set" dirty := Set new. ! ! VMemory createGetMethod: 'faults'!