Sign in to follow this  
Kaptein

Relinquish cpu

Recommended Posts

Kaptein    2224

I'm implementing a wait() function, which I want to be multiplatform, and hopefully not use sleep().

 

Are there any functions on win and linux that allows you to just relinquish cpu time immediately?

I realize that sleep() does this, but I want to know what the alternatives are?

I'm guessing there are none, but I'm asking anyways.

 

 

Share this post


Link to post
Share on other sites
codenine75a    9

I do not like the sleep function because it causes a fixed delay.  I would loop a little bit and use the clock function.  It is under the ctime namespace or I believe time.h

Share this post


Link to post
Share on other sites
frob    44911

Neither system is a real-time operating system.  You can yield your time, but there are no guarantees about when the OS will reschedule you.

 

In fast-paced games usually the best bet is to wait for the screen buffer to flip. The major rendering APIs have blocking calls for that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this