SDL - simple beginner questions

Started by
11 comments, last by Coder21 19 years, 2 months ago
Quote:Original post by Drew_Benton
I think you do not have a full understanding of how threads work. On windows, even though it is a 'multi-threaded' system, general threads are still executed one at a time. This is because most computers do not have 2 cores/cpus to work with. I know on my P$ w/ HT, I can do 2 because it is the way it is engineered. On the new computers that are soon to come, they will have 4 cores so they can execute 4 at once.

Even the P4 only has a single core, though the hyperthreading unit apparently allows several threads to execute in parallel, to some degree—but it's still only one processor. The CPU's slated to hit the market this year are dual core CPU's, not quad core, and will be more or less equivalent to dual processor systems. (I've no idea if or how hyperthreading fits into Intel's scheme; I'm no hardware guy.) Of course, it's already possible to run multiprocessor systems (and today's N-socket 939 boards are tomorrow's 2*N CPU boards ...).

Quote:
Now I cannot illustarte the same W/ Threads because of the complexity, but it gets more confusing and complex. Basically if you had a threaded system, you would launch a thread for every enemy. This adds additional memory and cpu usage. Now you must sync all of the enemies so that they are only updated once per frame, this adds more cput and memory processing. Then you must make sure that all threads have finished before you can continue on in the main loop, drawing everything, once again more cpu and memory usage being wasted. Do you kind of see what I am talking about?

Of course, it gets worse. If you did have a multiprocessor system, you'd have a nightmare of locks with any shared/global data structures, and thread synchronisation; it's tricky enough, sometimes, with simulated concurrency, but gets worse with the real thing.

As a general note: Concurrency is a wonderful thing, but some problems lend themselves more easily to parallelisation—and some not at all.
Advertisement
Quote:Original post by Coder21

Now if threads aren't good as you say, then how do i update a few enemies on the screen at one?


Use a double buffer.
k thanks alot Drew , miserable and oberon :)

This topic is closed to new replies.

Advertisement