I need a function to stop the cpu from doing is work for some seconds.
The seconds passed as argument would be great.
Does something like this exist?
For example:
wait(7); makes the cpu stop for 7 seconds before passing to the next instruction.
wait function?
Started by Max.89, Jan 02 2009 07:56 AM
3 replies to this topic
#1
Posted 02 January 2009 - 07:56 AM
|
|
|
#2
Posted 02 January 2009 - 08:16 AM
Max.89 said:
I need a function to stop the cpu from doing is work for some seconds.
The seconds passed as argument would be great.
Does something like this exist?
For example:
wait(7); makes the cpu stop for 7 seconds before passing to the next instruction.
The seconds passed as argument would be great.
Does something like this exist?
For example:
wait(7); makes the cpu stop for 7 seconds before passing to the next instruction.
Are you talking about giving cpu cycles back to the OS? If this is the case, then I suggest that you look for a sleep function, not a wait function.
You could also search Google for things like "sleep function" or "give up cpu cycles", but you might also want to include your OS in the search because such functions are often OS specific.
I haven't looked into this, but I've heard before that you could use the functions found in time.h to create wait functions. The downside is that it's not guaranteed to work, and again it's system dependent.
Dave
#3
Posted 02 January 2009 - 03:18 PM
in C++, you can cause the computer to stop using the sleep command included in windows.h.
The sleep command has to be capitalized in windows systems and works in milliseconds(ie. 7000 pauses the computer for 7 secs.)
#include <windows.h>
int main(void)
{
Sleep(1000);
}
The sleep command has to be capitalized in windows systems and works in milliseconds(ie. 7000 pauses the computer for 7 secs.)
#4
Posted 04 January 2009 - 06:07 PM
If you want it to wait for something to happen, you can use events... Try looking up the following functions in MSDN...
Sleep();
SleepEx();
SetEvent();
ResetEvent();
CreateEvent();
OpenEvent();
CloseHandle();
Those should be all you need.
Oh, and if it's time that you're waiting for, use Sleep();
Sleep();
SleepEx();
SetEvent();
ResetEvent();
CreateEvent();
OpenEvent();
CloseHandle();
Those should be all you need.
Oh, and if it's time that you're waiting for, use Sleep();


Sign In
Create Account

Back to top









