Re: Thread program makes Windows XP run slow,



arun wrote:
Hi all,,

I am a newbie to this group. When i tried to write a simple program
using windows threads,
It is crashed. The program creates two threads of a function which
prints the string "hello" in an infinite while loop. The program caused
an "Access violation" in a routine called by printf.
But this problem happens only in Windows XP, it is running fine in
Windows 2000.
Also when i tried with a program that creates two thread of a
function which has an infinite while loop, the machine becomes really
slow, its almost hang. The cpu usage is shown as 95 by the windows task
manager.This problem also exists in Windows XP only.
I had tried both these using pthreads on my linux machine. Both are
running without any problem. Anyway now i am forced to use Windows as
my project requires it. It will be helpful if anyone can explain why
these problems occur,,

Thanking you all,,,
arun..


Make sure you have linked your program to the multithreaded version of the runtime library. In older versions of Visual C both a single threaded and multithread version of the library are available. Also use beginthreadex, not CreateThread, so your runtime lib will be properly initialized for each thread.

Writing an infinite while loop is SUPPOSED to consume 100% of CPU in Windows. What's the problem with that?

--
Scott McPhillips [VC++ MVP]

.



Relevant Pages

  • RE: Certification..
    ... > MCSA: Messaging on Windows 2000 ... > MCSE on Windows 2000 ... Will I get a new welcome kit for Exch Server 2003? ... >> Arun Aluvila ...
    (microsoft.public.cert.exam.mcse)
  • Re: Wireless Connection for Windows 2000 desktop
    ... Microsoft MVP [Windows] ... "Arun" wrote: ... | I have 2 other laptopsusing a D-link ... | wireless cardand working perfectly fine. ...
    (microsoft.public.win2000.general)
  • RE: Unable to copy more files in a folder
    ... Hey there Arun, ... There doesn't appear to be any indication of a "number of files" limitation ... in Windows XP. ...
    (microsoft.public.windowsxp.help_and_support)
  • Thread program makes Windows XP run slow,
    ... using windows threads, ... prints the string "hello" in an infinite while loop. ... I had tried both these using pthreads on my linux machine. ...
    (comp.programming.threads)
  • How to retrieve Registered users under windows.
    ... Hi Arun ... as to whether the password matches the ... account... ... >Passwd in windows. ...
    (microsoft.public.win2000.security)