Eliot Miranda uploaded a new version of VMMaker to project VM Maker Inbox: http://source.squeak.org/VMMakerInbox/VMMaker.oscog-eem.2959.mcz ==================== Summary ==================== Name: VMMaker.oscog-eem.2959 Author: eem Time: 20 May 2021, 3:32:35.376631 pm UUID: bcb1f4a6-116d-4a10-ae3f-fcd449535d7d Ancestors: VMMaker.oscog-eem.2958 Candidate implementations of primitiveResume that check for myList and fail if it is not nil. See the comment in InterpreterPrimitives>>primitiveResume "Personally I would like to check MyList, which should not be one of the elements of the scheduler lists. But there are awful race conditions in things like should:notTakeMoreThan: that mean we can't. eem 9/27/2010 23:08." =============== Diff against VMMaker.oscog-eem.2958 =============== Item was changed: ----- Method: CoInterpreterPrimitives>>primitiveResume (in category 'process primitives') ----- primitiveResume "Put this process on the scheduler's lists thus allowing it to proceed next time there is a chance for processes of it's priority level. It must go to the back of its run queue so as not to preempt any already running processes at this level. If the process's priority is higher than the current process, preempt the current process." | proc inInterpreter | proc := self stackTop. "rcvr" + "We only have to check for myList being nil. If it is nil then this is either the active process or + a process suspended with primitiveSuspend (and if it is the activeProcess suspendedContext will + be nil and the isContext: test will fail). If it is not nil then either the process is waiting on some + semaphore-like list or on one of the scheduler's lists. If it is on some semaphore-like list it should + not resume. If it is on one of the scheduler's lists it is runnable (already resumed)." + objectMemory nilObject = (objectMemory followField: MyListIndex ofObject: proc) ifFalse: + [^self primitiveFailFor: PrimErrInappropriate]. (objectMemory isContext: (objectMemory followField: SuspendedContextIndex ofObject: proc)) ifFalse: + [^self primitiveFailFor: PrimErrBadReceiver]. - [^self primitiveFail]. "We're about to switch process, either to an interpreted frame or a machine code frame. To know whether to return or enter machine code we have to know from whence we came. We could have come from the interpreter, either directly or via a machine code primitive. We could have come from machine code. The instructionPointer tells us where from:" inInterpreter := instructionPointer >= objectMemory startOfMemory. (self resume: proc preemptedYieldingIf: preemptionYields from: CSResume) ifTrue: [self forProcessPrimitiveReturnToExecutivePostContextSwitch: inInterpreter] "Personally I would like to check MyList, which should not be one of the elements of the scheduler lists. But there are awful race conditions in things like should:notTakeMoreThan: that mean we can't. eem 9/27/2010 23:08. e.g. | proc myList classLinkedList | proc := self stackTop. myList := objectMemory fetchPointer: MyListIndex ofObject: proc. classLinkedList := self superclassOf: (objectMemory splObj: ClassSemaphore). ((self fetchClassOfNonInt: myList) ~= classLinkedList and: [objectMemory isContext: (objectMemory fetchPointer: SuspendedContextIndex ofObject: proc)]) ifFalse: [^self primitiveFail]. ''We're about to switch process, either to an interpreted frame or a machine code frame. To know whether to return or enter machine code we have to know from whence we came. We could have come from the interpreter, either directly or via a machine code primitive. We could have come from machine code. The instructionPointer tells us where from:'' inInterpreter := instructionPointer >= objectMemory startOfMemory. (self resume: proc preemptedYieldingIf: preemptionYields from: CSResume) ifTrue: [self forProcessPrimitiveReturnToExecutivePostContextSwitch: inInterpreter]"! Item was changed: ----- Method: InterpreterPrimitives>>primitiveResume (in category 'process primitives') ----- primitiveResume "Put this process on the scheduler's lists thus allowing it to proceed next time there is a chance for processes of it's priority level. It must go to the back of its run queue so as not to preempt any already running processes at this level. If the process's priority is higher than the current process, preempt the current process." | proc | proc := self stackTop. "rcvr" + "We only have to check for myList being nil. If it is nil then this is either the active process or + a process suspended with primitiveSuspend (and if it is the activeProcess suspendedContext will + be nil and the isContext: test will fail). If it is not nil then either the process is waiting on some + semaphore-like list or on one of the scheduler's lists. If it is on some semaphore-like list it should + not resume. If it is on one of the scheduler's lists it is runnable (already resumed)." + objectMemory nilObject = (objectMemory followField: MyListIndex ofObject: proc) ifFalse: + [^self primitiveFailFor: PrimErrInappropriate]. + (objectMemory isContext: (objectMemory followField: SuspendedContextIndex ofObject: proc)) ifFalse: + [^self primitiveFailFor: PrimErrBadReceiver]. - (objectMemory isContext: (objectMemory fetchPointer: SuspendedContextIndex ofObject: proc)) ifFalse: - [^self primitiveFail]. self resume: proc preemptedYieldingIf: preemptionYields "Personally I would like to check MyList, which should not be one of the elements of the scheduler lists. But there are awful race conditions in things like should:notTakeMoreThan: that mean we can't. eem 9/27/2010 23:08. e.g. | proc myList classLinkedList | proc := self stackTop. myList := objectMemory fetchPointer: MyListIndex ofObject: proc. classLinkedList := self superclassOf: (objectMemory splObj: ClassSemaphore). ((self fetchClassOfNonInt: myList) ~= classLinkedList and: [objectMemory isContext: (objectMemory fetchPointer: SuspendedContextIndex ofObject: proc)]) ifFalse: [^self primitiveFail]. self resume: proc preemptedYieldingIf: preemptionYields"! |
Free forum by Nabble | Edit this page |