Run process with higher priority

29,258

Solution 1

To set niceness (CPU bound) use nice. To set IO niceness (IO bound) use ionice. Refer to the respective man pages for more information. You can use them together as follow:

ionice -c 2 -n 0 nice -n -20 mplayer

Note: the lowest level of niceness (lower means more favorable) you can define is determined by limits.conf. On my computer the file is located at /etc/security/limits.conf.

Solution 2

In general, as a non-root user, you can only decrease the priority of your tasks, not increase them. So, one approach would be to lower the priority of everything else. Or, you can set up something at the system level which handles your priorities.

If you're using a relatively modern Linux distribution, the most powerful way would be with control groups. This is in its infancy so basically you'd have to configure everything by hand, but in short what you want is to configure the categorizer to put different processes into different CPU control groups, and then to give the mplayer process more CPU shares.

Share:
29,258

Related videos on Youtube

SHW
Author by

SHW

Linux System Integrator by profession

Updated on September 17, 2022

Comments

  • SHW
    SHW almost 2 years

    I want to run mplayer with higher priority than any other processes, including the IO-processes. How can I do that?

    • Gilles 'SO- stop being evil'
      Gilles 'SO- stop being evil' over 13 years
      There is no cross-unix variant answer to this question. In general it's better to describe what OS you're using (including the distribution for Linux, but here it won't matter much if at all). I've added a linux tag, please change it if that's not what you're using.
    • killermist
      killermist about 12 years
      Do you mind if I ask why you're looking to increase the priority of mplayer? I ask because I've had issues before where increasing the priority of mplayer, the effect was opposite what I was trying to accomplish because mplayer would get busy using up CPU time doing post-production cleaning, then grind to a halt as the network finally got a gasp of air to go grab more content, then mplayer would stutter back to life, just to grind to a halt again waiting for network.
    • SHW
      SHW about 12 years
      I asked this cause, I am playing a movie through mplayer. Whenever I try to download few GB files over network. Mplayer observes slicing and a jerk while playing.
  • mattdm
    mattdm over 13 years
    Mentioning the io scheduler classes is good, because that's likely to be a big factor. Worth nothing that for the middle -c2 scheduling class, processes are by default sorted by the nice level, so the example command you've given is really not necessary. One could try putting mplayer in the -c1 realtime class. (With root access.)