Click to See Complete Forum and Search --> : Shared memory and CPU time


Ryan Hagan
August 31st, 2000, 12:07 PM
Greetings,

I'm working with an engine library that is using a custom made shared memory algorithm. We have access to the shared memory in our code but we don't have the code for the library.

The problem we're running across right now is that in order to tell if a new message has come from the engine, we have to sit in a loop and continuously check the shared mem to see if it's been altered. That eats up 99% of the CPU time and there's nothing left for the engine for the Windows GUI.

Does anyone have any suggestions on how we can solve this problem? I wouldn't imagine it's too tough, but the answer seems to evade us at every turn. Thanks for the help!

--
Ryan Hagan
IncaGold USA
http://www.incagold.com/

CGhijselinck
August 31st, 2000, 06:17 PM
There is no other way than polling your memory unless the engine fires an event ( from which you have to know the name ). Another method could be that you create a thread that makes Sleep calls ( 20, 50 or 100 ms ) with less priority than your main application thread. Every time you wake up from the sleep, you check the memory. If it has changed, you fire an event from the thread to your main application thread. Instead of events you could also use windows messages if you prefer.

Christiaan