Skip to main content
GameDev.net gamedev.net
🔒 Locked

realtime priority???

Started by emmai Apr 14, 2004 at 8:20 PM 6 replies 950+ views
Original Post
emmai
emmai
I''d like my code running at RealTime priority, I do it like this
DWORD dwOldProcessP = GetPriorityClass(GetCurrentProcess());
DWORD dwOldThreadP = GetThreadPriority(GetCurrentThread());
SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_TIME_CRITICAL);
//

//...some instructions

//

SetThreadPriority(GetCurrentThread(), dwOldThreadP);
SetPriorityClass(GetCurrentProcess(), dwOldProcessP);
it does works on a AMD 2200+ cpu,when the instauctions been executed,I can''t move the mouse, but on a P4 2.4c cpu,it seems not running at Realtime priority,I can move my mouse or alt+tab to another apps,just like the instructions is running at normal priority!!! All OS is win2000 pro+sp4! can u tell me why this happened?thanks!
mfawcett
mfawcett
Yea...don''t run at RealTime priority. When you do that, your app has greater priority than even the operating system, and those mouse events are never even being fired.
--Michael Fawcett
emmai
emmai
but on a P4 2.4c cpu,it seems NOT running at Realtime priority,I can move my mouse or alt+tab to another apps,just like the instructions is running at normal priority!!!
SiCrane
SiCrane
Does the P4 2.4 you were using have hyperthreading?
emmai
emmai
quote:
Original post by SiCrane
Does the P4 2.4 you were using have hyperthreading?


yes!!!any ideas?
hplus0603
hplus0603
If you have hyperthreading, then that means that you have two logical CPUs. One of the logical CPUs runs your real-time thread; the other runs the mouse movement thread (and other threads wanting to run).

If you create two threads and make them both real-time, it''ll block out both CPUs.

Note that regular user accounts may or may not be able to set their process as real time class.
enum Bool { True, False, FileNotFound };
emmai
emmai
quote:
Original post by hplus0603
If you have hyperthreading, then that means that you have two logical CPUs. One of the logical CPUs runs your real-time thread; the other runs the mouse movement thread (and other threads wanting to run).

If you create two threads and make them both real-time, it''ll block out both CPUs.

Note that regular user accounts may or may not be able to set their process as real time class.


thanks a lot
Telamon
Telamon
If you are trying to implement a high-frequency callback function (only reason I could see to use a realtime thread) and you want your code to run on machines with only one CPU, use the Windows multimedia timers. That is what we do in our haptics class to update the forcefeedback at 1000 Hz.

----------------------------------------
Let be be finale of seem, seems to me.
----------------------------------------

Shedletsky''s Code Library:

Open source projects and demos

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.