[squeak-dev] Improving a Process termination procedure
Igor Stasenko
siguctua at gmail.com
Fri May 1 09:57:23 UTC 2009
There are a potential of having incorrect behavior , when terminating
a preempted or waiting process:
with introduction of ProcessLocalVariable, it is essential that
context unwinding procedure should be performed only
for currently active process.
Here the proposal how to ensure this:
if terminating process is not active process we should do the following:
suspendedContext := proc suspendedContext.
currentProces := Processor activeProcess.
proc suspendedContext: [ Processor activeProcess
terminateFromContext: suspendedContext. Processor switchToProcess:
currentProcess ] asContext.
Processor switchToProcess: proc.
here #switchToProcess: is explicit switch (bypassing scheduling logic).
If we don't care about immediate termination of process and getting
back to process who initiated termination as soon as possible, then
simply do:
process terminateSoon.
which can be implemented as:
Process>>terminateSoon
| termContext |
termContext := suspendedContext.
suspendedContext := [ self terminateFromContext: termContext. self
suspend ] asContext.
Processor yield.
--
Best regards,
Igor Stasenko AKA sig.
More information about the Squeak-dev
mailing list
|