Preemptive scheduling
J J
azreal1977 at hotmail.com
Tue May 1 19:05:04 UTC 2007
Aha, Interpreter! I was looking in process for the "swap" method. :)
At the moment, I am not looking to solve a problem per se. I was just
thinking that Smalltalk tries to be it's own OS, kind of. I wonder what
would happen if it went a bit further.
On a real OS, a processes are only allowed to run for a certain amount of
time before the CPU interupts them and puts the OS back in control to decide
what to do next. In any kind of "green threads" system this (normally)
isn't doable because it is actually just one running process and if a "green
thread" doesn't want to yield, then the threading system never gets back in
control to stop it. The threading system could, of course, have the OS send
it some kind of signal ever so many milliseconds but how that is done is
very platform specific (not to mention a host of other problems with it).
But with an interpreter it would be possible to do the same things an
advanced OS does, let a process only run for a specific amount of VM
instructions, penilize processes that keep using their whole "quantum",
promote processes that don't, etc.
The question is, would this have any benifit? If I ever have time, maybe I
will find out (unless of course Squeak already does most of this). :)
>From: John M McIntosh <johnmci at smalltalkconsulting.com>
>Reply-To: johnmci at smalltalkconsulting.com,The general-purpose Squeak
>developers list<squeak-dev at lists.squeakfoundation.org>
>To: The general-purpose Squeak developers
>list<squeak-dev at lists.squeakfoundation.org>
>Subject: Re: Preemptive scheduling
>Date: Tue, 1 May 2007 11:21:38 -0700
>
>Interpreter>>transferTo: is the place in the VM were we transfer control
>from one process to another. This is invoked via
>
>primitiveSuspend
>primitiveWait
>primitiveYield
>resume:
>
>for wait and yield it follows the pattern
>
> self addLastLink: activeProc toList: processList.
> self transferTo: self wakeHighestPriority
>
>which means we stick the process at the end of the linked list of
>processes in the same priority, thus if there was a higher process or
>process at the same priority ready to run it will run instead of the
>process that has the wait or yield. It could of course wake the same
>process if the process is the only one in it's priority group and it's
>ready to run of course.
>
>for suspend, we don't do the addLastLink because the process is being
>suspended.
>
>In all of this the ProcessorScheduler does not do preemptive scheduling,
>thus if you have a high priority smalltalk process that runs away it will
>block all other
>processes from running. You could of course and I've seen change sets for
>Visualworks write your own scheduler that modifies what
>wakeHighestPriority means by suspending processes that normally would be
>runnable. That would be overhead, and what is the problem you are trying
>to solve?
>
>
>On May 1, 2007, at 10:48 AM, J J wrote:
>
>>Hi all,
>>
>>Does the Squeak VM do preemptive scheduling or regular yield style
>>scheduling. This may sound like a silly question, but I know Erlang is
>>language that does mainly green threads and they are preemptive in
>>nature. They accomplish this by allowing a given thread to execute no
>>more then 100 VM instructions before it is preempted (obviously if a
>>thread makes a primitive call that is a voluntary yield).
>>
>>Does Squeak do this already? I suspect not, and if I am correct, would
>>there be any benefit in doing something like this or would it actually
>>slow things down?
>>
>>Thanks,
>>Jason
>>
>>_________________________________________________________________
>>Dont quit your job Take Classes Online and Earn your Degree in 1 year.
>>Start Today! http://www.classesusa.com/clickcount.cfm?
>>id=866146&goto=http%3A%2F%2Fwww.classesusa.com%2Ffeaturedschools%
>>2Fonlinedegreesmp%2Fform-dyn1.html%3Fsplovr%3D866144
>>
>>
>
>--
>========================================================================
>===
>John M. McIntosh <johnmci at smalltalkconsulting.com>
>Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com
>========================================================================
>===
>
>
>
_________________________________________________________________
Dont quit your job Take Classes Online and Earn your Degree in 1 year.
Start Today!
http://www.classesusa.com/clickcount.cfm?id=866146&goto=http%3A%2F%2Fwww.classesusa.com%2Ffeaturedschools%2Fonlinedegreesmp%2Fform-dyn1.html%3Fsplovr%3D866144
More information about the Squeak-dev
mailing list
|