Help with threads

Ron Teitelbaum Ron at USMedRec.com
Mon Jan 23 00:40:14 UTC 2006


John,

In my case I'm running setup on SUnit, the high priority thread is only
waiting for all the lower priority threads to finish.  In a production
environment, having the system wait unit user processes are finished before
running background tasks is acceptable.  But for testing I just threw
SUnit>>setUp into a loop and said wait unit you get this expected result.  I
guess I could have suspended the process and waited for a signal instead.  

The comments on Processor>>yield says use to allow processing on a process
with the same priority.  Why is it that this didn't work even though they
are not the same priority?  Since A thread is at the active priority, and B
and C are at background, wouldn't a yield on A allow processor time to B and
C? (I'm assuming that there are no other higher priority threads running,
since even debugging allows the threads to finish).  I was calling yield
once each check loop.  What process was it yielding to?

I like the idea of maybe changing the controller to check processes that
want control and then use the controller loop time to bump up their priority
to give them some processor time.  Is that a good way to manage scheduling
time?  How responsive are the threads to changes in priority?

Thanks again for your help.

Ron Teitelbaum



> -----Original Message-----
> From: squeak-dev-bounces at lists.squeakfoundation.org [mailto:squeak-dev-
> bounces at lists.squeakfoundation.org] On Behalf Of John M McIntosh
> Sent: Sunday, January 22, 2006 4:00 AM
> To: The general-purpose Squeak developers list
> Subject: Re: Help with threads
> 
> Ah, well your generic smalltalk implementation has a simple scheduler.
> It does a round robin scheduling on the link list of processes ready
> to run sorted by priority.
> 
> See Interpreter>>primitiveYield & Interpreter>>wakeHighestPriority
> by yielding in a high priority task which is not waiting for anything
> just restarts that process and starves the lower priority processes.
> 
> If all three threads ran at the same priority then each would get
> some run time
> 
> Being smalltalk you can of course alter things and add a revised
> scheduler that uses suspend/resume or alter priorities to do process
> escalation and other
> features of more advanced schedulers.
> 
> However in your case you need to evaluate what your high priority
> task is doing? Should it be running non-stop, or waiting for the
> lower priority tasks to do something?
> 
> 
> On 21-Jan-06, at 8:30 PM, Ron Teitelbaum wrote:
> 
> > All,
> >
> >
> >
> > I have three threads, the active thread and two at
> > systemBackgroundPriority.  It appears that the primary thread is
> > preventing the others from running (I'm running tests in SUnit, and
> > the method in question is setup).
> >
> >
> >
> > I first thought that adding Processor yield would work but it
> > appears from the method comments, and my tests, that this doesn't
> > work.
> >
> >
> >
> > I added (Delay forMilliseconds: 10) wait.  and this worked.
> >
> >
> >
> > What is the proper way to allow background thread to operate and
> > get some processor time when there is an active processing running.
> >
> >
> >
> > Thanks for your help,
> >
> >
> >
> > Ron Teitelbaum
> >
> > Ron at USMedRec.com
> >
> >
> 
> --
> ========================================================================
> ===
> John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
> Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
> ========================================================================
> ===
> 





More information about the Squeak-dev mailing list