HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- High CPU usage due to getch() curses fn.
Operating System - HP-UX
1830340
Members
2468
Online
110001
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2003 07:13 AM
04-21-2003 07:13 AM
High CPU usage due to getch() curses fn.
Hi All,
We have found that our application process in C/Sybase, at times takes very high CPU.
From detailed analyis it was observed that this is due to a curses function, getch(), used within a do.. while loop.
The getch() function waits for user input and if it is not given, approximately after 2hrs, it starts utilizing high cpu time.
However,this doesn't prevent other processes from getting CPU time, if they need .
Why getch() consumes 99% CPU time? How to get rid of this problem? Is there any way the process can come out after trying for some time?
Thanks
Ajay
We have found that our application process in C/Sybase, at times takes very high CPU.
From detailed analyis it was observed that this is due to a curses function, getch(), used within a do.. while loop.
The getch() function waits for user input and if it is not given, approximately after 2hrs, it starts utilizing high cpu time.
However,this doesn't prevent other processes from getting CPU time, if they need .
Why getch() consumes 99% CPU time? How to get rid of this problem? Is there any way the process can come out after trying for some time?
Thanks
Ajay
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2003 07:33 AM
04-21-2003 07:33 AM
Re: High CPU usage due to getch() curses fn.
The problem is getch is a blocking I/O call
That is it blocks till it gets a input.Instead use "getc" which is unbuffered.
that is write something like
int getch(void)
{
/*
* fetches the next char (if any) hit by the user
*/
return(getc(stdin));
}
in your program to unbuffer it.
Better still would be to use alternatives like
polling or signal driven input in your application.
Hope this helps
That is it blocks till it gets a input.Instead use "getc" which is unbuffered.
that is write something like
int getch(void)
{
/*
* fetches the next char (if any) hit by the user
*/
return(getc(stdin));
}
in your program to unbuffer it.
Better still would be to use alternatives like
polling or signal driven input in your application.
Hope this helps
The sufficiency of my merit is to know that my merit is NOT sufficient
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP