Sponsored Content
Full Discussion: Cpu usage
Top Forums Programming Cpu usage Post 302262539 by zing_foru on Friday 28th of November 2008 01:23:49 AM
Old 11-28-2008
Cpu usage

Hi all,


When I have a below while loop in my code (This observation is same for C and Perl)

i= 0;
while(1)
{
i++;
}

for above the CPU uses goes beyond 49% on hp-ux machine, why cpu usage increase at this level for just a simple while loop?

and if I have a single print statement (as shown below) under this while then cpu usage decrease and comes at normal level i.e. 0.9 or 1%

i= 0;
while(1)
{
i++;
printf("%d\n", i);

}
Also adding few mili seconds sleep inside the while loop results reducing the CPU usage

any idea why it happens and how we can avoid the CPU usage?

Thanks....
 

10 More Discussions You Might Find Interesting

1. Programming

Monitor CPU usage and Memory Usage

how can i monitor usages of CPU, Memory, Hard disk etc. under SUN Solaries through a c program or java program i want to store that data into database so i can show it graphically thanks in advance (2 Replies)
Discussion started by: Gajanad Bihani
2 Replies

2. Programming

CPU usage and memory usage

Please tell me solaris functions/api for getting following information 1- Function that tells how much memory used by current process 2- Function that tells how much memory used by all running processes 3- Function that tells how much CPU is used by current process 4- Function that tells how... (1 Reply)
Discussion started by: mansoorulhaq
1 Replies

3. UNIX for Advanced & Expert Users

Cpu Usage

System FreeBSD. Issue: I see that system idle = 0% in the same time top and other commands show that all process eat 0% of cpu. System calls 98% CPU states: 7.9% user, 0.0% nice, 91.8% system,<==!!! But top does not show any process which eats more than 0% Question: how can I see... (0 Replies)
Discussion started by: mirusnet
0 Replies

4. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

5. Solaris

current CPU usage, memory usage, disk I/O oid(snmp)

Hi, I want to monitor the current cpu usage, monitor usage , disk I/o and network utlization for solaris using SNMP. I want the oids for above tasks. can you please tell me that Thank you (2 Replies)
Discussion started by: S_venkatesh
2 Replies

6. Solaris

Multi CPU Solaris system shows 100% CPU usage.

Hello Friends, On one of my Solaris 10 box, CPU usage shows 100% using "sar", "vmstat". However, it has 4 CPUs and prstat and glance are not showing enough processes to justify high CPU utilization. ========================================================================= $ prstat -a ... (4 Replies)
Discussion started by: mahive
4 Replies

7. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

8. Programming

CPU usage

Hi all, I'm using python and psutil a library to get system informations like cpu usage (percent) for a given process. My question is if I have the value in % of the cpu usage how I could get the cpu usage in cycle number I mean not in percent? Thanks a lot D. (5 Replies)
Discussion started by: Dedalus
5 Replies

9. AIX

Overall CPU Usage

Hi Guys, I am a newbie on the forum. This is my first post, so first of all I would like to introduce myself. I am a SAS Analyst programmer working for an Health Insurance client. SAS is installed on a 16 CPU AIX Server with partitions running with shared processor. I have couple of... (2 Replies)
Discussion started by: saurabhiim2003
2 Replies

10. HP-UX

CPU Usage

Hi Experts, We encountered problem in one of the production system where some processes were taking higher CPU and after some time it came back to normal.. From system prespective, is there any way to check why processes took more cpu during that particular period. (16 Replies)
Discussion started by: sai_2507
16 Replies
BUS_BIND_INTR(9)					   BSD Kernel Developer's Manual					  BUS_BIND_INTR(9)

NAME
BUS_BIND_INTR, bus_bind_intr -- bind an interrupt resource to a specific CPU SYNOPSIS
#include <sys/param.h> #include <sys/bus.h> int BUS_BIND_INTR(device_t dev, device_t child, struct resource *irq, int cpu); int bus_bind_intr(device_t dev, struct resource *irq, int cpu); DESCRIPTION
The BUS_BIND_INTR() method allows an interrupt resource to be pinned to a specific CPU. The interrupt resource must have an interrupt han- dler attached via BUS_SETUP_INTR(9). The cpu parameter corresponds to the ID of a valid CPU in the system. Binding an interrupt restricts the cpuset(2) of any associated interrupt threads to only include the specified CPU. It may also direct the low-level interrupt handling of the interrupt to the specified CPU as well, but this behavior is platform-dependent. If the value NOCPU is used for cpu, then the interrupt will be ``unbound'' which restores any associated interrupt threads back to the default cpuset. Non-sleepable locks such as mutexes should not be held across calls to these functions. The bus_bind_intr() function is a simple wrapper around BUS_BIND_INTR(). Note that currently there is no attempt made to arbitrate between multiple bind requests for the same interrupt from either the same device or multiple devices. There is also no arbitration between interrupt binding requests submitted by userland via cpuset(2) and BUS_BIND_INTR(). The most recent binding request is the one that will be in effect. SEE ALSO
BUS_SETUP_INTR(9), cpuset(2), device(9) HISTORY
The BUS_BIND_INTR() method and bus_bind_intr() functions first appeared in FreeBSD 7.2. BSD
October 14, 2009 BSD
All times are GMT -4. The time now is 03:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy