Hack CPU Utilization


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Hack CPU Utilization
# 1  
Old 11-16-2009
Data Hack CPU Utilization

Hi friends,
I am currently working on an issue where i should write a program which utilizes Cpu as specified by the user. The function should be provided with an argument ( how much percentage of CPU has to be utilized by the process ) for example CPU(75) should utilize 75% of CPU. The function should be terminated by a signal. Is this feasible ???? guys please help me out. Thanks in advance. is there any linux commands ? all NETBSD functions can be used.

Thanks,
Chandra Mohan .S
# 2  
Old 11-16-2009
Quote:
The function should be terminated by a signal. Is this feasible
Executing function is not visible to the kernel but the process in which its wrapped is available to the external world for communication. I guess this is what you meant right?

Keeping pinging for the load average often if it exceeds or equals commit suicide or restart

Code:
sub get_system_load {
    open(L, '<', '/proc/loadavg') or die "Unable to open /proc/loadavg file <$!>\n";
    my $data = <L>;
    close(L);

    return (split(' ', $data))[0];
}

# 3  
Old 11-16-2009
Look up processor affinity - settask() - will allow you to specify which cpu a process runs on.
# 4  
Old 11-16-2009
A percentage of one single CPU or of all CPUs/Cores/Threads available to it ?
With what sampling rate ? Load is meaningful only as an average value. Instantaneously, a process is either running 100% or 0% of each CPU.
# 5  
Old 11-16-2009
I think am wrong here, what I gave is only a generic load average fetch and controlling based on that. It will really not fetch the utilization of a process bound to a processor.
# 6  
Old 11-16-2009
Load average and CPU load are indeed different metrics.
# 7  
Old 11-16-2009
Oh - ignore the affinity comment. I thought you wanted to designate a cpu for a given process.

Monitoring of cpu usage as a percent by a process on itself is just adding pointless overhead. If you do not want to degrade system performance, then nice the process.

That is why nice exists.

If the process gets 100% cpu, when in a lower priority, it then means nothing else needs it. So it does not degrade overall performance. Plus, 100% cpu utilization in and by itself does not mean the system is overloaded - it could be a background process running at low priority. Things like cpu wait queue length or i/o queue request length are far more important.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

CPU Utilization and Memory Utilization of Services and Applications

Hi, i am new to linux/RHEL 6.0 and i have two questions. 1) How to get the CPU utilization and Memory Utilization of all Services running currently? 2) How to get the CPU utilization and Memory Utilization of all Applications running currently? Please help me to find the script. ... (2 Replies)
Discussion started by: nossam
2 Replies

2. UNIX for Advanced & Expert Users

CPU utilization

Hi, any commande on AIX 6.1 that shows me total CPU utilization ? I saw curt in documentation but there should be a trace file before. Thank you. (1 Reply)
Discussion started by: big123456
1 Replies

3. Shell Programming and Scripting

CPU Utilization

I know how to check the CPU utilization and memory space like: vmstat top free What i want ot check on my linux system is... how much CPU are available on my system and do i need to put extra CPU. Also need to check the hardware configuration and the space related to the same ... (3 Replies)
Discussion started by: j_panky
3 Replies

4. AIX

CPU Utilization

Hi All, Can some one help me in finding % CPU Utilization ? From VMSTAT command, How we can find % utilization ? Thanks (3 Replies)
Discussion started by: VBudatha
3 Replies

5. UNIX for Dummies Questions & Answers

how to get persistant cpu utilization values per process per cpu in linux (! top,ps)

hi, i want to know cpu utilizatiion per process per cpu..for single processor also if multicore in linux ..to use these values in shell script to kill processes exceeding cpu utilization.ps (pcpu) command does not give exact values..top does not give persistant values..psstat,vmstat..does njot... (3 Replies)
Discussion started by: pankajd
3 Replies

6. Shell Programming and Scripting

CPU Utilization

Hi to All, Would you please help me. I would like to know, In Unix How to know CPU utilization for every process. Thanks in Advance. Thanks, Divyang (3 Replies)
Discussion started by: div_Neev
3 Replies

7. Shell Programming and Scripting

CPU Utilization

Dear friends, I am doing a report daily for all most 30 more serves... i need to check out CPU utlization bu (top command, 100 - (ideal value)) and Memory utilization too could some one help me how can i get it directly, if scripts also no problem.. i will very thankful if some one... (3 Replies)
Discussion started by: bullz26
3 Replies

8. UNIX for Dummies Questions & Answers

% CPU utilization

Hi, iam new to AIX and had a basic question. I was asked to give a chart of CPU utilization in percentage for every hour. where can i look for information and which column should i look at? I would be very thankful if somebody could respond. Thanks! karthik (1 Reply)
Discussion started by: karthikosu
1 Replies

9. UNIX for Advanced & Expert Users

CPU Utilization

On user complains about the performance of web application, as a part application support, we use following commands to see the CPU utilization in the UNIX using ‘sar' command. Some times it goes below 20 and even reaches 0. HLW$~> sar -u 10 60 SunOS HLW 5.8 Generic_117350-14 sun4u ... (2 Replies)
Discussion started by: thinakarmani
2 Replies

10. UNIX for Dummies Questions & Answers

CPU Utilization

What command do you use to verify if the CPU utilization. Example. If the CPU is at 98%? Thanks (4 Replies)
Discussion started by: kimosilk
4 Replies
Login or Register to Ask a Question