[squeak-dev] Re: Delay time question

David T. Lewis lewis at mail.msen.com
Thu Feb 28 12:36:19 UTC 2008


On Thu, Feb 28, 2008 at 01:53:26AM -0800, Robert F. Scheer wrote:
> 
> On Thu, 2008-02-28 at 00:18 -0800, Andreas Raab wrote:
> > Robert F. Scheer wrote:
> > 
> > > I probably don't understand the primitive serial methods well enough.
> > > They seem not to block while awaiting input so that requires
> > > continuously looping to read.  Is there a blocking method?
> > 
> > There isn't. Since Squeak doesn't use native threads internally (instead 
> > it uses so-called "green threads") a blocking read would block the 
> > entire VM and completely defeat the purpose of a blocking read. That's 
> > why all such primitives are designed to simply signal a semaphore so 
> > that the process in squeak just sits there doing something like:
> > 
> >    dataArrived := Semaphore new.
> >    self registerSemaphoreForSignallingData: dataArrived.
> >    [true] whileTrue:[
> >       dataArrived wait.
> >       self processData.
> >    ].
> 
> Yes, that's what I need.  Unfortunately being a Squeak newbie and having
> one month till competition, this looks like an insurmountable gap to me
> atm.  But if it existed, I'd be in heaven.

Robert,

I don't have time to read catch up with this thread, but FYI the
kind of event driven input that Andreas describes is implemented in
AioPlugin and OSProcess. CommandShell uses this heavily with pipes. I
do not know if it will work with serial lines (/dev/ttyXX) but I can't
think of any reason that it wouldn't.

With that sort of approach, you would use one Squeak process to service
each inbound serial connection, and each process would wait on a semaphore,
so no polling required. The Linux serial drivers handle the IO buffering
etc, so it might work fine.

Sorry I don't have any performance numbers to quote, and I've never
tried it on /dev/ttyXX.

HTH,
Dave
 



More information about the Squeak-dev mailing list