ioprio_get(2) / ioprio_set(2) for mruby
C Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.gitignore
.travis.yml
.travis_build_config.rb
Dockerfile
LICENSE
README.md
Rakefile
mrbgem.rake
mruby-ionice.gem

README.md

mruby-ionice Build Status

This is a binding for Linux system calls ioprio_set(2) , ioprit_get(2) . And it is compatible with ionice(1) .

install by mrbgems

  • add conf.gem line to build_config.rb
MRuby::Build.new do |conf|

    # ... (snip) ...

    conf.gem :github => 'takumakume/mruby-ionice'
end

example

ioprio classes

from linux/ionice.h

IOnice::IOPRIO_CLASS_NONE  # => 0
IOnice::IOPRIO_CLASS_RT    # => 1
IOnice::IOPRIO_CLASS_BE    # => 2
IOnice::IOPRIO_CLASS_IDLE  # => 3

iopro who

from linux/ionice.h

IOnice::IOPRIO_WHO_PROCESS  # => 1
IOnice::IOPRIO_WHO_PGRP     # => 2
IOnice::IOPRIO_WHO_USER     # => 3

ionice get

# for process
IOnice::get(Process.pid)
# => { 'class' => IOnice::IOPRIO_CLASS_NONE }
IOnice::get(Process.pid)
# => { 'class' => IOnice::IOPRIO_CLASS_RT, 'priority' => 2 }
  • for process

    IOnice::get(pid)
    IOnice::get(pid, IOnice::IOPRIO_WHO_PROCESS)
  • for process group

    IOnice::get(pgid, IOnice::IOPRIO_WHO_PGRP)
  • for uid

    IOnice::get(uid, IOnice::IOPRIO_WHO_USER)

ionice set

# for process
IOnice::set(Process.pid, IOnice::IOPRIO_CLASS_NONE)
IOnice::set(Process.pid, IOnice::IOPRIO_CLASS_IDLE)
IOnice::set(Process.pid, IOnice::IOPRIO_CLASS_BE, 7) # priority is 0..7
IOnice::set(Process.pid, IOnice::IOPRIO_CLASS_RT, 2) # priority is 0..7
# => true
  • for process

    IOnice::set(pid, IOnice::IOPRIO_CLASS_BE, 2)
    IOnice::set(pid, IOnice::IOPRIO_CLASS_BE, 2, IOnice::IOPRIO_WHO_PROCESS)
  • for process group

    IOnice::set(pgid, IOnice::IOPRIO_CLASS_BE, 2, IOnice::IOPRIO_WHO_PGRP)
  • for uid

    IOnice::set(uid, IOnice::IOPRIO_CLASS_BE, 2, IOnice::IOPRIO_WHO_USER)

License

under the MIT License:

  • see LICENSE file