windows_ionice 0.0.0 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/bin/windows_ionice +11 -5
  3. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.1.0
data/bin/windows_ionice CHANGED
@@ -1,10 +1,12 @@
1
- require 'rubygems' if $0 == __FILE__ && RUBY_VERSION < '1.9'
1
+ if RUBY_VERSION >= '1.9'
2
+ raise '1.9 not yet supported'
3
+ end
4
+
5
+ require 'frubygems' if $0 == __FILE__ && RUBY_VERSION < '1.9'
2
6
  require 'sane'
3
7
  require 'ruby-wmi'
4
8
  require 'benchmark'
5
9
 
6
- puts 'starting watcher...'
7
-
8
10
  # take a snapshot of the processes' status
9
11
  # could be more efficient by selecting just what we wanted, I suppose
10
12
  def fill into_this
@@ -38,6 +40,9 @@ def diff_values first, second, time_diff, what_to_calculate
38
40
  answer
39
41
  end
40
42
 
43
+ NORMAL_PRIO=32
44
+ IDLE_PRIO=64
45
+
41
46
  loop {
42
47
  print '.' if $VERBOSE
43
48
  STDOUT.flush
@@ -65,8 +70,9 @@ loop {
65
70
  violated << pid
66
71
  proc = WMI::Win32_Process.find(:first, :conditions => {:ProcessId => pid.to_i})
67
72
  if proc.Priority > 4 # appears that 7 or 8 here mean normal prio...
68
- proc.SetPriority 64 # set it to low priority
69
- sputs "pid violated!", pid, value, reading, "was greater than", max, "punishing it"
73
+ proc.SetPriority IDLE_PRIO # set it to low priority
74
+ puts "violated!", pid, value, reading, "was greater than", max
75
+ Thread.new { sleep 5; proc.setPriority NORMAL_PRIO; puts "set it back to normal", pid }
70
76
  end
71
77
  end
72
78
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: windows_ionice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roger Pack
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-05 00:00:00 -07:00
12
+ date: 2010-01-25 00:00:00 -07:00
13
13
  default_executable: windows_ionice
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency