|
[4.2] Windows multitasking CPU usage |
Gerwin Broers
Member #3,681
July 2003
|
I have two programs made with Allegro v4.2 (windows). I read about a CPU idle patch for allegro 4.4 in this forum, but did not find any reference to it in the latest allegro 4 changelog, so did not try v4.4 yet. There are task switch in and switch out hook functions, but since I don't know how to idle, what should I make the program do at task switch out? Main Project: HeroQuest. And Other Stuff |
Audric
Member #907
January 2001
|
If your program currently takes 100% (of one) CPU at all times, it lacks |
Gerwin Broers
Member #3,681
July 2003
|
wow, I just added "else rest(10);" at the end of the key polling and all multitasking troubles have vanished, while the program itself seems as snappy as before. I should have learned about this years ago. Thanks a lot Audric. Main Project: HeroQuest. And Other Stuff |
Thomas Fjellstrom
Member #476
June 2000
|
resting is not the best option. Look at the "Making use of the ticks" section of the Wiki's Timers Article. -- |
Audric
Member #907
January 2001
|
That section uses rest() too, were you thinking of the semaphore technique ? It saves less CPU, it would gain timing precision in theory (*) but I think the game is his "HeroQuest", a turn-based board game with little animation except the mouse cursor... The difference would be invisible. When it comes to CPU saving / optimization, my guidelines are (*) not on Windows because of its 10ms timer granularity |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Audric said: (*) not on Windows because of its 10ms timer granularity I think this is a badly perpetuated myth - I've never seen rest take more than an additional millisecond or so of overhead to return. (That's on Vista, and maybe XP as well). My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Elias
Member #358
May 2000
|
I guess maybe Windows 98 and also Linux systems from that time (it's a kernel setting there I think) could use 10ms. I have never seen it either though. [edit:] rest(10) instead of rest(1) will use 10ms of course. -- |
Gerwin Broers
Member #3,681
July 2003
|
This question was for TFDtool: I adjusted it to: Main Project: HeroQuest. And Other Stuff |
|