Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ziplux

Multithreading

This topic is 6512 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m making a multithreaded program. I made a funciton that I want to run, like this:
  
DWORD WINAPI func(LPVOID arg)
{
while(bQuit != true)
{
// do stuff

}
}
  
WHen I use CreateThread the create a thread that runs that function, my CPU usage goes thru the roof to 100 percent. Is there another way to do this without sitting in a busy while loop? Thanks in advance. My Geekcode: "GCS d s: a14 C++$ P+(++) L+ E-- W+++$ K- w++(+++) O---- M-- Y-- PGP- t X R- tv+ b++ DI+(+++) D- G e* h!" Decode my geekcode! Geekcode.com
Visit our web site: Asylum Entertainment

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
use sleep in the loop.

as long as your loop is running without ever relinquishing control of the thread, your cpu usage will always be 100%.

this isn''t always bad. you can give your thread a low priority and still use 100% of the cpu time. This way any time another process or thread needs the cpu, that thread will give the other process control.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!