[squeak-dev] documentation on squeak vm api

Randal L. Schwartz merlyn at stonehenge.com
Thu Oct 16 10:52:10 UTC 2008

>>>>> "Kjell" == Kjell Godo <squeaklist at gmail.com> writes:

Kjell> I have noticed that Squeak seems to do Sockets by using Delays for x
Kjell> milliseconds and then waking back up to do something again.

I'm pretty sure that's not the case, because otherwise a Squeak webserver
image would be constantly consuming a noticable amout of CPU.

I believe that what actually happens is that you have a Semaphore that is
triggered either when a timeout happens or when data has arrived.  At the VM
level, this eventually maps to the actual select() or poll() call which
contains a file descriptor mask and the shortest timeout currently requested.
At this point, no CPU is consumed until the OS responds, at which point
the event is mapped back to the appropriate Semaphore wakeup.

At a higher level, the pattern is to request a read with a timeout of say, 5
seconds.  If the data is available immediately or soon, the 5 seconds is never
reached.  It's unlikely that you'd ask for no timeout, as there's probably
some other course of action you'd want to take if the data won't be arriving.

This is as I understand it, having looked at similar event loop dispatchers in
Perl, and the bits I remember looking at Socket and OldSocket from the image
level (not VM level) in Squeak.

Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

More information about the Squeak-dev mailing list