• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

change prority of pid to change its state

How can I change priority of a pid so it does not sleep.

1 Solution
you can run renice(1) to change its prority, but it can still sleep(3)
You can might it a signal(3) to wake it up
Brian UtterbackPrinciple Software EngineerCommented:
There is no way to guarantee that a process never sleeps because sometimes it will need resources that
are not immediately available. If it did not sleep ever, then the whole system would essentially lock up.
Having said that, you can make it so a process never gives up the CPU involuntarily. You can place a process
in the real time scheduling class. In that class, it will not be preempted, but if it never gives up the cpu then
the computer is hung.

To place a process in the real time class, use the priocntl command. For the exact syntax, see the priocntl man
page. Of course, you have to be root to do it, or have sufficient privs.
I agree with blu that hardly you will find a process that does not sleep unless it is just looping and does not need any resource like disk IO, etc.

If you have multiple processors on your system, then you may let this process run on a particular CPU.

z670193Author Commented:
What is the difference between renice and priocntl?

Which one of them would be a better option?

Brian UtterbackPrinciple Software EngineerCommented:
Solaris supports multiple scheduling classes, each with its own characteristics. How each one of those classes
decides which processes to schedule is determined by the class, using some class parameters and characteristics of the processes. One way a class can prioritize the processes is via the "nice" value. A smaller nice number, the
higher priority. So, the renice command will allow you to change the relative priority of a process within a scheduling
class. The priocntl command will allow you to change a process to a whole new scheduling class. This include the
RT, or real time class.  The RT class is the only class that does not preemptively interrupt a process and pull it off the CPU. The process must give up the CPU itself before any other process can run.

Needless to say, any process in the RT class needs to be aware that it owns the machine and nothing else
can get done while it is on the CPU.

Perhaps this isn't really what you want. However, I suggest you read the priocntl man page to get some insight
how to get what you really want.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now