Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

100% CPU usage in Windows

PP2005PP2005 Posts: 111Member
When running my Borland Pascal programs in Windows XP, I notice that the CPU is almost always running at 100%. I suppose this isn't really healthy for my computer. Is there any way to counter this problem or is it just a consequence of running a Pascal DOS program in a Windows environment?

Comments

  • zibadianzibadian Posts: 6,349Member
    : When running my Borland Pascal programs in Windows XP, I notice that
    : the CPU is almost always running at 100%. I suppose this isn't
    : really healthy for my computer. Is there any way to counter this
    : problem or is it just a consequence of running a Pascal DOS program
    : in a Windows environment?

    That's a partly a consequence of running a DOS program, and partly a consequence of the way the compiler creates the programs. The only way to truly solve it is to switch to a windows-based Pascal compiler (Delphi, FreePascal).
  • Phat NatPhat Nat Posts: 757Member
    : When running my Borland Pascal programs in Windows XP, I notice that
    : the CPU is almost always running at 100%. I suppose this isn't
    : really healthy for my computer. Is there any way to counter this
    : problem or is it just a consequence of running a Pascal DOS program
    : in a Windows environment?

    Hmm... Funny. I've never noticed that before. I was going to ask how fast your processor is, but then I looked and confirmed mine is the same. Who needs video games to stress your system... just run the Pascal IDE. lol
  • PP2005PP2005 Posts: 111Member
    : : When running my Borland Pascal programs in Windows XP, I notice that
    : : the CPU is almost always running at 100%. I suppose this isn't
    : : really healthy for my computer. Is there any way to counter this
    : : problem or is it just a consequence of running a Pascal DOS program
    : : in a Windows environment?
    :
    : That's a partly a consequence of running a DOS program, and partly a
    : consequence of the way the compiler creates the programs. The only
    : way to truly solve it is to switch to a windows-based Pascal
    : compiler (Delphi, FreePascal).

    I guess I'll have a closer look at FreePascal, since it would also be pretty neat to be able to compile my code for Linux.
  • zibadianzibadian Posts: 6,349Member
    : : When running my Borland Pascal programs in Windows XP, I notice that
    : : the CPU is almost always running at 100%. I suppose this isn't
    : : really healthy for my computer. Is there any way to counter this
    : : problem or is it just a consequence of running a Pascal DOS program
    : : in a Windows environment?
    :
    : Hmm... Funny. I've never noticed that before. I was going to ask how
    : fast your processor is, but then I looked and confirmed mine is the
    : same. Who needs video games to stress your system... just run the
    : Pascal IDE. lol
    :
    Borland's text-based GUI is build around a busy-wait messaging system. This causes the CPU to run at 100%.
  • ActorActor Posts: 438Member
    : When running my Borland Pascal programs in Windows XP, I notice that
    : the CPU is almost always running at 100%. I suppose this isn't
    : really healthy for my computer. Is there any way to counter this
    : problem or is it just a consequence of running a Pascal DOS program
    : in a Windows environment?

    How do you know that the CPU is running at 100%? I'm unaware of any signal that tells you how much the CPU is running. And if the CPU is running at 100% how would it be able to tell you? I guess I'm assuming that 100% means that the CPU is only running your DOS program. Does it mean something else? And if it is running at 100%, so what?

    Actor



  • zibadianzibadian Posts: 6,349Member
    : : When running my Borland Pascal programs in Windows XP, I notice that
    : : the CPU is almost always running at 100%. I suppose this isn't
    : : really healthy for my computer. Is there any way to counter this
    : : problem or is it just a consequence of running a Pascal DOS program
    : : in a Windows environment?
    :
    : How do you know that the CPU is running at 100%? I'm unaware of any
    : signal that tells you how much the CPU is running. And if the CPU
    : is running at 100% how would it be able to tell you? I guess I'm
    : assuming that 100% means that the CPU is only running your DOS
    : program. Does it mean something else? And if it is running at
    : 100%, so what?
    :
    : Actor
    :
    You can see from the Task-Manager (CTRL+SHIFT+ESC) how much memory, CPU time etc. is used. A program running at close to 100% can make your windows appear sluggish, because the CPU must perform a lot more thread-switching. Also CPUs have a greater chance of overheating when continuously running on 100%, with all the consequences it entails.
  • ActorActor Posts: 438Member
    : You can see from the Task-Manager (CTRL+SHIFT+ESC) how much memory,
    : CPU time etc. is used. A program running at close to 100% can make
    : your windows appear sluggish, because the CPU must perform a lot
    : more thread-switching.

    Hmmm. The Task-Manager on this machine says that this forum is taking up 100% of CPU.

    : Also CPUs have a greater chance of
    : overheating when continuously running on 100%, with all the
    : consequences it entails.

    Interesting statement! Googling "CPU" produces a multitude of sites that define it as synonymous with the microprocessor. Doesn't that run 100% of the time anyway, albeit switching between several tasks most of the time? Whether doing one task or several the microprocessor is always in a cycle of
    [code]
    get an instruction
    carry it out
    advance the program counter
    repeat
    [/code]
    and it spends 100% if its time doing this, even it the instruction is the null instruction (do nothing). It never takes a break.

    I would say that a statement like "program x is taking p% of CPU" would simply mean that over some period of time (say 10 seconds) p% of that time was spent executing program x. And of course the Task-Manager itself takes up some of that time, which would alter the calculation (Hiezenburg's Principle). That would mean only the Task-Manager could take up 100% of CPU, unless you don't run Task-Manager. So if Task-Manager reports that any program other than itself is using 100% of CPU, it's lying.


  • Phat NatPhat Nat Posts: 757Member
    : Hmmm. The Task-Manager on this machine says that this forum is
    : taking up 100% of CPU.

    That's the thread title (or you have a very old processor ;)
    Check the processes tab. Most programs use relatively nothing (other than games, video editing, etc) and the rest is listed as System Idle Process (pretty much NOP operations). When TP is run, TURBO.EXE (or NTVDM, Dos emulation under XP) runs at 99% and the performance tab shows the CPU at 100% usage.

    If you let it sit without moving the mouse or typing it will decrease, but as soon as you start programming again, it returns to full usage. I believe that it is because it is a 16-bit process and there fore Windows must give it complete control for compatibility reasons.
  • PP2005PP2005 Posts: 111Member
    Just for fun I tried running a FreePascal program I made some time ago and that was complied for Win32. This also uses 100% CPU! I thought that if the program was compiled in FreePascal for Win32, it would run "normally" under Windows (i.e. not use 100% CPU). Is this because it's still using the Delay() function? If switching to FreePascal and compiling for Win32 doesn't solve the 100% CPU problem, then what will?
  • PP2005PP2005 Posts: 111Member
    : Just for fun I tried running a FreePascal program I made some time
    : ago and that was complied for Win32. This also uses 100% CPU! I
    : thought that if the program was compiled in FreePascal for Win32, it
    : would run "normally" under Windows (i.e. not use 100% CPU). Is this
    : because it's still using the Delay() function? If switching to
    : FreePascal and compiling for Win32 doesn't solve the 100% CPU
    : problem, then what will?

    Disregard this. I just checked the code for that program. In the main menu of that program, there actually isn't any Delay(), so it's just a loop running all the time - that's why it's using 100% CPU. That's some pretty bad programming I did there! When I checked another part of the program that used a Delay() in the loop, the usage was only 2%. :)
Sign In or Register to comment.