Thread overview
[Issue 3859] New: 100% CPU with thread in a loop
Feb 27, 2010
bremby@seznam.cz
Feb 27, 2010
bremby@seznam.cz
Apr 01, 2013
Martin Krejcirik
February 27, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3859

           Summary: 100% CPU with thread in a loop
           Product: D
           Version: 1.053
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bremby@seznam.cz


--- Comment #0 from bremby@seznam.cz 2010-02-27 02:17:30 PST ---
When I create a thread in a while loop, the first time it is created it works, the second time dual-core CPU gets up to 100% load and stucks in there. Tested with DMD 1.053. When compiled with latest GDC, only one core gets to 100%, the other one is fine.

Code:

class doNothing : Thread;

while(condition){
   Thread test = new doNothing();
   test.start;
   test.wait(1000);
}

Reproducible: Always.

System: Ubuntu 9.10, x86, Core 2 Duo

The doNothing thread just wastes CPU cycles, I wrote it as a test for the
wait() method. The test instance gets terminated after the second that is
waited in wait().

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 27, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3859



--- Comment #1 from bremby@seznam.cz 2010-02-27 09:50:03 PST ---
(In reply to comment #0)
> When I create a thread in a while loop, the first time it is created it works, the second time dual-core CPU gets up to 100% load and stucks in there. Tested with DMD 1.053. When compiled with latest GDC, only one core gets to 100%, the other one is fine.
> 

Sorry, guys, I am an idiot - of course the CPU gets up to 100%, the class doNothing is written so. Anyway, the bug report is still valid: it never finishes a 2nd loop.

> Code:
> 
> class doNothing : Thread;
> 
> while(condition){
>    Thread test = new doNothing();
>    test.start;
>    test.wait(1000);

++    writefln("1000 msec elapsed");

> }
> 
> Reproducible: Always.
> 
> System: Ubuntu 9.10, x86, Core 2 Duo
> 
> The doNothing thread just wastes CPU cycles, I wrote it as a test for the
> wait() method. The test instance gets terminated after the second that is
> waited in wait().

The code prints out the text only once. It correctly waits 1000ms, prints out and then nothing happens ever again. Sorry for the messup.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 01, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=3859


Martin Krejcirik <mk@krej.cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |mk@krej.cz
         Resolution|                            |INVALID


--- Comment #2 from Martin Krejcirik <mk@krej.cz> 2013-04-01 19:09:58 CEST ---
Cannot reproduce on both linux and windows DMD 1.076 32bit

Marking as INVALID.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------