<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>[4.2] Windows multitasking CPU usage</title>
		<link>http://www.allegro.cc/forums/view/608901</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 27 Nov 2011 00:16:04 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I have two programs made with Allegro v4.2 (windows). <br />When running these programs windowed, then switching out and load up another application to make a screenshot or something else: the system gets really slow. The system I tested this on is Windows 2000 SP5 on a single core Athlon 3000+. The programs are compiled with both MSVC6 and Dev-C.<br /> <br />For the second program, which is a development tool for a game, it is important to me that users can multitask it comfortably. The programs are mostly in a loop just polling the keyboard. </p><p>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.  </p><p>There are task switch in and switch out hook functions, but since I don&#39;t know how to idle, what should I make the program do at task switch out?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Gerwin Broers)</author>
		<pubDate>Thu, 24 Nov 2011 16:46:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If your program currently takes 100% (of one) CPU at all times, it lacks <br /><span class="source-code"><a href="http://www.allegro.cc/manual/rest"><span class="a">rest</span></a><span class="k2">(</span>number_milliseconds<span class="k2">)</span></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Audric)</author>
		<pubDate>Thu, 24 Nov 2011 17:01:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>wow, I just added &quot;else rest(10);&quot; at the end of the key polling and all multitasking troubles have vanished, while the program itself seems as snappy as before. </p><p>I should have learned about this years ago.</p><p>Thanks a lot Audric.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Gerwin Broers)</author>
		<pubDate>Fri, 25 Nov 2011 00:02:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>resting is not the best option. Look at the &quot;Making use of the ticks&quot; section of the Wiki&#39;s <a href="http://wiki.allegro.cc/index.php?title=Timers">Timers</a> Article.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Fri, 25 Nov 2011 01:01:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>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 &quot;HeroQuest&quot;, a turn-based board game with little animation except the mouse cursor... The difference would be invisible.</p><p>When it comes to CPU saving / optimization, my guidelines are<br />Priority 1) be sure to rest(&gt;0) when &quot;nothing to do&quot;<br />Priority 2) don&#39;t redraw the screen if nothing has changed<br />Priority 3) ...don&#39;t bother anymore <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p>(*) not on Windows because of its 10ms timer granularity
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Audric)</author>
		<pubDate>Fri, 25 Nov 2011 02:02:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/608901/938427#target">Audric</a> said:</div><div class="quote"><p>
(*) not on Windows because of its 10ms timer granularity 
</p></div></div><p>
I think this is a badly perpetuated myth - I&#39;ve never seen rest take more than an additional millisecond or so of overhead to return. (That&#39;s on Vista, and maybe XP as well).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Fri, 25 Nov 2011 02:06:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I guess maybe Windows 98 and also Linux systems from that time (it&#39;s a kernel setting there I think) could use 10ms. I have never seen it either though.</p><p>[edit:] rest(10) instead of rest(1) will use 10ms of course.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Fri, 25 Nov 2011 02:57:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This question was for TFDtool:<br /><a href="http://combatace.com/topic/68667-alternate-tfd-terrain-tilemap-editorviewer/">http://combatace.com/topic/68667-alternate-tfd-terrain-tilemap-editorviewer/</a><br />But I will also put it in heroquest when I find the time.</p><p>I adjusted it to:<br />if (keypressed())<br />{<br />   //key polling<br />}<br />else rest(5);
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Gerwin Broers)</author>
		<pubDate>Sun, 27 Nov 2011 00:16:04 +0000</pubDate>
	</item>
</rss>
