In a Std C Console app, gets() grabs vast processor time. How to fix?

In a Std C Console app, gets() grabs vast processor time. How to fix?

Post by Ken » Thu, 12 Feb 2004 11:01:48


Hi...

I'm writing a little mini-app in straight C with CW8 in OSX...with just
a command line type of interface (a Std C Console app.) I display a few
lines, and then wait for input with a "gets()". I note when I use OSX's
Activity Monitor, my little "do mostly nothing but wait for input
mini-app" is grabbing huge chunks of processor time.

Anyone know how I can make this Std C Console mini-app behave a little
better?

Thanks!

Ken
 
 
 

In a Std C Console app, gets() grabs vast processor time. How to fix?

Post by MW Ro » Fri, 13 Feb 2004 00:31:33

In article <100220042101486670% XXXX@XXXXX.COM >,



are you running this in terminal or is it a Carbon SIOUX application.

When you are running it is that from the IDE if so is it in debug mode
etc.

Ron

--

Metrowerks, maker of CodeWarrior - "Software Starts Here"
Ron Liechty - XXXX@XXXXX.COM - < http://www.yqcomputer.com/ >

 
 
 

In a Std C Console app, gets() grabs vast processor time. How to fix?

Post by Ken » Fri, 13 Feb 2004 05:31:01


Hi Ron...

Thanks for your thoughts.

My Std C Console app (which is a processor hog...that's the problem) is
a FINAL, not a DEBUG, application. It is Carbon-based. It is run in OSX
as a standalone application, nothing to do with Terminal.

It's a simple little C-program, that uses "gets()" to wait for input
then process the input then wait for next input, etc. Activity Monitor
says it consumes 70 or 80% of the processor time while doing nothing.

Again, thanks...

Ken




In article < XXXX@XXXXX.COM >, MW Ron
 
 
 

In a Std C Console app, gets() grabs vast processor time. How to fix?

Post by MW Ro » Fri, 13 Feb 2004 11:56:21

In article <110220041531010130% XXXX@XXXXX.COM >,



Yeah that rings a bell, I think someone else reported that PEF/CFM
SIOUX used a lot of processor time.

Write this up in a letter and send it to me. I'll make a Mach-O SIOUX a
PEF SIOUX and a terminal program and see how they each use up processor
time. I'll also pass it on to some of our engineers which is why I
want the e-mail with details.

Thanks for any cooperation,

Ron




--

Metrowerks, maker of CodeWarrior - "Software Starts Here"
Ron Liechty - XXXX@XXXXX.COM - < http://www.yqcomputer.com/ >
 
 
 

In a Std C Console app, gets() grabs vast processor time. How to fix?

Post by Ken » Sat, 14 Feb 2004 05:48:43


Well, if this helps, succinctly put...the problem is merely that when I
create a Std C Console Carbon app (Final, not Debug) in CW8 on OSX and
use "gets()", the program (when run in OSX and monitored with Activity
Monitor) seems to completely hog the processor even while the program
in question is doing nothing but waiting for input. That's all.

You can pass this on as you see fit.

(My personal bet is that if you look up the source for your Std C
Console stuff, you'll find someone did a WaitNextEvent with a parameter
indicating do NOT be a good citizen and do NOT give away any processor
time to other apps. But, just a guess.)

Anyway, good luck.


In article < XXXX@XXXXX.COM >, MW Ron