multithreading question

P

PJ6

I drive my game's physics engine using a simple loop running on its own
thread. It invokes Thread.Sleep(1) when processing takes little or no time
(under 4ms) to allow real time to catch up. For heavier loads the loop uses
bigger timeslices, up to 20ms, with no sleeps.

Since this is a multithreaded application, I decided to break out CHESS to
test the object (render) buffer for problems. But CHESS hates
Thread.Sleep() - it fails any test that hits one, calls it a livelock.

I ended up switching out the original realtime loop with a high resolution
multimedia timer, but I don't feel like it was a design improvement. I know
sleeping threads should generally be avoided, but what about in games? Using
a timer seems more... clumsy.

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top