On Wed, Apr 14, 2010 at 4:24 AM, Randal L. Schwartz merlyn@stonehenge.com wrote:
"Ang" == Ang BeePeng beepeng86@yahoo.com writes:
Ang> Are Squeak processes pre-emptive? Are infinite loop processes safe Ang> to run?
Squeak uses a simple priority scheme.
A Squeak process runs until it yields or it is interrupted by a higher priority process event. When it is interrupted, it goes to the back of the queue, so when the higher priority process pauses or completes, other processes at the same priority are likely to be run instead.
So, it's safe to run an infinite loop, but be sure that anything that should interrupt it is at a higher priority. And if you're running *two* infinite loops at the same priority, you need something that will just interrupt regularly.
What I do is start up a very high priority process that does something like:
d := Delay forMilliseconds: 50. [ d wait ] repeat.
or...
EventSensor eventPollPeriod: 50. EventSensor install.
This forces processes at lower levels to rotate, thus making the whole system a bit fairer and surprisingly more reactive.
My opinion is that the scheduler needs improving. I'll work on it... one day.
Gulik.