Reputation: 21
I come from an embedded background, where hard real-time is taken quite seriously. For me (fast) real time is tricky on Linux, and ludicrous on Windows, jet video games seem to be doing just fine.
Obviously, since it's only soft real time, and the frequency is (relatively) low with 60+ Hz, the simple solution is to render as fast as possible and hope for the best. But are there any advanced techniques in use that further enhance the responsiveness on Windows?
Some concrete questions:
Any insight would be welcome!
Edit:
I've looked through a few resources and have added my conclusions:
1. Q: What happens when a time critical calculation gets pre-empted?
A: The thread should have higher priority so pre-emption is rare, and when it happens, the interruption should be brief (short interrupts or IO-operations).
Windows has the capability to move threads to other cores, thou it is recommended to keep them locked ( -> Thread Affinity).
2. Q: Should IO-operations have a higher priority than the render loop?
A: Yes, Naughty Dog's engine gives IO-operation higher priority.
A: In the presentation, a job system is used (similar to reactive programming).
It uses three priorities that are non-preemptive.
Upvotes: 1
Views: 351
Reputation: 662
I recommend you read Modern Operating System from Ph.D Andrew Tanenbaum if you haven't read it. His book also have Unix and Windows architecture.
One most major thing: Game programming is different than Embedded programming
I had worked with Windows and Android (Unix-like). Not only Windows but also Android very hard rendering too meet hard real-time. One of our tricks to reduce CPU, GPU latency is using lower feature driver support for the visual effect (which mean if hardware not support good this new graphic API, we will use older API so this will make object less shape and less beauty) or if device is not support the feature and effect is not important, just remove this effect for that device. It will push FPS (frames per second) better.
Game engine is also difference between many graphic APIs, use Vulkan or DX12 (Windows) or Metal (Apple devices) is make more FPS but require newer hardware, because they are low-level APIs. It will give you better performance, more beautiful than OpenGL or DX11, but old APIs is support on older devices.
And 3 your questions, I will answer with my knowledge (may be there is a better answer from other):
I also have a small question: Why don't you use thread
, atomic
, mutex
C++ 11 APIs for share tasks with multi-core CPU? It easier for thread programming, cross-platform and no need to schedule anything.
Windows has classic Win32 thread APIs SetThreadPriority for set the relative priority of a thread. This API isn't recommended for Windows Runtime (Modern Windows concept from Microsoft for Windows 8 and later) which recommended using thread-pool concept instead (use modern API will automation parallel tasks with multi-core, which is better than manually config use classic API).
In Game engine, there is a presentation of Christian Gyrling from Naughty Dog talking concept Parallel and Sergey Makeev from Roblox implement open source TaskScheduler base this concept in Win32 APIs and Pthread APIs. Jeff Preshing from Ubisoft also have a presentation using C++ 11.
What did you mean about IO-latency? Keyboard, mouse or Disk IO? I will edit answer if you edit your question more clear
I can't find a document or anything similar Earliest Deadline First / Rate Monotonic Scheduling on Windows. May be this is limited by prevent kernel mode scheduling from Microsoft.
Upvotes: 1