<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Wieso haben alle Schleifen bei maximaler Iteration...]]></title><description><![CDATA[<p>nur eine CPU auslastung von ~50%? Egal, wie ich Programmiere, ich komme nie auf eine höhere Auslastung... Liegt das daran, dass nicht alle Kerne meines CPUs belastet werden? (Habe eine Dual-Core CPU)</p>
<p>Danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/275461/wieso-haben-alle-schleifen-bei-maximaler-iteration</link><generator>RSS for Node</generator><lastBuildDate>Wed, 26 Aug 2026 23:24:13 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/275461.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 14 Oct 2010 23:56:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wieso haben alle Schleifen bei maximaler Iteration... on Thu, 14 Oct 2010 23:56:53 GMT]]></title><description><![CDATA[<p>nur eine CPU auslastung von ~50%? Egal, wie ich Programmiere, ich komme nie auf eine höhere Auslastung... Liegt das daran, dass nicht alle Kerne meines CPUs belastet werden? (Habe eine Dual-Core CPU)</p>
<p>Danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1965878</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1965878</guid><dc:creator><![CDATA[HELPVISTAWIN7]]></dc:creator><pubDate>Thu, 14 Oct 2010 23:56:53 GMT</pubDate></item><item><title><![CDATA[Reply to Wieso haben alle Schleifen bei maximaler Iteration... on Thu, 14 Oct 2010 23:58:27 GMT]]></title><description><![CDATA[<p>Ja.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1965879</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1965879</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 14 Oct 2010 23:58:27 GMT</pubDate></item><item><title><![CDATA[Reply to Wieso haben alle Schleifen bei maximaler Iteration... on Fri, 15 Oct 2010 00:05:51 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>Ja.</p>
</blockquote>
<p>Und wie kann ich bei <strong>einem</strong> Programm beide Kerne belasten?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1965884</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1965884</guid><dc:creator><![CDATA[HELPVISTAWIN7]]></dc:creator><pubDate>Fri, 15 Oct 2010 00:05:51 GMT</pubDate></item><item><title><![CDATA[Reply to Wieso haben alle Schleifen bei maximaler Iteration... on Fri, 15 Oct 2010 00:13:20 GMT]]></title><description><![CDATA[<p>HELPVISTAWIN7 schrieb:</p>
<blockquote>
<p>volkard schrieb:</p>
<blockquote>
<p>Ja.</p>
</blockquote>
<p>Und wie kann ich bei <strong>einem</strong> Programm beide Kerne belasten?</p>
</blockquote>
<p>Indem Du <strong>zwei</strong> Threads in <strong>einem</strong> Programm benutzt. Ist aber noch nicht in Standard-C++ dabei.<br />
Win32: CreateThread, _beginthread,<br />
linux: pthread_create, fork<br />
boost: bost::thread<br />
Winforms: Backgroundworker<br />
.Net: System::Threading::Thread<br />
Compilermagie: openmp<br />
usw...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1965886</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1965886</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 15 Oct 2010 00:13:20 GMT</pubDate></item><item><title><![CDATA[Reply to Wieso haben alle Schleifen bei maximaler Iteration... on Fri, 15 Oct 2010 00:21:00 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>HELPVISTAWIN7 schrieb:</p>
<blockquote>
<p>volkard schrieb:</p>
<blockquote>
<p>Ja.</p>
</blockquote>
<p>Und wie kann ich bei <strong>einem</strong> Programm beide Kerne belasten?</p>
</blockquote>
<p>Indem Du <strong>zwei</strong> Threads in <strong>einem</strong> Programm benutzt. Ist aber noch nicht in Standard-C++ dabei.<br />
Win32: CreateThread, _beginthread,<br />
linux: pthread_create, fork<br />
boost: bost::thread<br />
Winforms: Backgroundworker<br />
.Net: System::Threading::Thread<br />
Compilermagie: openmp<br />
usw...</p>
</blockquote>
<p>Verstehe. Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1965888</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1965888</guid><dc:creator><![CDATA[HELPVISTAWIN7]]></dc:creator><pubDate>Fri, 15 Oct 2010 00:21:00 GMT</pubDate></item><item><title><![CDATA[Reply to Wieso haben alle Schleifen bei maximaler Iteration... on Fri, 15 Oct 2010 10:20:58 GMT]]></title><description><![CDATA[<p>HELPVISTAWIN7 schrieb:</p>
<blockquote>
<p>volkard schrieb:</p>
<blockquote>
<p>HELPVISTAWIN7 schrieb:</p>
<blockquote>
<p>volkard schrieb:</p>
<blockquote>
<p>Ja.</p>
</blockquote>
<p>Und wie kann ich bei <strong>einem</strong> Programm beide Kerne belasten?</p>
</blockquote>
<p>Indem Du <strong>zwei</strong> Threads in <strong>einem</strong> Programm benutzt. Ist aber noch nicht in Standard-C++ dabei.<br />
Win32: CreateThread, _beginthread,<br />
linux: pthread_create, fork<br />
boost: bost::thread<br />
Winforms: Backgroundworker<br />
.Net: System::Threading::Thread<br />
Compilermagie: openmp<br />
usw...</p>
</blockquote>
<p>Verstehe. Danke!</p>
</blockquote>
<p>bezweifel ich</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1966006</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1966006</guid><dc:creator><![CDATA[zweifler]]></dc:creator><pubDate>Fri, 15 Oct 2010 10:20:58 GMT</pubDate></item><item><title><![CDATA[Reply to Wieso haben alle Schleifen bei maximaler Iteration... on Sat, 16 Oct 2010 08:43:10 GMT]]></title><description><![CDATA[<p>Du kannst schlecht einen 'Programmlauf' auf zwei Cores verteilen. Da würden die ganze zeit Fehler auftreten, da das ding nicht synchron läuft.</p>
<p>Wie gesagt, unter Windows benutzt du dann die WinAPI, unter Mac und <a href="http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html" rel="nofollow">Linux</a> POSIX. Boost bietet eine gute portable threading library an.</p>
<p><a href="http://de.wikipedia.org/wiki/Thread_(Informatik)#Windows" rel="nofollow">Wikipedia</a></p>
<p>Oder in einem <a href="http://forum.fachinformatiker.de/c-compiler-ides-apis/77026-thread-fuer-anfaenger.html" rel="nofollow">Forum</a> gefunden:</p>
<p><strong>EDIT:</strong><br />
Die Sleep(..); Anweisungen wird die CPU-Auslastung verhindern.</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;

DWORD WINAPI MyThreadSagWasAndauernd(LPVOID parameter)
{
   // parameter wird in diesem Beispiel nicht genutzt
   while(true)
   {
      printf(&quot;was...\n&quot;);
      Sleep(1000);
   }
}

int main()
{
   // Starte einen Thread:
   // EDIT: zu CreateThread guck mal zwei Posts weiter bei Vicious Falcon
   CreateThread(NULL, 0, MyThreadSagWasAndauernd, NULL, 0, NULL);
   // Kurz warten...
   Sleep(500);
   // Und noch eine Endlosschleife:
   while(true)
   {
      printf(&quot;anderes...\n&quot;);
      Sleep(1000);
   }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1966028</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1966028</guid><dc:creator><![CDATA[lk]]></dc:creator><pubDate>Sat, 16 Oct 2010 08:43:10 GMT</pubDate></item><item><title><![CDATA[Reply to Wieso haben alle Schleifen bei maximaler Iteration... on Fri, 15 Oct 2010 12:01:32 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/21699">@lk</a> das Sleep wird das mit der CPU auslastung verhindern</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1966047</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1966047</guid><dc:creator><![CDATA[evilissimo]]></dc:creator><pubDate>Fri, 15 Oct 2010 12:01:32 GMT</pubDate></item><item><title><![CDATA[Reply to Wieso haben alle Schleifen bei maximaler Iteration... on Fri, 15 Oct 2010 13:50:16 GMT]]></title><description><![CDATA[<p>Mit OpenMP kann man eine for Schleife ganz leicht aufteilen.</p>
<pre><code class="language-cpp">#pragma omp parallel for
for (int i = 0; i &lt; 1000; ++i) {
  a[i]= 2 * i;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1966087</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1966087</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Fri, 15 Oct 2010 13:50:16 GMT</pubDate></item><item><title><![CDATA[Reply to Wieso haben alle Schleifen bei maximaler Iteration... on Fri, 15 Oct 2010 17:05:15 GMT]]></title><description><![CDATA[<p>lk schrieb:</p>
<blockquote>
<pre><code class="language-cpp">printf(&quot;was...\n&quot;);
</code></pre>
<p>und</p>
<pre><code class="language-cpp">CreateThread(NULL, 0, MyThreadSagWasAndauernd, NULL, 0, NULL);
</code></pre>
</blockquote>
<p>Ist printf nicht eine Funktion aus der CRT?<br />
Es gibt wirklich viele Probleme, wenn man mit CreateThread einen Thread startet, der Funktionen der CRT nutzt. Das Problem ist, dass man andauernd denkt, mit der Synchronisation laufe irgendetwas falsch.<br />
Wenn man Funktionen der CRT in einem Thread nutzen möchte, dann sollte <a href="http://msdn.microsoft.com/en-us/library/kdzttdcb%28VS.80%29.aspx" rel="nofollow">_beginthread(ex)</a> verwendet werden. Steht auch in der Beschreibung von <a href="http://msdn.microsoft.com/en-us/library/ms682453%28VS.85%29.aspx" rel="nofollow">CreateThread</a></p>
<blockquote>
<p>A thread in an executable that calls the C run-time library (CRT) should use the _beginthreadex and _endthreadex functions for thread management rather than CreateThread and ExitThread;</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1966181</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1966181</guid><dc:creator><![CDATA[Vicious Falcon]]></dc:creator><pubDate>Fri, 15 Oct 2010 17:05:15 GMT</pubDate></item></channel></rss>