Hi VM people,<br><br>I apologise in advance for the length of this post.<br><br><div><span class="gmail_quote">On 9/27/07, <b class="gmail_sendername">Andreas Wacknitz</b> &lt;<a href="mailto:A.Wacknitz@gmx.de">A.Wacknitz@gmx.de
</a>&gt; wrote:</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div bgcolor="#ffffff" text="#000000"><blockquote type="cite">This patch fixes 4 problems which prevented the VM from building
<br>
on Solaris/SPARC.&nbsp; They shouldn&#39;t cause problems for other<br>
</blockquote>
Interesting that there is another guy running Squeak under Solaris.</div></blockquote><div><br>Yeah.&nbsp; I have an Intel Linux PC at&nbsp; work and a Sun SPARC at home.<br>How times have changed!<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000">Which version of the VM sources you are talking about?<br>
I have 3.9-8 running for quite some time on my Blade 2000.<br>
Although I haven&#39;t used sound yet.</div></blockquote><div><br>This is the Subversion sources that I&#39;m building, rev 1762. <br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000">
I have good experiences with Sun&#39;s CoolTools gcc for SPARC systems.<br>
This is a gcc-4.0.4 frontend with a SunStudio 12 code generator.<br>
The code runs at least twice as fast as with a plain gcc-3.4.3.</div></blockquote><div><br>Cool. That&#39;s good to know.<br>&nbsp;</div>With this patch, the VM builds and runs fine if built with gcc-3.4.3.<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000"><blockquote type="cite">
I&#39;ve checked both the stock 3.9a-7024 image as well as the <br>
etoys image. (My motivation for this whole exercise is to fix the<br>
problems with audio under Solaris for my young daughter to use
  <br>
etoys: the first sound plays, but after that, no sounds ever play.)<br>
  <br>
With gcc-4.2.1 and -O2, the VM won&#39;t even start up (complains<br>
about a missing vm-display-X11, even though it&#39;s there).&nbsp; With<br>
gcc-4.2.1 and no -O2, the VM starts, runs for a short while, and<br>
then cores with a bus error.&nbsp; gdb shows a corrupt stack.&nbsp; I&#39;m<br>
about to build gcc-4.1.2 and give it a spin building the VM to<br>
try to track this down.&nbsp; But I do suspect bad code generation
  <br>
with gcc-4.2.1.</blockquote></div></blockquote><div><br>I take back what I said about gcc-4.2.1.&nbsp; I&#39;m pretty sure that this was<br>due to user-stupidity (mine).<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000">
Did you manage to build libffi-2.0? This library is part of gcc-4.2.1.</div></blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div bgcolor="#ffffff" text="#000000">

AFAIK it is necessary for Squeak&#39;s FFI. I have only an old libffi-1.2.0
that<br>
has some Solaris bugs. So I don&#39;t have FFI which is needed for some
interesting<br>
packages (e.g. ODBC).</div></blockquote><div><br>Hmm. I haven&#39;t tried building libffi.&nbsp; That might be my next project,<br>once this is sorted out. Anyway, on to the sound problems.<br><br>1/<br>Thanks to the patch by 
<b>Wolfgang Helbig</b> at<br><a href="http://lists.squeakfoundation.org/pipermail/vm-dev/2006-January/000450.html">http://lists.squeakfoundation.org/pipermail/vm-dev/2006-January/000450.html</a><br>the problem was quite simple to fix.&nbsp; I made a few small changes,
<br>and sound is working on Solaris/SPARC hardware natively (no NAS<br>needed).&nbsp; Note that it looks like vm-sound-sun never implemented<br>recording; this is playback only (which is fine for my purposes).<br><br>2/<br>According to the squeak porting guide, to make sounds, the snd_Start
<br>C function is called.&nbsp; This is passed a (Squeak/smalltalk) semaphore<br>&quot;that should be signalled when input/output completes&quot;.&nbsp; I take it this
<br>means that the sound driver should signal the semaphore when the<br>sound device has space for writing.<br><br>(An old copy of the Squeak porting guide is here:<br><a href="http://coweb.cc.gatech.edu/squeakbook/uploads/porting.1.pdf" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

http://coweb.cc.gatech.edu/squeakbook/uploads/porting.1.pdf</a><br>I have a much newer version on paper, but I can&#39;t remember where<br>I got it.)<br><br>When I send a sound, it plays fine, but when I signal the semaphore
<br>that output has completed, the VM keeps writing more and more stuff to
<br>the sound device.&nbsp; I assume that it&#39;s writing &quot;silence&quot;, since I hear<br>nothing after the initial sound.&nbsp; But it does keep the CPU quite busy<br>as you might imagine.<br><br>3/<br>I have instrumented the C code where the VM checks for I/O (aioPoll),
<br>and under ordinary usage (keyboard, mouse, etc.) I get under 20<br>polls/second.&nbsp; As soon as a sound has started playing, this jumps<br>to 2300+ polls/second, and stays there, even when the sound is<br>played and silence reigns.
<br><br>I can&#39;t figure out why it would do this.
<br><br>Clearly, since the buffer is large enough to contain only a fraction<br>of a second of audio data, the semaphore is needed to tell the VM<br>to send some more data. And clearly the select() call in aioPoll will<br>
notice the file-descriptor for /dev/audio is writable as soon as the<br>first sample is played, and continuously thereafter, so I can<br>understand that during playback the poll-rate <span style="font-weight: bold;">should
</span> be high.&nbsp; This<br>problem should be fix-able by using the STREAMS SIGPOLL to<br>trigger the auHandle() function, rather than using select().<br><br>However, once the whole sound is played, why would the VM<br>continue playing nothing at full speed?&nbsp;
Even with the SIGPOLL<br>handler in place -- I&#39;m about to try it now -- the VM is still issuing<br>write() calls to /dev/audio several time per second, indefinitely.<br><br>I&#39;m sure I&#39;m missing something here...
<br><br>Andrew<br></div></div>