The Linux Administration group is for the discussion of technical issues technical issues that arise during the administration of Linux systems, including maintaining the operating system and supporting end-user applications.

Is it possible to make a process run in a slow motion without increasing the CPU usage ?

Is is possible to make a process run in a "slow motion" without increasing/affecting the CPU usage , to just understand how the process works or how the code flow happens particularly in a multithreaded process. basicallly is there a way we can listen for some interuppts and then make it sleep for system call or something, just throwing out ideas , if so .. let me know.

Hi,
the command "cpulimit" may be/(may be not) helpful
cpulimit is a simple program that attempts to limit the cpu usage of a
process (expressed in percentage, not in cpu time). This is useful to
control batch jobs, when you don't want they eat too much cpu.
cpulimit project does not act on the nice value or other scheduling priority
stuff, but on the real cpu usage. Also, it is able to adapt itself to the
overall system load, dynamically and quickly.
download from:
http://heanet.dl.sourceforge.net/sourceforge/cpuli mit/cpulimit-1.1.tar.gz

onewebclick -
This will be a twist on your question, but may work for you.
try running your process using strace.
Make sure you specify the -o option with a log file.
Something like : strace myprogram -o output.log
strace will output a lot of information - file opens, closes, buffers
check out http://www.debian-administration.org/articles/352 for a more
indepth article on using strace
If you are trying to debug a web app, you can also use strace with an
already running process (ie - Apache/Tomcat, etc...)
You should be able to grab the PID of your server using ps or lsof :
ps -elf |grep httpd
nobody 1641 10607 0 14:51 ? 00:00:00 /usr/local/apache/bin/httpd
root 6888 10607 0 Jul25 ? 00:00:00 /usr/local/apache/bin/httpd
root 10607 1 0 Jul16 ? 00:00:04 /usr/local/apache/bin/httpd
nobody 31567 10607 0 14:20 ? 00:00:00 /usr/local/apache/bin/httpd
The parent process here is 10607, so you can do : strace -p 10607 -o
logfile.log

Thanks for you all trying to help me,
i checked nice .. it seems like it might useful if there are several
programs running and trying to grap the cpu time but it doesn't help to slow
down a process if it's the only process.
does cpulimit helps me specify in terms on like 0.005% , i really wanted the
process to run 100x slower.
strace will not help me slow down the process ,
basically what i am trying to achive is that i wanted to slow down a java
process so that i can take java thread dumps using kill -3 at frequent
intervals to get the thread stack and understand the code path. right now
the threads are executed real fast i really can't find the code path to
figure out what is going on between a request that is working and
non-working .. .so i basically need a process to go really slow to achieve
the same. any thoughts , comments , etc ?

This change the question generally, but I have few ideas: set Xms to very low value to get very fragmented memory and win some slowdown from defragmentation (after garbage collector). Set garbage collector(s) (new and old) do not use threads (UseParallelGC, UseParallelOldGC), do not use Concurrent Collector. Set MaxNewSize to very little value to make again memory fragmentation
And BTW start some very heavy process on the machine and with nice set little priority to your program

Yes - I just tested it in bash - works fine.
Obviously you'd do it from c better than shell - getting a more
efficient and finer-grained STOP - CONT cycle.
I was wondering if you could change the configuration of the scheduler
but that looks like a nice exercise for a Sunday afternoon as if there
was nothing else to do it would run anyway...

Copyright 1998-2015 Ziff Davis, LLC (Toolbox.com). All rights reserved. All product names are trademarks of their respective companies. Toolbox.com is not
affiliated with or endorsed by any company listed at this site.