Software :: Limiting CPU Usage Of A Multithreaded Process?
Oct 12, 2010
I have a multi-threaded process running and I have to limit the cpu time used by each of the threads. If 1 of the threads uses the whole of configured CPU time, the other thread should sleep and not consume CPU time in that cycle. 1 thread has higher preference over the other. How can i implement it my CPP code?
We run Jboss app server that of course is all multithreaded under one JVM. I have couple of question regarding monitoring on per thread basis:
1. Is there a way to see which thread is bound to which CPU core? 2. Is there a way to see the CPU, Memory usage per thread? Something like prstat on Sun box which is real time and gives detailed information about threads per CPU
How can i limit disk space usage for one user? Like.. User john123, you can only use 100mb of my harddisk. User jake155, you can only use 250mb of my harddisk.
Is there any way to monitor one process' CPU usage and RAM usage over time on Linux? I am trying to change to a cheaper VPS and need to work out what level of CPU and RAM I need!
I am currently writing a JAVA script to monitor certain unix processes through JConsole. Upon having lots of trouble with runtime.exec, i decided to bypass the top/ps command call and just get the information straight from /proc/*pid*/whatever.Now i can pull back any information from any of the files I want, and the current way i determine the CPU usage of a process is as follows:Add the UTime and STime of that process from /proc/pid/stat then divide my pidCpu by UTime + STime + NTime from /proc/stat, then multiply that by 100, should give me the % cpu usage a process is using, right?Theory being if I get the jiffies assigned to my process, I can divide that by the total jiffies the cpu assigns.
However, my results seem to vary from the ones gathered from top and ps. What am I doing wrong?
I'm writing a shell script which aims to create a safe gtared (xxx.sql.gz) copy of MySQL databases.This script is planned to be Cron-Jobed.
Well, what I need to add to this shell, is something that limit CPU usage for the whole process (just in case if the database being generating is a huge one.)So, after few time of googling I found couple of solutions:
- Using cpulimit. I tried to place the code in Position(1) and Position(2) but it didn't seem to be working fine.. Any idea about the right use?
And the other Solution is:- Using nice.
Well, assuming I named my shell script (sqlbacker)..
Finally, this is my first time I ever write a shell, so correct me if somewhere I made a mistake :-) (The script itself works perfectly)
I am currently writing a JAVA script to monitor certain unix processes through JConsole. Upon having lots of trouble with runtime.exec, i decided to bypass the top/ps command call and just get the information straight from /proc/*pid*/whatever.Now i can pull back any information from any of the files I want, and the current way i determine the CPU usage of a process is as follows:
Add the UTime and STime of that process from /proc/pid/stat then divide my pidCpu by UTime + STime + NTime from /proc/stat, then multiply that by 100, should give me the % cpu usage a process is using, right?Theory being if I get the jiffies assigned to my process, I can divide that by the total jiffies the cpu assigns. However, my results seem to vary from the ones gathered from top and ps. What am I doing wrong?
There's a disfunctional process eating copious cpu time.Is there a way to effectively assign it a high nice value? I need to do this whenever it runs, for whatever reason, and I can't be bothered to track down all the scripts and scenarios that cause it to run and change the script to use nice. And I can't be bothered to manually run renice whenever I notice that it's running.
I want the OS to automatically assign a high nice value to this process, perhaps based on the processes name. Is this possible?Presumably, a cron job could run every 5 minutes and run "renice" on every process matching a given name, but I'm hoping for a solution with more finess.
In linux, how can I display memory usage of each process if i do a 'ps -ef'?I would like to the 'virtual memory', 'res memory', 'shared memory' of each progress. I can get that via 'top', but I want the same info in 'ps -ef ' so that I can pipe the output to 'grep {my process name}'.
I have been running to a strange problem. For a few days, a few times a day something seems to take over my machine. Suddenly I can't type, or the key shows up about 5 seconds are being pressed, music players halt, etc. In anticipation, I had top and htop running. Sure enough, when this business begins htop reports all 8 cores firing at near 100% for a few minutes. However, top is telling me nothing about who is too blame. The cup%sy on top shows heavy usage, but the top processes are nothing remarkable, mostly just top and htop and conky, all running at around 1 or 2% on average. I am a bit puzzled as to why I can't see the cpu hog so that I figure out what is going on. My question then: Are there some processes (in kernel space?) that don't show up in top, yet which could be hogging the cpu?
I have to monitor the %MEM that processes are using, so I use the ps and sort command like this ....
ps -aux | sort -nk4
So this will sort by column 4 so I can see the all the processes that are using the highest %MEM. What I really want is to be able to just display the process name and the %MEM next to it. how to do this?
What originally seemed like an easy thing to calculate has given me a big headache. Perhaps someone can help me with my issue. I am trying to find, in particular, how much memory certain application processes are taking. The process always is the same name, main_server, but with an argument to tell it what to do when running as a daemon.
When running the following command against all "main_server" processes, it produces a result in megabytes based on the output of the rss field in 'ps'.
Code: CALC=0 for ea in `ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS | grep main_server | grep -v "grep main_server" |
[Code]...
Currently I am left scratching my head. For capacity planning purposes, it would be nice to know how many more 'main_server' processes could run on the system without causing it to swap. Knowing the buffer and cache usage will go down as running processes demand more memory, I prefer to look at the free memory excluding cache and buffers. However, since 'ps' is reporting the processes are using more memory than free reports is in use without those things, I have no way to know how many more processes the system can support. I played around with different fields in 'ps', such as vsize, size, etc, but with no luck in matching up any numbers.
Are there a way to set fixed maximum processing power to a process.For example a program called 'X' uses cpu in high speed. I need to set this 'X' process to to run with maximum 20% of cpu usage at any time.
how to check which process consuming a lot of HDD I/O ? Do You know any good command which can show me which process saving something big on the storage system ? "iostat" or maybe "ps" ? Would be great if somebody could past me here nice command.
We have an internal application which takes below 10% cpu usage normally. However sometimes it hit above 85% or more (and stays there) causing the server to become very slow. Currently we have to monitor this manually, kill the process and manually start it.
command / script that will kill the process (using pid will be the best option as i think) when it reaches 85% or higher
(I saw another question that suggested to use monit but I have to get this done using the standard commands available in the current installation - RHEL5)
I use linux and Unix and I want to monitor the memory usage for process. To prevent memory leakage and out of memory of the system. Any command or sytnax , have more better and presentable data than below command about memory usage of one process ?
I am using qmail in my office. I am noticing this for more than a month. It is my daily routine to check the cpu utilization using top command and by using top different processes can be viewed. the apache process after 1 or 2 days shows cpu utilization of 100%. There is no affect on the server whatsoever of 100% because mail server has 2 processors of 4 core, i think so that may be the reason. Can any one explain why is this happening. What i do after that is i restart the httpd process and cpu utilization comes to normal. What are the reasons behind this and how to solve this permanently.
How can I periodically monitor memory usage of a process in linux.Can it be dumped in some file.So that later I can see what was the process behaviour in taking memory.
I've written a program for a class that my professor will be testing in various low memory environments to see how it behaves when the program runs out of memory. Is there a way I can simulate the execution in a low memory environment without creating a virtual machine?
Is there any program to terminate process automatically if using more than 90% or 100% CPU time for more than 5 seconds? I have a program that opens a web browser, do some stuff on it and close it. But problem is that sometimes that browser starts using 100% CPU
I have looked for and found several tools to show a system's total network usage. I have not, however, been able to find any that show this information in the context of individual processes. Do any such tools for linux exist?
I woukld like to know the kernel command or linux kernel file name where i can get the process actual physical RAM usage in linux version 2.6.21 or hiher version.
I have a java process running in background. I have no java dependent program opened and even if I had, this program should be killed if I kill the Java process. top shows that Java causes almost 90% cpu usage.
[Code]...
The only way I can imagine is to restart, but this might happen again.
I am running a HP dc5750 dual core computer with a 512MB Nvidia 7200/7300 graphics card my operating system is Ubuntu 10.10. Both my processors are operating at 98-104% cpu usage, it appears that gnome-appearance-properties is the culprit and the only way to return to normal is to end these processes. I have been setting up the desktop cube to my liking and the processor appears to rise up to 100% again. Would getting a 1GB graphics card correct this or is this a bug in maverick meerkat. Any advice would be appreciated. Please keep it simply as I am a Newbie to Linux and find things over-whelming at times. Also would running at 100% on both processors at indefinite periods of time harm my computer.