一、进程的基础
1、进程和程序的区别
每个进程都有自己的PID,PCB(是一个结构体,有占用资源的情况)
2、操作系统上运行的所有进程构成一颗树。
3、如何察看这课树:
pstree(1)
init──NetworkManager─┬─dhclient
├─dnsmasq
└─2*[{NetworkManager}]
树根进程是init,其PID是1
进程间的亲缘关系有两种:父子关系,兄弟关系
4、使用top(1)命令来观察进程的实时的更新 ctrl+c结束
tarena@ubuntu:~$ top
top - 09:15:28 up 40 min, 3 users, load average: 0.56, 0.66, 0.54
Tasks: 176 total, 1 running, 175 sleeping, 0 stopped, 0 zombie
Cpu(s): 14.3%us, 28.6%sy, 0.0%ni, 57.1%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 2025840k total, 1123868k used, 901972k free, 156168k buffers
Swap: 1952764k total, 0k used, 1952764k free, 545592k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2024 tarena 20 0 38228 4080 2944 S 32 0.2 0:15.61 ibus-daemon
2494 tarena 20 0 109m 18m 12m S 32 1.0 0:06.13 gnome-terminal
2820 tarena 20 0 2836 1184 880 R 32 0.1 0:03.11 top
1 root 20 0 3600 2076 1312 S 0 0.1 0:00.55 init
2 root 20 0 0 0 0 S 0 0.0 0:00.00 kthreadd
3 root 20 0 0 0 0 S 0 0.0 0:00.13 ksoftirqd/0
5 root 20 0 0 0 0 S 0 0.0 0:00.23 kworker/u:0
6 root RT 0 0 0 0 S 0 0.0 0:00.00 migration/0
7 root RT 0 0 0 0 S 0 0.0 0:00.00 watchdog/0
8 root RT 0 0 0 0 S 0 0.0 0:00.00 migration/1
10 root 20 0 0 0 0 S 0 0.0 0:00.11 ksoftirqd/1
12 root RT 0 0 0 0 S 0 0.0 0:00.00 watchdog/1
13 root 0 -20 0 0 0 S 0 0.0 0:00.00 cpuset
14 root 0 -20 0 0 0 S 0 0.0 0:00.00 khelper
15 root 20 0 0 0 0 S 0 0.0 0:00.00 kdevtmpfs
16 root 0 -20 0 0 0 S 0 0.0 0:00.00 netns
18 root 20 0 0 0 0 S 0 0.0 0:00.01 sync_supers
5、使用ps(1)命令也可以察看进程
tarena@ubuntu:~$ ps -aux
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 3600 2076 ? Ss 08:35 0:00 /sbin/init
root 2 0.0 0.0 0 0 ? S 08:35 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S 08:35 0:00 [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S 08:35 0:00 [kworker/u:0]
root 6 0.0 0.0 0 0 ? S 08:35 0:00 [migration/0]
root 7 0.0 0.0 0 0 ? S 08:35 0:00 [watchdog/0]
root 8 0.0 0.0 0 0 ? S 08:35 0:00 [migration/1]
root 10 0.0 0.0 0 0 ? S 08:35 0:00 [ksoftirqd/1]
root 12 0.0 0.0 0 0 ? S 08:35 0:00 [watchdog/1]
还没有评论,来说两句吧...