[Vm-dev] linux thread priorities

Igor Stasenko siguctua at gmail.com
Thu Feb 4 05:47:17 UTC 2010


On 4 February 2010 07:31, Eliot Miranda <eliot.miranda at gmail.com> wrote:
>
>
>
> On Wed, Feb 3, 2010 at 6:40 PM, Bert Freudenberg <bert at freudenbergs.de> wrote:
>>
>> On 03.02.2010, at 18:01, Eliot Miranda wrote:
>> > Our sound processing depends on a high-prirority thread running for a short time every 20 milliseconds to push data through the sound processing paths (microphone recording, OpenAL for spatialization, and so on).  On linux this approach is not immediately applicable
>>
>> Scheduling in Linux sucked for a long time, only optimized for server work. Depending on the kernel your users have running it may still be totally unsuitable for anything multimedia. There was a big hubbub about that on LKML where the leading developers did not even acknowledge there was a problem with the scheduler. A rewritten scheduler demonstrated much better performance, but was not accepted as-is. Google for Con Kolivas to learn more. It supposedly has gotten better but only very recently.
>>
>> You need to find someone to talk to who knows this stuff, I'm only watching from afar. Here's the general idea:
>>
>> http://x264dev.multimedia.cx/?p=185
>
> Thanks Bert!  Plenty to investigate here, but building a special kernel is something I didn't bargain for ;)
>
> I think one interim solution to explore is to run the sound pump from the VM thread in the VM's check for events code.  In the Cog VMs a 1KHz heartbeat updates the wall clock and causes the VM to break out of native code and check for events (ideally the heartbeat is a separate thread).  An mentioned, on linux the heartbeat is a software signal from an interval timer.  The software interrupt serves also to interrupt any system calls (e.g. in relinquishProcessorForMilliseconds).  I can extend the heartbeat to set a flag saying "run the sound pump" which will be checked by the VM when checking for events and it will invoke the sound pump code.  The problem here is that any long-running activities that aren't interruptable by the software interrupt (OpenGL rendering?) will delay the sound pump.  So this is either doomed to failure or might just work depending on those other activities.  Comments?  Try it, waste of time?

Well, if you need to run sound pump every 20ms or so, and heartbeat
interval is 1ms, there is a good chances that it will work fine.
Also, other thing to try, is making sure that in the buffer there is
enough data to play sound for 30ms or so, while refilling it every
20ms (or more frequently).

>>
>>
>> - Bert -
>>
>>
>
>
>



-- 
Best regards,
Igor Stasenko AKA sig.


More information about the Vm-dev mailing list