Win32 and Priority Classes
I have a big problem and I hope that somebody here can help me with it!
When my Win32 application''s priority class (the app uses DD and D3D) is set to NORMAL, every 3rd or 4th time I start the application it''s really sloooow. I''ve tried this on two different computers.
So I tried to set the priority class to IDLE. Now the application should not run at all, should it? Well, it runs just perfectly on my computer. But only on my computer :-(. On every other computer it''s also very slow when it''s set to IDLE.
I should mention that there is a second thread in the background that runs as THREAD_PRIORITY_NORMAL and calls Sleep(0) at the end of every main loop. So that should give the CPU more processing time for my main process, right?
Well, I hope that somebody knows how to solve this. Please reply!
___________________________________________ //.athias .üller mmathias@magnet.at¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Well, it seems like nobody knows the answer to my problem. :-(
___________________________________________ //.athias .üller mmathias@magnet.at¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
That''s the thread priority your twiddling (not a ''class'' priority)
Whenever you have an unending amount of work to do, or long processor intensive work to do, you always set the priority to low or idle, usually idle.
Whats the main loop do?
It should probably Sleep(10) whenever there''s no msg''s
Whenever you have an unending amount of work to do, or long processor intensive work to do, you always set the priority to low or idle, usually idle.
Whats the main loop do?
It should probably Sleep(10) whenever there''s no msg''s
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
mmathias, a few things...
Priority Class and Thread Priority are 2 seperate things. Both of them together determine scheduling. There is tons of documentation about thread scheduling in MSDN, look there for details.
Sleep(0) will never yield control to your main thread if the thread calling Sleep(0) is a higher priority than your main thread. Sleep(0) is like telling the scheduler to end your timeslice early and follow normal scheduling rules (i.e. highest priority thread runs next). Since the calling thread is higher priority, it will be scheduled next. If you do a Sleep(1), it''s the same thing, but requesting that your thread not be considered for the next timeslice. That still won''t guarantee that your main thread gets called because there may be other threads on the system that are active.
In your case, and anytime that you want a thread to be called with any regularity, DO NOT set it to idle.
I don''t know what exactly you''re trying to accomplish, maybe you could explain better, but I can''t see your justification for changing priorities in the first place.
Let us know,
Jon
Priority Class and Thread Priority are 2 seperate things. Both of them together determine scheduling. There is tons of documentation about thread scheduling in MSDN, look there for details.
Sleep(0) will never yield control to your main thread if the thread calling Sleep(0) is a higher priority than your main thread. Sleep(0) is like telling the scheduler to end your timeslice early and follow normal scheduling rules (i.e. highest priority thread runs next). Since the calling thread is higher priority, it will be scheduled next. If you do a Sleep(1), it''s the same thing, but requesting that your thread not be considered for the next timeslice. That still won''t guarantee that your main thread gets called because there may be other threads on the system that are active.
In your case, and anytime that you want a thread to be called with any regularity, DO NOT set it to idle.
I don''t know what exactly you''re trying to accomplish, maybe you could explain better, but I can''t see your justification for changing priorities in the first place.
Let us know,
Jon
I have a thread dedicated to rendering the scene
I set the priority to Idle before I start the thread
It renders a new frame whenever there''s no msg''s & I never call Sleep
Is this not the way to do it? should I add a Sleep(0) at the end of the rendering?
I set the priority to Idle before I start the thread
It renders a new frame whenever there''s no msg''s & I never call Sleep
Is this not the way to do it? should I add a Sleep(0) at the end of the rendering?
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Well, I tried to adjust the process and thread priorities, because my application was terribly slow every 4th or 5th time I started it. But when I set the process priority to IDLE it runs fine every time. So I don''t really know what''s causing my problem....
___________________________________________ //.athias .üller mmathias@magnet.at¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement