Hi all interested,
I am not sure, if this is really related to the topic. Anyway,
I made an experience with threads and their priorities on Windows.
If one thread has higher priority then the other, it does not mean that
the time will be divided between the threads. Actually, the higher
priority thread will receive all the time. The only exceptions will be
its waits on I/O, when other lower priority threads can get a chance.
I wanted two threads to cooperate. So, I set them the same priority. But
I realized that Windows is switching them in 93ms intervals. Actually,
it is 6 times time quantum 15.6ms. Some processors have the quantum 10
ms, probably resulting in 60ms. Anyway, 93ms was too long for real-time
rendering and backgroung task that was doing some scene processing. It
was simply jerky.
My only chance was to crush 93ms into the single quantum of 15.6ms.
I made many experiments based on one control thread and two workers and
functions like SwitchToThread, SuspendThread, and similar. Finally, the
solution is easy - Sleep(1) makes the current process (of any priority)
to give up current quantum and different thread (probably of lower
priority) will receive the 15.6 ms. Then, the control gets back to the
control thread that can decide whether it wants to give the lower
priority thread another quantum or wheter it wants to do something on
its own.
That worked also as one manager thread and several workers - the manager
just increases the priority of one of its workers, perform Sleep(1)
and that one receives the quantum. Then, it may increase the priority of
other one and so on.
Just word of warning: better to never use SuspendThread (deadlocks), it
is much better to control threads by priorities.
That is my experience with threads on Windows...
I have sources somewhere...
Cheers,
John
Zach Deedler napsal(a):
Hello,
I didn't find anything funky with the timers. They all seemed to be
reasonable values. However, now that I'm running on one CPU, I get cases in
which I don't get areas paged in. These seem to be around the same areas
that used to hitch badly. I've created ways to change vsync interval, and
multi-cpu dynamically. If I do either of these, then the area seems to page
in, usually. So, I'm guessing that enabling vsync interval is doing
something that pre-empts the paging from even happening. I say this because
playing with the priority of the paging thread doesn't seem to help much.
Any ideas, or what I can try next?
Thanks.
By the way, I'm doing this while also porting to Linux to double my chances
of success.
Zach
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/