Operating System - Tru64 Unix
1755781 Members
4597 Online
108838 Solutions
New Discussion юеВ

High CPU usage when using getch ()

 
R.Dakshinamurthi
Occasional Contributor

High CPU usage when using getch ()

Hi All,
Our application is developed in C/Sybase and running under Tru64 5.1a.

Our screens are developed using Unix Curses.

There is a call to getch () with in do ... while loop.
If there is no user input for approximately about 2hrs, the process started taking more than 90% of CPU.
What could be the corrective action?
Is it possible to set timeout? Please note that the mode set is cbreak.

The speedy response will be highly appreciated.

Thank you,
Dakshin
2 REPLIES 2
John Daley
Occasional Advisor

Re: High CPU usage when using getch ()

Dakshin,

You'd need more information.

I would grab dcpi from here:
http://h30097.www3.hp.com/dcpi/

...and use it to keep an eye on the application. There are docs on that site.

You could also try connecting to the process with ladebug's -pid option, doing ^C and t.

truss and trace also have the ability to attach to a running process.
Ralf Puchner
Honored Contributor

Re: High CPU usage when using getch ()

First doublecheck your program maybe the cbreak mode is not active consuming cpu usage.
Insert a sleep() in front of the getch() command.

Try kdbx -k /vmunix /dev/mem
(kdbx) set $PID=
(kdbx) tstack

so have a look onto the stack. may it gives you a clue what is going on.
Help() { FirstReadManual(urgently); Go_to_it;; }