【C语言】【unix c】进程的基础

深碍√TFBOYSˉ_ 2022-06-09 05:27 292阅读 0赞
  1. 一、进程的基础
  2. 1、进程和程序的区别
  3. 每个进程都有自己的PIDPCB(是一个结构体,有占用资源的情况)
  4. 2、操作系统上运行的所有进程构成一颗树。
  5. 3、如何察看这课树:
  6. pstree(1)
  7. init──NetworkManager─┬─dhclient
  8. ├─dnsmasq
  9. └─2*[{NetworkManager}]
  10. 树根进程是init,其PID1
  11. 进程间的亲缘关系有两种:父子关系,兄弟关系
  12. 4、使用top(1)命令来观察进程的实时的更新 ctrl+c结束
  13. tarena@ubuntu:~$ top
  14. top - 09:15:28 up 40 min, 3 users, load average: 0.56, 0.66, 0.54
  15. Tasks: 176 total, 1 running, 175 sleeping, 0 stopped, 0 zombie
  16. 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
  17. Mem: 2025840k total, 1123868k used, 901972k free, 156168k buffers
  18. Swap: 1952764k total, 0k used, 1952764k free, 545592k cached
  19. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
  20. 2024 tarena 20 0 38228 4080 2944 S 32 0.2 0:15.61 ibus-daemon
  21. 2494 tarena 20 0 109m 18m 12m S 32 1.0 0:06.13 gnome-terminal
  22. 2820 tarena 20 0 2836 1184 880 R 32 0.1 0:03.11 top
  23. 1 root 20 0 3600 2076 1312 S 0 0.1 0:00.55 init
  24. 2 root 20 0 0 0 0 S 0 0.0 0:00.00 kthreadd
  25. 3 root 20 0 0 0 0 S 0 0.0 0:00.13 ksoftirqd/0
  26. 5 root 20 0 0 0 0 S 0 0.0 0:00.23 kworker/u:0
  27. 6 root RT 0 0 0 0 S 0 0.0 0:00.00 migration/0
  28. 7 root RT 0 0 0 0 S 0 0.0 0:00.00 watchdog/0
  29. 8 root RT 0 0 0 0 S 0 0.0 0:00.00 migration/1
  30. 10 root 20 0 0 0 0 S 0 0.0 0:00.11 ksoftirqd/1
  31. 12 root RT 0 0 0 0 S 0 0.0 0:00.00 watchdog/1
  32. 13 root 0 -20 0 0 0 S 0 0.0 0:00.00 cpuset
  33. 14 root 0 -20 0 0 0 S 0 0.0 0:00.00 khelper
  34. 15 root 20 0 0 0 0 S 0 0.0 0:00.00 kdevtmpfs
  35. 16 root 0 -20 0 0 0 S 0 0.0 0:00.00 netns
  36. 18 root 20 0 0 0 0 S 0 0.0 0:00.01 sync_supers
  37. 5、使用ps(1)命令也可以察看进程
  38. tarena@ubuntu:~$ ps -aux
  39. Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
  40. USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
  41. root 1 0.0 0.1 3600 2076 ? Ss 08:35 0:00 /sbin/init
  42. root 2 0.0 0.0 0 0 ? S 08:35 0:00 [kthreadd]
  43. root 3 0.0 0.0 0 0 ? S 08:35 0:00 [ksoftirqd/0]
  44. root 5 0.0 0.0 0 0 ? S 08:35 0:00 [kworker/u:0]
  45. root 6 0.0 0.0 0 0 ? S 08:35 0:00 [migration/0]
  46. root 7 0.0 0.0 0 0 ? S 08:35 0:00 [watchdog/0]
  47. root 8 0.0 0.0 0 0 ? S 08:35 0:00 [migration/1]
  48. root 10 0.0 0.0 0 0 ? S 08:35 0:00 [ksoftirqd/1]
  49. root 12 0.0 0.0 0 0 ? S 08:35 0:00 [watchdog/1]

发表评论

表情:
评论列表 (有 0 条评论,292人围观)

还没有评论,来说两句吧...

相关阅读