J
Joe Withawk
I have an application in which there exist a thread that handles directx
rendering. It runs on a dual core system with windows vista and xp.
It is set to have highest priority and simply loops with
while(isRendering)
{
prepare for rendering;
do render;
present()
}
It runs smoothly and then pauses very briefly and resumes.
I assume it has to do with windows wanting to do some background processing,
but I did not expect it to interrupt a high priority thread.
I am wondering if it has to do with the call to directx's present. It will
not always return immideately. Sometimes, when it has filled an outbuffer
with rendered frames (that buffer is small.. 2 or 3 frames), it will block.
If the thread blocks there then it will become idle and windows will grab
its processor for its own purposes and not release it again quickly enough.
This then causes the small pause in a high priority thread?
Generally with two cores and few processes, I beleive the core running the
critical thread will be more or less reserved for the thread and the other
core will be uses for low priority work. Is this not correct?
I am running low on ideas to how I should fix this, but it would help to
hear if my theory seem plausible at all. If it is, would the solution then
be to do a spin wait in the thread when I can see that present() will block?
Something like replacing present() with
while(presentWillBlock());
present();
This way the thread never powers down and should not worry about anyone
taking its core?
rendering. It runs on a dual core system with windows vista and xp.
It is set to have highest priority and simply loops with
while(isRendering)
{
prepare for rendering;
do render;
present()
}
It runs smoothly and then pauses very briefly and resumes.
I assume it has to do with windows wanting to do some background processing,
but I did not expect it to interrupt a high priority thread.
I am wondering if it has to do with the call to directx's present. It will
not always return immideately. Sometimes, when it has filled an outbuffer
with rendered frames (that buffer is small.. 2 or 3 frames), it will block.
If the thread blocks there then it will become idle and windows will grab
its processor for its own purposes and not release it again quickly enough.
This then causes the small pause in a high priority thread?
Generally with two cores and few processes, I beleive the core running the
critical thread will be more or less reserved for the thread and the other
core will be uses for low priority work. Is this not correct?
I am running low on ideas to how I should fix this, but it would help to
hear if my theory seem plausible at all. If it is, would the solution then
be to do a spin wait in the thread when I can see that present() will block?
Something like replacing present() with
while(presentWillBlock());
present();
This way the thread never powers down and should not worry about anyone
taking its core?