<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Levente,<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 10, 2021 at 3:41 PM Levente Uzonyi <<a href="mailto:leves@caesar.elte.hu">leves@caesar.elte.hu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Hi Eliot,<br>
<br>
On Wed, 10 Feb 2021, Eliot Miranda wrote:<br>
<br>
> Hi Levente,<br>
> <br>
> On Wed, Feb 10, 2021 at 11:54 AM Levente Uzonyi <<a href="mailto:leves@caesar.elte.hu" target="_blank">leves@caesar.elte.hu</a>> wrote:<br>
>       On Wed, 10 Feb 2021, Eliot Miranda wrote:<br>
><br>
>       ><br>
>       ><br>
>       > On Wed, Feb 10, 2021 at 11:27 AM Jaromir <<a href="mailto:m@jaromir.net" target="_blank">m@jaromir.net</a>> wrote:<br>
>       >       > the right solution is to create a new primitive if we want to support<br>
>       >       on-the-fly priority changes.<br>
>       ><br>
>       >       The system already does on-the-fly priority changes - implementing<br>
>       >       #valueUnpreemptively and #valueAt: - but they're actually not working<br>
>       >       properly due to this #priority: issue - they're trying to use #yield after<br>
>       >       changing the priority down but that really doesn't do anything.<br>
>       ><br>
>       ><br>
>       > So it seems to me that updating the yield primitive to "do the right thing" is a good way to go.  Agreed?  If so, I should be able to get to that very soon.<br>
><br>
>       I think it's not. Let's say the priority of process p is 30, I want to<br>
>       increase it to 40 and then do something at that priority.<br>
>       #yield will stop the process and put it at the end of the list of<br>
>       processes with 40 priority (I think the current implementation doesn't<br>
>       check for priority changes and puts the process on the list of its<br>
>       earlier priority).<br>
>       So, with yield, p will have to wait until all other 40 priority processes<br>
>       finish their job or yield instead of just continuing as the active<br>
>       process.<br>
> <br>
> <br>
> But if that's the behaviour you want you can either<br>
> - set the priority, do the processing, and then invoke yield<br>
> - do the processing and then set the priority and then yield, right?<br>
> <br>
> We're not tying assigning to priority to the yield primitive, right?  These are still distinct operations.  I'm simply suggesting that the yield primitive take into account the receiver's priority, which it currently doesn't do.<br>
<br>
The current issue is that when a process's priority is decreased, e.g. <br>
from 42 to 40, and there's a process waiting to be executed at priority <br>
41, then that process will not be activated but the process with priority <br>
40 will keep on running.<br>
And, even yielding after the priority decrease doesn't help now.<br>
<br>
IMO, the ideal solution would be to<br>
1. Make sure that #yield lets all existing higher priority processes run <br>
besides all the same priority processes.<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">Agreed.  This means that yield should check to see if there is a runnable process at higher priority than the current process.  It doesn't do this.  It merely checks if there are processes at the same priority as the receiver.</div><div class="gmail_default" style="font-size:small"></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
2. When #priority: is sent to the active process to decrease its priority, <br>
then that process should<br>
        a) should keep running without interruption if there's no higher <br>
priority processes awaiting execution than the new priority<br>
        b) should be suspended if there are higher priority processes <br>
ready to run, and it should be resumed once all higher priority processes <br>
are suspended or terminated.<br>
<br>
Only fixing #yield does not help with the requirements in point 2.<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">Ah, yes, I see. That's tricky.  "Fixing" yield to ensure that the highest priority process is runnable and using it in Process>>priority: would have the unwanted side-effect of yielding.  So we may need another primitive.  A primitive that answered the highest runnable priority process would work.  Then we could write</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Process>>priority: anInteger</div><div class="gmail_default" style="font-size:small">    priority := anInteger.</div><div class="gmail_default" style="font-size:small">    ProcessorScheduler highestPriorityRunnableProcess priority > priority ifTrue:</div><div class="gmail_default" style="font-size:small">        [self yield]</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">That would be OK right?</div><div class="gmail_default" style="font-size:small"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Levente<br>
<br>
> <br>
> <br>
><br>
>       Levente<br>
><br>
>       > _,,,^..^,,,_<br>
>       > best, Eliot<br>
>       ><br>
>       ><br>
> <br>
> <br>
> <br>
> --<br>
> _,,,^..^,,,_<br>
> best, Eliot<br>
> <br>
><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div>