On Wed, 21 Sep 2011, Stéphane Ducasse wrote:
Processor yield
That will only allow processes to run which have the same priority as the
current process. Higher priority processes will simply interrupt the
current process if they can run, lower priority processes won't have a
chance to run, because the current process will be ready to run again
right after #yield (it will just be moved to the end of the queue of the
processes with the same priority).
Using a Delay is one solution, though waiting for less than 1 millisecond
is not possible with current VMs AFAIK. Another possibility is to
temporarily decrease the priority of the current process. Something like:
currentProcess := Processor activeProcess.
originalPriority := currentProcess priority.
[
currentProcess priority: priorityOfTheProcessToBeWokenUp.
Processor yield ]
ensure: [ currentProcess priority: originalPriority ].
Note that currentProcess in the argument of #ensure: can not be replaced
with Processor activeProcess, because the executor of the block may be
another process (unwinding).
Also note that there's no guarantee that currentProcess will be activated
anytime soon.
Levente
Stef
On Sep 21, 2011, at 7:27 PM, Camillo Bruni wrote:
Is it possible to manually yield the current (high priority) to leave the
possibility for other processes to run?
The closest solution I came up with is:
Delay forMilliseconds: 0.001.
IMO not very nice?
cami