some aditions to processes md
This commit is contained in:
parent
0b6a08d45e
commit
3bb4a65b6d
|
@ -307,12 +307,77 @@ I'm asking you to look for an answer online but the solution can be found the re
|
|||
|
||||
## Zombie processes
|
||||
|
||||
Yes, there are such things as zombie processes.
|
||||
Learning how to create them is a bit out of our scope but I highly advise you to read up a bit on [what](https://en.wikipedia.org/wiki/Zombie_process) they are and [how](https://www.howtogeek.com/701971/how-to-kill-zombie-processes-on-linux/) to deal with them.
|
||||
|
||||
## Process priorities
|
||||
|
||||
Life is all about setting priorities and while Linux is very good at managing it's CPU time all by itself, sometimes we know better.
|
||||
We've seen the priorities before in `htop` in the `NI` column but we can view them as well via `ps o nice`.
|
||||
A more detailed command would be `ps o nice,pid,ppid,args` which for my laptop returns the following:
|
||||
|
||||
```
|
||||
➜ ~ git:(master) ✗ ps o nice,pid,args
|
||||
NI PID COMMAND
|
||||
0 2220 zsh
|
||||
0 2283 -zsh
|
||||
0 2323 /bin/sh /usr/bin/startx
|
||||
0 2345 xinit /etc/X11/xinit/xinitrc -- /etc/X11/xinit/xserverrc :0 vt1 -keeptty -auth /tmp/serverauth.8jVsAiU2KQ
|
||||
0 2346 /usr/lib/xorg/Xorg -nolisten tcp :0 vt1 -keeptty -auth /tmp/serverauth.8jVsAiU2KQ
|
||||
0 2354 x-window-manager -a --restart /run/user/1000/i3/restart-state.2354
|
||||
0 5848 zsh
|
||||
0 8365 zsh
|
||||
0 9036 zsh
|
||||
0 9065 newsboat
|
||||
0 10478 ssh waldek@86thumbs.net
|
||||
0 13113 vim learning_processes.md
|
||||
0 13860 ps o nice,pid,args
|
||||
0 28084 zsh
|
||||
➜ ~ git:(master) ✗
|
||||
```
|
||||
|
||||
All my processes are neutral on a scale from *nice* to *not-very-nice*.
|
||||
You can tell because they are at `0`.
|
||||
The **nice** scale goes from `-20` being not-at-all-nice to `20` being super friendly towards other processes.
|
||||
The nicer a process the less aggressive it will be when demanding CPU time.
|
||||
|
||||
### Nice
|
||||
|
||||
Depending on your system a new process will get a specific nice value.
|
||||
On my Debian laptop by default processes get `5` as nice value.
|
||||
We can inspect this as follows where the `ping` command is the new process:
|
||||
|
||||
```
|
||||
➜ ~ git:(master) ✗ ping 8.8.8.8 > /dev/null &
|
||||
[1] 15428
|
||||
➜ ~ git:(master) ✗ ps o nice,pid,args -p 15428
|
||||
NI PID COMMAND
|
||||
5 15428 ping 8.8.8.8
|
||||
➜ ~ git:(master) ✗
|
||||
```
|
||||
|
||||
Let's be nice to start with and set the process to be not aggressive at all.
|
||||
You can launch a command with a specific nice value by prepending `nice -n 15` before the command.
|
||||
The value you set will be **added** to the default value as seen below (but tops out at 19 and -19).
|
||||
|
||||
```
|
||||
➜ ~ git:(master) ✗ nice -n 15 ping 8.8.8.8 > /dev/null &
|
||||
[1] 15632
|
||||
➜ ~ git:(master) ✗ ps o nice,pid,args -p 15632
|
||||
NI PID COMMAND
|
||||
19 15632 ping 8.8.8.8
|
||||
➜ ~ git:(master) ✗
|
||||
```
|
||||
|
||||
Now what about *aggressive* processes?
|
||||
I would like you to try and set a very *not-nice* value for a `ping` or `sleep` process?
|
||||
You can probably guess but it won't work.
|
||||
Why do you think this is?
|
||||
|
||||
### Renice
|
||||
|
||||
|
||||
|
||||
## Exercises
|
||||
|
||||
Download the following files:
|
||||
|
|
Loading…
Reference in New Issue