Assidragon on 9/12/2005 at 17:52
Quote Posted by ZylonBane
You are wrong.
Multithreading is a SUBSET of the available techniques for distributing CPU power.
No, you are wrong. It's not only to distribute available CPU power; it's rather to make the program work efficient, letting different processes work asynchronous so they only have to wait for a few of each other instead of running in a rigid scheme, and also lets different processes use more parts of the computer at once. like in modern games, the networking interface runs in another thread so it's not tied into the generic main-loop update, so it can receive or send packets faster instead of having to wait for say the renderer to finish drawing the current frame. Or to have the loading process in another thread, so the loading itself won't delay the rendering of the next frame, resulting in a much smoother background loading.
Quote Posted by ZylonBane
On a single-core system, as you should be well aware, only one "thing" is happening at any given moment in time (ignoring for the sake of the argument FPUs and the various pipeline optimizations on modern CPUs). So the closest a single-core system can come to simultaneity is to do things so quickly that they APPEAR to be happening simultaneously. Multithreading is only one way to do this. Another way, a way that's as old as gaming itself, is to just call a whole bunch of subroutines (each subroutine handling a particular game SYSTEM) from a main loop.
Since you apparently don't quite have a guess what is for what, let me use a short example.
Say someone makes a program in two variants. One that will has major parts divided into systems, and the other that has not. The two programs work exactly the same way aside from that.
Program A will do:
procedure updateFrame : draws frame
procedure updateSound : makes new sounds, stops old ones
procedure updateInput : takes user input
procedure updateAI : updates AI
so the main loop of A would look like:
procedure mainLoop:
updateInput
updateAI
updateFrame
updateSoundMeanwhile, B would not have all those nice systems only a main loop, which would look like:
procedure mainLoop:
update input
update AI
draw new frame
update the soundsThe first program has those systems, while the other has none such. You claim the system based approach would suddenly make everything appear to update simulatenously. Now, tell me
why on earth should the system based approach look updating anything more simultaneous than the non system based one.
It won't be any more simultaneous. In case you failed to notice, even in the system based case, your main loop won't do anything else than update the systems one by one, after each other, only launching one when the other has finished or was interrupted. If you at least spent a few seconds thinking about it, that's ABSOLUTELY not different than from having other sets of commands updating every little part of the game, apart from being a lot messy. And that is the point of the game having divided into systems: to make it easier to write, see through and debug. Not to make various parts run "effectively simulatenous".
As for where is that quote wrong. Two points. First, indeed, the single core CPU will process ASM commands one by one (not counting multiple pipelines and other optimizations). However one command can range from a dozen to hundreds of ASM commands, which means that in a multithreaded environment, while a command from a process is running, another from another could just as well be executed. So you can easily have two commands running on the same time. This of course does result in weird bugs and unexpected/random results if not programmed with needed caution.
Secondarily, various threads will access and use various peripherials (soundcard, graphics, HDD, memory) that might take a while (like rendering a frame, or loading in a big mesh takes a long time). One great pro of multithreading - and running more threads simultaneously - is letting the use of these peripherials not block each other. This again can result in messups, and complicates debugging/reverse engineering.
Quote Posted by ZylonBane
This appears to be what Thief does.
If you mean Thief is split into systems for easier debug/programming then yes. If you mean Thief is split into systems for "effectively simultaneous" running, no.
Quote Posted by ZylonBane
However, Thief also appears to implement a huge amount of self-adjusting optimization code to keep itself playable even on low-spec systems. This results in non-deterministic engine behavior based on CPU speed, graphics card speed, and the position of the Moon. For the canonical example of this, see Komag's (
http://www.ttlg.com/forums/showthread.php?t=55335&highlight=mind+master) Mind Master.
It's possible Thief would monitor how long each update function takes, and shut down/change them depending on the elapsed time. But this is again based on a command/function/macro inside the game, and as such, inside the source code, and as such, reverse engineerable (even if would be painsticking).
Quote Posted by jay pettitt
Yes there is. You can look up the word '
effectively' in the dictionary. You can try and understand context by reading the preceeding posts. You can also put the words in the right order. That would help.
Oh please.
Effectively every application appears to run updates at once, until one clogs up the common update pipe so much you can notice it yourself.
ZB, jay pettitt - instead of trying to prove me there are programs that run commands
effectively simulatenously without multithreading, get your obviously top knotch programming skills together show me one. With source code, of course.