The Linux distillery
The nuts and bolts of the Linux process scheduler | The nuts and bolts of the Linux process scheduler |
|
|
| by David M Williams | |
| Monday, 18 February 2008 | |
|
Page 3 of 3 Use the up arrow and enter to call ps repeatedly over a period of several seconds. You’ll see very soon that the priority – the PRI column – changes value for both scripts. The priority for yielder.sh increases and the priority for preempter.sh decreases. This is because the scheduler is giving a positive and a negative bonus respectively.Immediately, you will realise that the cards are against you if you genuinely want your system to give its utmost to your complex calculations. On the one hand, there’s a reason for this: Linux wants to ensure performance isn’t degraded for anyone using the system interactively. On the other hand, it’s your system. It should do what you want. And make it do what you want you can. You can directly influence the scheduler’s decisions through another value, called the nice value. This is so called because it lets you be “nice” to other tasks on the system. Give a process a positive nice value, and it will have a lower overall priority. By contrast, give it a negative nice value and the scheduler will boost its priority higher. Only the super user can assign a negative nice value; the only thing non-privileged users may do is bump their own processes lower down the queue. Re-run the preempter.sh process with a negative nice value like so: sudo nice –n -5 ./preempter.sh & Check out its effective priority via the same ps command as above and compare to the previous set of results. Once a nice value has been set it is fixed for the lifetime of the process unless you alter it with a command called renice; apart from this nothing else can influence it. Use renice to modify the nice value of an existing process with a command like this:
sudo renice -10 –p 50432
Get stories like this delivered daily - FREE - subscribe now
|
| < Next story in category | Previous story in the category > |
|---|





Tags





