qbasic taking up 100% of cpu!

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
cdcuase
Newbie
Posts: 2
Joined: Tue Apr 05, 2005 12:31 am

qbasic taking up 100% of cpu!

Post by cdcuase »

Hey folks! Hope you can help me with a minor, but irritating problem I'm having with quickbasic 4.5 running in Windows XP (sp2)

As soon as qbasic is running in its dos window I notice it's taking up 100% of the cpu resources. Looking in Windows Task Manager I see that it is the process ntvdm.exe that's hogging up all the %. If I close qbasic, cpu usage goes back to normal (0%)

Anyone know how I can solve this? From the looks of things around this board, there are quite a number of you out there using qbasic under Winxp with no problems at all, and frankly I'm envious!

:)
MystikShadows
Veteran
Posts: 703
Joined: Sun Nov 14, 2004 7:36 am
Contact:

Post by MystikShadows »

I would say the first question I need to ask you is.

1. Do you have all service packs?
2. What does your system have (CPU Speed, RAM, HD capacity, Video Card etc etc...)

I got XP and running QB fine....I never checked if it took all the CPU though lol. but I don't think so because I usually have it opened with an average of 7 other applications lol....so let's start with your system configuration and take it from there.
When God created light, so too was born, the first Shadow!

MystikShadows

Need hosting? http://www.jc-hosting.net

Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
User avatar
ShadowWolf
Veteran
Posts: 56
Joined: Thu Mar 04, 2004 1:32 pm
Contact:

Post by ShadowWolf »

cdcuase is right any dos app will kill the cpu resource's most likely since dos is running though a piss poor VM. you could always try a another Dos emulator.

or simple give up QB and start using FB (www.freebasic.net)
User avatar
Pete
Site Admin
Posts: 887
Joined: Sun Dec 07, 2003 9:10 pm
Location: Candor, NY
Contact:

Post by Pete »

That's exactly it. WinXP doesn't natively support DOS, so when you run DOS apps through the "Command Prompt," you're actually emulating the DOS environment. Emulation is processor intensive, plus the XP DOS VM is absolute garbage.

I have noticed that a lot of Freebasic apps take up 100% of the CPU too, though...
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

Pete, yah

Poorly coded FB crap takes 100%


Namely, ones that rely on SLEEP for delay... or ones that use SDL and SDL_Flip inproperly.

Both sleep and sdl_flip have a bug that makes them suck up 100% CPU if called too often..


though, only on low end computers, so the people with 3ghz computers wont notice.


C Bug:
"It works for me, stfu!"
"It runs smoothly on my 15GHz computer with 128gb ram, n00b!"
I have left this dump.
cdcuase
Newbie
Posts: 2
Joined: Tue Apr 05, 2005 12:31 am

Post by cdcuase »

That is exactly right.. I did a bit more searching (ala google) and discovered that my Dos/XP problem was shared by a lot more people. Has something to do with the way Dos was designed a hundred years ago...

Found a site that helped fix the 100% cpu usage. Tamedos.com offeres a neat little program that basically "tames" dos. I installed it and now my cpu gets a much needed break whenever a dos app is loaded up. The program is shareware, however, so in 30 days I may have to look for another means of solving this little prob.
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

Just change the priority of the XP DOS VM.

Lower priority = higher usage (as it comes to the VM, dont ask me, ask MS)
I have left this dump.
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

How do you do that Z!re?
"But...It was so beutifully done"
User avatar
Halifax
Coder
Posts: 21
Joined: Thu Apr 07, 2005 4:20 pm
Location: utah

Post by Halifax »

i also have a problem with this. i like to program with music going on in the background, but media player is always so slow and it sometimes skips. it also screws with qbasic. and dont even mention the internet...
And you will come to find that we are all one mind, capable of all that's imagined and all conceivable - Maynard
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

Halifax, slow computer?
In any case, try changing to Winamp, you can set the priority of winamp so it wont hog the system, like WMP does. WMP is the biggest resource hog ever.


Mitth, not sure, I don't use WinXP. Probably as easy as righclicking on the exe or something (the DOS VM exe that is)
I have left this dump.
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Well, I have no clue. :cry:

Halifax:
QB4.5 is using 100% reasources on my XP 3.0GHz. But for some reason I can still use WMP. It works fine....don't know how that's possible with 100% reasources.
"But...It was so beutifully done"
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

It's a bug in the DOS VM, it doesent actually use 100%

It works like this, the sleep funtion it uses to emulate DOS (not qb sleep mind you) works by taking all free CPU and using it to loop, checking for when not to loop anymore.

It sucks, and is crappy coding.
I have left this dump.
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

:?: Why is FB's SLEEP like that? You know, the bug and all, makes little since......

Heh, I do know with QB1.1 or something that music wont play while running it.. but 4.5 and 7.1 seem to do it fine, course I was on my spare comp with a diff sound using those 2... I tried QB1.1 along time b4 I fried my audio on this one.

Wheter diff sound systems made a diff, dunno... can't check, that cpu is unusable since I had to swap monitors from it... :(
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Halifax
Coder
Posts: 21
Joined: Thu Apr 07, 2005 4:20 pm
Location: utah

Post by Halifax »

well i have a 900mhz computer with like 712 ram. i also have qb4.5. so im gonna download winamp (free?) and see how its different. thanks for the advice. too bad i cant run kazaa or whatever in the background.
And you will come to find that we are all one mind, capable of all that's imagined and all conceivable - Maynard
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

I dont know exactly how FB's sleep is coded.
It has the same kind of bug as SDL_Flip
SDL_Flip's bug comes from the flip not happening on extremely high end machines, running at high herz rates for the monitor/gfx card. So they "improved" the formula, so it wouldnt skip frames (single herzes, sort of) making it a bit faster on those high end 100hz+ machines, but slow as hell on normal machines with 60hz.

It's a documented "bug" and it seems the SDL teams arent going to improve it, not too big of a problem though, easy to code around.

FB's sleep could do something simmillar, use a CPU intensive loop to check for the sleep-end value, but i dont know.

Best advice, DONT ever use SLEEP for delays, bad:

Code: Select all

do
sleep 5
loop
Instead use timer, or simillar.

Ofcourse, using a single sleep to wait for a keypress is ok.


Yes, winamp is free.
I have left this dump.
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Do you mean processor speed?
Cause a 60Mhz processor is not 'normal' anymore.

Is a Radeon X300 a good gfx card? lol :lol:
"But...It was so beutifully done"
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

It even says Hz, not MHz,

And I was refering to screen Herz rates.
I have left this dump.
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

:( What a delay if it want work?

You mean a timer delay, like this?:

Code: Select all

T! = TIMER: DO: LOOP UNTIL (TIMER - T!) = 0.1
:?: :roll: Oh well,....
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Z!re: sorry I missed that.

Rattra:
Its a good ideas to put a >= instead of a = just incase if FB skips .1 randomly for some odd reason.

What about this?
Do :loop while inkey$ = ""
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

:lol: forgot the ">=",.. and yeah, FB skip it to.. I think,.. I'll go test it ^_^ FB is easier to crash, the IDE stays up... :wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
Post Reply