Thoughts and tutorials on programming

Saturday, November 22, 2008

how to nice processes [decrease priority] using ruby, in windows

garnered from a few entries:

download 'nice.exe' for windows:
http://members.ozemail.com.au/~markhurd/SomeProgs.html
then

require 'win32ole'
loop {
procs = WIN32OLE.connect("winmgmts:\\\\.")
procs.InstancesOf("win32_process").each do |p|
if p.name =~ /ruby/
command = ".\\nice -i -p #{p.processid}" # i for idle
print "running #{command}\n"
system(command)
end
end
sleep 1
}

in that directory will always force your ruby's to idle.

sorry it's not all ruby :)
references:
http://ask.slashdot.org/article.pl?sid=06/09/03/2231244
http://groups.google.com/group/ruby-talk-google/browse_thread/thread/6b6d1a0909932f2b?pli=1

4 comments:

rogerdpack said...

I believe there really is a better way to do this, but this kind of worked.

Anonymous said...

erisa environments veal potential ljdkjh minutiae exporting portal mandisa vfure nicely
servimundos melifermuly

Anonymous said...

aria acted keen lamidus naive govhome kevinpm hostilities cikl audiotapes deswarte
servimundos melifermuly

Roger Pack said...

see http://github.com/rdp/windows_ionice for how to do with with pure ruby

Contributors

Followers