limit streamdev client's ringbuffer timeouts to more sane values
Commit Message
Well, the streamdev-client reads data from a ringbuffer and when there isn't anything
to read it tries to sleep for 1us and loops. This wasn't a problem when the timer
resolution was in the 1000..10000us range (1000..100Hz); the usleep(1) call slept
for one or more milliseconds.
With the high-res timers in kernel 2.6.21+ usleep(1) is no longer treated as
usleep(10000) and the streamdev client is almost unusable; it uses most of the cpu
and causes hundreds of thousands context switches per second.
This gets rid of the almost-busy-loop.
artur
@@ -57,6 +57,7 @@ cStreamdevFilters::cStreamdevFilters(voi
cThread("streamdev-client: sections assembler") {
m_Active = false;
m_RingBuffer = new cRingBufferLinear(MEGABYTE(1), TS_SIZE * 2, true);
+ m_RingBuffer->SetTimeouts(10, 10);
Start();
}
@@ -111,8 +112,7 @@ void cStreamdevFilters::Action(void) {
}
}
m_RingBuffer->Del(TS_SIZE);
- } else
- usleep(1);
+ }
}
}