Re: [linux-audio-dev] Re: lock-free data structures

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] Re: lock-free data structures
From: Benno Senoner (sbenno_AT_gardena.net)
Date: Mon Jun 21 2004 - 04:01:12 EEST


Juhana Sadeharju wrote:

>>From: Tim Hockin <thockin_AT_hockin.org>
>>
>>
>>
>>>Quick question: disk thread may suspend if there are no disk use.
>>>How the disk thread is woken up to read the lock-free buffer?
>>>
>>>
>>Semaphore. Every time you put something into the buffer, up() the
>>
>>
>
>
>How this all is done in Ardour? I browsed the source but there are
>a lot of stuff there. How about LinuxSampler?
>
>

We use a very simple approach in LinuxSampler: in the disk thread if all
ringbuffers are filled or no voice is active then
we sleep for 30msec. It could be done with a semaphore too (or waiting
for a byte from a FIFO) but it's simply not worth
the trouble changing the current approach.
When the disk streamer gets busy the usleep() is not called and if it is
idle then periodical sleeps of 30msec aren't going
stressing the process scheduler in any way.
I know sleeping is not the "elegantest" method but it is the simplest
one and since we plan to support multiple disk threads
(one per physical disk) adding all the needed IPC in the audio thread to
communicate with the disk threads
(and since the datarate of the disk streams is dynamic (user moves the
pitchbender etc) the disk thread has no easy way to exactly
figure out when to wake up other than looking at the fill amount of each
active ringbuffer.

Just open the file

engines/gig/DiskThread.cpp

and search for: IsIdle (a boolean variable that indicates if the
diskthread needs to sleep a bit or if it did perform
disk I/O during the current cycle).

The idling/sleeping mechanism consist of 3 lines of code, not that
complex I'd say, and it works very well :)

cheers,
Benno
http://www.linuxsampler.org

>Juhana
>
>
>


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Mon Jun 21 2004 - 13:03:44 EEST