Re: [Dev-C++] sleep() for Windows XP
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: matheus r. <mfr...@gm...> - 2007-07-24 04:32:42
|
But it also eats your cpu cycles... Sleep doest consume CPU.
2007/7/23, Adam Jones <aj...@i-...>:
> Just in case you are interested, here is a platfrom independent way to cause
> your program to sleep without using sleep() or MS version Sleep(). It also
> avoids preprocessors commands.
>
> #include <time.h>
>
> Int main()
> {
>
> unsigned int clockTicks; //Stores the amount
> of time you want to pause execution in clock ticks
> clock_t ticksReached; //Stores the amount
> of clock ticks
>
> clockTicks = 3000; //set pause to 3 seconds
> ticksReached = clockTicks + clock(); //get number of
> clocks tick since program started then add the addition wait time
> while (ticksReached > clock()); //loop until current clock
> ticks equal the ticks needed to wait
>
> return 0;
> }
>
> It is more code, but it is platfrom independent and free of preprocessor
> commands.....
>
> -Adam Jones
>
>
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf Of Adam Jones
> Sent: Monday, July 23, 2007 10:24 PM
> To: 'Jamiil Abduqadir'; 'Dev Cpp MailingLinst'
> Subject: Re: [Dev-C++] sleep() for Windows XP
>
> >>You wrote:
> >> Does anyone know where I can find a source code for such service, so that
> it is a portable sleep() function?
>
> Why do you feel the need to cause your program to sleep(). There may be
> other ways of pausing executive without using a platform dependent command.
> Or using #defines. If you could provide more details, that may be helpful.
>
> -Adam Jones
>
> From: dev...@li...
> [mailto:dev...@li...] On Behalf Of Jamiil
> Abduqadir
> Sent: Monday, July 23, 2007 3:37 PM
> To: Dev Cpp MailingLinst
> Subject: [Dev-C++] sleep() for Windows XP
>
> Using GCC, I developed some small apps under Linux, now I am trying to port
> this apps to MSWinXP, but there are some Unix functions that are not
> availableunder MS, sleep() is one of them. Does anyone know where I can
> find a source code for such service, so that it isa portable sleep()
> function?
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|