You are not logged in to Prodigits. Please register or login.
Subject: Sleep()
Replies: 10 Views: 868
edit.or 4.06.11 - 01:20pm
jesus christ,i can't beleive how stupid windows can be. i guess it can't let anything go smooth,not even programming simple GDI graphics... yeah,i know GDI is supposed to be slow but it just fits my needs cause i don't wanna use any third party library like allegro (....) or r*pe open_gl for a tiny little game. so,the game loop was using about 50 of the cpu which is normal considering it is about * +
edit.or 4.06.11 - 01:24pm
about infinite while loop. and i normally put like Sleep(33),cause 1sec equals 1000ms.. and if 30fps then thats about it,render frame per second. but no,that way incredibly slow.... so i try Sleep(10) but that was laggy. sleep(1) done the job perfectly.everything works fine,spent an entire night adding features to the game,optimising the code,fixing bugs.... and i do a final test. it rocks! i go * +
edit.or 4.06.11 - 01:31pm
i go to sleep and THE NEXT MORNING,IT LAGS LIKE HELL (here is the problem in caps). after a little commenting,checking cpu and memory usage and bi * * ing around,cpu being zero,system memory usage 200 and something MB,i get to the idea to remove Sleep() completely.the game was running fine but very fast with 50 cpu. and to cut it short i do a research and find out the common confusion about Sleep * +
edit.or 4.06.11 - 01:35pm
about Sleep() - and this is important for any programmer to know. Sleep(minimum miliseconds to wait before waking the program),it doesn't mean this interval will allways be correct.so if you write Sleep(33) it DOESN'T MEAN that the program will continue after 33ms,it means it will wait minimum 33ms before waking up,and that can extend to even 1sec and more depending on some other factors.......... * +
edit.or 4.06.11 - 01:38pm
THE PROBLEM: is there anything in windows that can put the program to sleep for exact time specified? * +
jay.mack 4.06.11 - 02:20pm
give it the big sleep... (hit it with a hammer) * +
phemzask 4.06.11 - 05:20pm
Have u tried join() ? * +
mok214 4.06.11 - 07:20pm
You gotta be smarter than the computer . Remember GIGO : garbage in , garbage out .
* +
+ go to page 1-2
+ my page
+ functions
3 search
4 submit a reply
7 last page
+ bookmark
8 Tech&Computers Forum
9 Forum Index