Processor Scheduler

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Processor Scheduler

Ang BeePeng
Hi all.

I find that there are little material about processorScheduler on the wiki. Is it written in C, Smalltalk and C? It is the SchedulerAssociate, fourth special object, which mean VM knows about the class directly. I wish to know more, what VM know about processorScheduler? How it interacts with the VM? Which part of processorScheduler is in C and which part of it is in Smalltalk? When specialObjects being loaded from image, I assume they are all in C, true?

Thank you very much.

Ang Beepeng
Reply | Threaded
Open this post in threaded view
|

Re: Processor Scheduler

Bert Freudenberg
On 10.01.2010, at 16:25, Ang BeePeng wrote:

>
>
> Hi all.
>
> I find that there are little material about processorScheduler on the wiki.
> Is it written in C, Smalltalk and C? It is the SchedulerAssociate, fourth
> special object, which mean VM knows about the class directly. I wish to know
> more, what VM know about processorScheduler? How it interacts with the VM?
> Which part of processorScheduler is in C and which part of it is in
> Smalltalk? When specialObjects being loaded from image, I assume they are
> all in C, true?
>
> Thank you very much.

See pg. 254 of the Blue Book.

There are no "C objects" in Squeak.

- Bert -



Reply | Threaded
Open this post in threaded view
|

Re: Processor Scheduler

johnmci
Let me answer the question in a different way. If you wanted to insert code at the point where the process switch actually occurs,
this can only be done in the VM slang code.  

In general the transfer is

transferTo(wakeHighestPriority())

Except in the case of resume  where it's resume: theProcess and theProcess will be run if it's priority is > than the current process priority.
Does that mean it could preempt a higher ready to run (but not running) process? That is a exercise for the reader...

transfer is a result of  calling:
wait
        via primitiveWait, lurks on Semaphore
resume
        via primitiveResume
        via signal to a Semaphore
suspend
        via primitiveSuspend
yield
        via primitiveYield

Obviously you can control the use of wait, suspend, resume, yield in Smalltalk.  The "Signal to a semaphore" is harder
because that is either a smalltalk message send, or internal to the VM/plugins where various  semaphores are used:

The VM has the following semaphores:
LowSpace, if space "is low" signal it
Interrupt,  I'm not sure this is used in the VM it was for the interrupt key code logic pre event driven keyboard logic, it is used in Smalltalk code.
TimerSemaphore,  drives Delay logic, it wakes the Delay process when the next  Delay(s) expire.
FinalizationSemaphore, drives Finalization logic
GCSemaphore, optional wakes something at the end of a GC cycle.

Other Semaphores driven by plugins, like the 3 on a Socket instance.


wakeHighestPriority

Again in Slang is where the logic is done that decides what the "Highest Priority" task to wake is. Which is find the highest priority linked list and remove the first element from the list.
The reverse of this is when we place the process we are "suspending" that goes to the end of the linked list based on the Process priority.

This is not the most clever scheduling see http://en.wikipedia.org/wiki/Priority_inversion
for issues.  Changing the way it works can be done, check the archives and the VisualWork's mailing list archives I think you'll find other people have visited the problem


On 2010-01-10, at 7:56 AM, Bert Freudenberg wrote:

> On 10.01.2010, at 16:25, Ang BeePeng wrote:
>>
>>
>> Hi all.
>>
>> I find that there are little material about processorScheduler on the wiki.
>> Is it written in C, Smalltalk and C? It is the SchedulerAssociate, fourth
>> special object, which mean VM knows about the class directly. I wish to know
>> more, what VM know about processorScheduler? How it interacts with the VM?
>> Which part of processorScheduler is in C and which part of it is in
>> Smalltalk? When specialObjects being loaded from image, I assume they are
>> all in C, true?
>>
>> Thank you very much.
>
> See pg. 254 of the Blue Book.
>
> There are no "C objects" in Squeak.
>
> - Bert -
>
>
>

--
===========================================================================
John M. McIntosh <[hidden email]>   Twitter:  squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================