Thread Synchronisation
OK...
What I would like is a render thread which renders constantly. I also have a "render stack" which is a stack of routines to be called for rendering. Whenever a menu or such is opened, its display routine is added to the render stack.. and when it is closed its display is taken out of the render stack...
Problem is: I cant have one thead (game engine) modifying the render stack when the render thread is going thru it, or some value could not be written yet by the game engine, and the render stack will be trying to use it.... (instant GPF
I was thinking I would just make a bool, which stipulates if the stack is in use or not.. and then threads modify the bool to true when they are using it, and false when they are not...
However, I still see potential problems with that.
Suggestions? (platform im developing under is win32 using DX7)
regards,
GeniX
regards,GeniXwww.cryo-genix.net
Critical sections are a good place to start, but if you use them exclusivly, performance will begin to hurt. What you might want is a scheme that allows multiple threads to read from your stack, locking out writers, and then letting writer-thread write to it, locking out the readers. I would explain the algorithm, but the code takes about 3 pages in a book I own. If you want to look for it, there is a great book on writing multithreaded apps in Win32. It is called "Multithreaded Programming with Win32". It is written by Thuan Q. Pham and Pankaj K. Garg. It is published by Prentice Hall. I really like it. Lots of examples.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement