rAzOr
rAzOr

Reputation: 320

How to prioritize a particular process on start up?

In Linux, I want a process to be assigned with higher priority than usual. I.e. when a process starts I want it's priority to be set to higher value. I want this to be done implicitly, i.e when the process starts (eg.:on a double click).

For this will I have to change the kernel code (sched.c)?

And are there any tools or packages using which I can see how exactly a process starts and how the priorities are assigned?

Would ptrace ( http://linux.die.net/man/2/ptrace) and strace ( http://linux.die.net/man/1/strace) help me with this?

Upvotes: 1

Views: 2159

Answers (2)

stsquad
stsquad

Reputation: 6032

Assuming you don't want to hack the actual application itself you can always create a custom desktop file which wraps the command with "nice" which will modify the niceness (priority) of the command you'll run.

For example, create a ~/.local/share/applications/myfastapp.desktop which looks like:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Exec=nice -n -20 /usr/bin/myapp
Name=My App (niced)
Comment=Custom definition for myapp

Upvotes: 1

gby
gby

Reputation: 15218

Have the process call the set_priority() system call in main() to lower it's nice level and raise it's priority. See the man page for details: http://linux.die.net/man/2/setpriority

You can also mark the process as a real time process using sched_setscheduler() but that is a little bit more involved and probably an overkill for what you seek.

You 100% don't need to change the kernel for this :-)

Upvotes: 0

Related Questions