<br><br><div class="gmail_quote">On Tue, Apr 13, 2010 at 12:05 PM, Chris Muller <span dir="ltr">&lt;<a href="mailto:asqueaker@gmail.com">asqueaker@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi, I&#39;m not very well-versed in process-scheduling, but I&#39;m having<br>
trouble understanding why you don&#39;t like sending the last pre-empted<br>
process to the back of its queue of processes waiting at that level.<br>
Doesn&#39;t that seem more &quot;fair&quot; and also, allow &quot;smoother&quot; multi-tasking<br>
since those other processes at that level would get a turn?<br>
<br>
Your reason was:  &quot;It means one cannot rely on cooperative scheduling<br>
within a priority level.&quot;  but I don&#39;t understand what you mean by<br>
&quot;rely on&quot;?<br></blockquote><div><br></div><div>A cooperative scheduler is one in which it is guaranteed that another process does not run until the active process chooses to yield.  This makes it easy to implement particular forms of synchronisation because processes are not preemptive.  The Smalltalk scheduler is a form of real-time scheduler in which processes have fixed priorities and are only preempted by higher-priroity processes.  This also makes it easy to implement various kinds of multi-process behaviour because one is guaranteed that a lower-priority process is never running while a higher priority process is able to run.</div>
<div><br></div><div>If one arranges that the scheduler does not put processes to the back of the run queue on preemption then within a priority level scheduling is cooperative and those simple synchronisation algorithms can still function when used by processes within the same priority.</div>
<div><br></div><div>One can still implement moving to the back of the queue on preemption with Smalltalk code if the VM does not, but one cannot prevent being put to the back if the VM does.</div><div><br></div><div>So having the VM not put processes to the back of the queue is generally more useful and flexible.</div>
<div><br></div><div>Your point about fairness is an important one, but being put to the back of the run queue on preemption does not in any way guarantee fairness.  Consider examples where some lower-priority process needs to kick a higher-priority process briefly, but the lower-priority process is contending with other lower-priroity processes.  The lower-priroity kicker can&#39;t avoid giving up the processor to the other contending processes and so the result could be unfairness.  Fairness is going to have to be defined in some context and a policy implemented to maintain that regime.  merely having the VM scheduler force an implicit yield on preemption is not enough to implement fairness.</div>
<div><br></div><div>cheers</div><div>Eliot</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5"><br>
<br>
<br>
On Tue, Apr 13, 2010 at 12:24 PM, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt; On Tue, Apr 13, 2010 at 9:53 AM, Bert Freudenberg &lt;<a href="mailto:bert@freudenbergs.de">bert@freudenbergs.de</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; On 13.04.2010, at 18:46, Eliot Miranda wrote:<br>
&gt;&gt;<br>
&gt;&gt; On Tue, Apr 13, 2010 at 9:24 AM, Randal L. Schwartz<br>
&gt;&gt; &lt;<a href="mailto:merlyn@stonehenge.com">merlyn@stonehenge.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &gt;&gt;&gt;&gt;&gt; &quot;Ang&quot; == Ang BeePeng &lt;<a href="mailto:beepeng86@yahoo.com">beepeng86@yahoo.com</a>&gt; writes:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Ang&gt; Are Squeak processes pre-emptive? Are infinite loop processes safe<br>
&gt;&gt;&gt; Ang&gt; to run?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Squeak uses a simple priority scheme.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; A Squeak process runs until it yields or it is interrupted by a higher<br>
&gt;&gt;&gt; priority process event.  When it is interrupted, it goes to the back of<br>
&gt;&gt;&gt; the queue, so when the higher priority process pauses or completes,<br>
&gt;&gt;&gt; other processes at the same priority are likely to be run instead.<br>
&gt;&gt;<br>
&gt;&gt; IMO the sending of the preempted process to the back of the queue is a<br>
&gt;&gt; bug.  It means one cannot rely on cooperative scheduling within a priority<br>
&gt;&gt; level.  On the other hand, if the VM does not send the preempted process to<br>
&gt;&gt; the back of the queue there is nothing to prevent a higher-priority process<br>
&gt;&gt; altering the run queues of lower priority processes, achieving the same<br>
&gt;&gt; thing.  But it is flexible if the scheduler code does it rather than the VM.<br>
&gt;&gt;  One can imagine per-process priorities being examined so that by default a<br>
&gt;&gt; process gets moved to the back of its run queue when preempted, but if a<br>
&gt;&gt; process has a &quot;don&#39;t preempt me&quot; property it is not.<br>
&gt;&gt;<br>
&gt;&gt; My guess is this odd behavior was like an accidental round-robin scheduler<br>
&gt;&gt; ... But changing it now might provoke rather obscure problems, no?<br>
&gt;<br>
&gt; That&#39;s certainly possible, but not the VisualWorks experience.  One can<br>
&gt; simply add a yield to allow other processes at the same priority level to<br>
&gt; run.  If there aren&#39;t any high-priroity processes running sporadically then<br>
&gt; one needs yields anyway.  So it is highly likely that in cases where the<br>
&gt; programmer wants to yield they have explicitly used a yield.  I think it<br>
&gt; much more likely that the current behaviour creates obscure problems because<br>
&gt; sometimes implicit yields occur and at other times they don&#39;t, depending on<br>
&gt; the state of finalization, whether delays are in progress or not, etc.<br>
&gt; But I agree it seems like a big change.  I just think it&#39;s a change for the<br>
&gt; better :)<br>
&gt; best<br>
&gt; Eliot<br>
&gt;&gt;<br>
&gt;&gt; - Bert -<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br>