On Mon, May 1, 2017 at 4:42 AM, <raffaello.giulie...@lifeware.ch> wrote:

> On 30/04/17 17:01, Ben Coman wrote:
> >
> >
> > On Sun, Apr 30, 2017 at 10:11 PM, <raffaello.giulie...@lifeware.ch
> > <mailto:raffaello.giulie...@lifeware.ch>> wrote:
> >
> >     Hi,
> >
> >     I can't find a description on how ProcessorScheduler in Pharo (i.e.,
> >     Cog) is supposed to do context switches in absence of other
> >     synchronization points.
> >
> >     Is it following the BlueBook spec? Just to recall that model, the VM,
> >     when about to execute the current bytecode instruction of the current
> >     Process, checks whether a strictly higher priority Process is ready
> to
> >     run and if so, switches to (one of) the highest priority among them.
> >
> >     Thanks in advance for clarifications.
> >
> >
> > This topic is probably a bit advanced pharo-users list.
> > You'll likely get better answers in vm-dev list of pharo-dev list.
> > Can you post any follow ups there?
> >
> > ProcessScheduler doesn't have much to do with context switching,
> > except providing the #yield primitive for a user to invoke manually.
> > As you noted, the actual context switching happens in the VM.
> >
> > The charts here [1] might be useful to get an overview of the execution
> > loop.
> > Keep in mind though Its a very rough view of a novice exploring the Cog
> > execution engine
> > and may not be entirely accurate.  But it will give you a starting point.
> >
> > For another example, look at
> > CoInterpreterPrimitives>>primitiveEnterCriticalSection
> > in VMMaker (http://source.squeak.org/VMMaker).
> >
> > cheers -ben
>
> Hi Ben,
>
> of course, I can post the question on the pharo-dev mailing list and
> certainly will if nobody on this one can answer my question.
>
> However, Process is a Pharo user level class,


I was responding to your literal question about ProcessScheduler and what
part of the system does the context switching.
Now I'm guessing your interest is more about user-level
multi-threaded behaviour of Processes,
so I hunted down some discussions you may find  be interesting

* http://forum.world.st/The-Trunk-Kernel-mt-1009-mcz-td4887889.html
    (search for preemptionYields)

* http://forum.world.st/threading-in-Pharo-td4750534.html

* http://forum.world.st/threading-in-Pharo-td4750534.html

* http://forum.world.st/VM-Maker-VMMaker-oscog-eem-942-mcz-td4790993.html


However I didn't quite follow where you said...  "in absence of
other synchronization points."
Do you mean without suspend/resuming Processes or waiting/signalling
Semaphore
and something else?

I'm not sure if this is what your looking for, but in summary... Processes
at the same priority are scheduled cooperatively. they must deliberately
yield or sleep to be put at the back of their priority's run-queue.before
another process of same priority can run.  Higher priority processes
pre-empt lower priority processes only when they are woken (i.e. signalled
or resumed). The pre-empted process stays at the front of its priority's
run-queue so that the higher-priority-preemption is transparent to the
same-priority-cooperative scheduling.


not something private to
> the implementation of the vm. Any programmer should know what to expect
> and what to not expect when different Processes are started, and how
> they behave and interact. It's part of the general knowledge of the
> Smalltalk programming model, on par with Object, Class and Behavior.


> So, before I switch to the pharo-dev list, let's wait and see...
>
> BTW, it seems that reference [1], containing the charts you mention,
> could not find its way in your reply. Can you please make it available?
>
>
Whoops.
[1]  http://forum.world.st/CogVM-Execution-Flow-td4900675.html#a4900676


--------------------

Now a follow up question of my own, for [pharo-dev].
The Process comment says "When any one of several paths of control can be
advanced, the single instance of ProcessorScheduler named Processor
**determines** which one will actually be advanced partly using the value
of priority."

Did I misunderstand how this works?  I thought determination of which
process next ran occurred in the VM
by StackInterpreter>>wakeHighestPriority  and  ProcessorScheduler seems
more a place to just get values associated scheduling.

cheers -ben

Reply via email to