Recommended Posts

Hello,
I'm in the prototyping phase for a game engine and I have the following situation: The game engine will be divided in several components/tasks that will be executed in a sequential order:
Input -> Physics -> Render -> Audio -> Resources -> Scripts
My approach to this work-flow was to design a kernel class that will call all the tasks found in an array based on the following conditions:
- the task must be executed if is marked as mandatory,
- a non-mandatory task can be skipped if there is not enough time in the current kernel cycle.

Share this post

Link to post

Share on other sites

Yes, that will work, but I imagine you'll want a more complex implementation than that. What you really want is a priority queue weighted by how much CPU time the task has gotten recently times whatever fixed priority you've given your processes. If you don't do that, when some of your mandatory processes get busy, the non-mandatory processes will *never* get any CPU (which I doubt you'll want). A weighted priority queue ensures that they'll get at least *some* CPU.

A good real-world example is kernel threading.

What sort of platform or API are you developing for? For example, with pthreads, you can just let the kernel handle prioritization and process switching for you. Which is probably the best approach.

0

Share this post

Link to post

Share on other sites

Thank you for the quick answer. I will have to look in both of your recommendations: adding priorities and pthreads. The prototype is not made for a specific API. The integer types were just typedef to other names and the intended platform is Win32.