分类: LINUX
2010-09-03 19:27:27
虽然研究了不少linux设备驱动,但总觉得欠缺些什么,使得我对Linux总是理解不深,因此决定静下心来,根据大师Gary Nutt的操作系统内核实习,来熟悉基本的linux内核知识。
内核版本:
注:只是在
练习一 观察linux行为
练习目的:学习linux内核、进程、存储和其他资源的一些重要特征。编写一个程序使用/proc机制检查反映机器平均负载、进程资源利用等方面的各种内核值。在得到内核状态后,需要准备一个有关所观察到的累积行为的报告。
1, 回答下列有关linux机器的问题
(1)CPU的类型和型号
[zhh@localhost ~]$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 1
model name : Intel(R) Celeron(R) CPU 1.70GHz
stepping : 3
cpu MHz : 1693.087
cache size : 128 KB
fdiv_bug : no
hlt_bug : no
f
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm up pebs bts
bogomips : 3386.17
clflush size : 64
power management:
(2)所使用的linux内核版本
[zhh@localhost ~]$ uname -a
Linux localhost.localdomain
[zhh@localhost ~]$ cat /proc/version
Linux version
(3)从系统最后一次启动以来已经经理了多长时间(天、小时和分钟)?
[zhh@localhost ~]$ uptime
16:38:15 up 1 day, 7:24, 1 user, load average: 0.00, 0.00, 0.00
(4)总共有多少CPU时间执行在用户态?系统态?空闲态?
[zhh@localhost ~]$ cat /proc/stat
cpu 4539 68 3104 11326798 10843 15 132 0 0
cpu0 4539 68 3104 11326798 10843 15 132 0 0
intr 1837656 146 2 0 2 2 0 5 0 1 0 0 0 4 0 0 26579 0 0 1140180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ctxt 1777453
btime 1283390031
processes 3761
procs_running 2
procs_blocked 0
第一行 第一个域是用户态时间, 第二个是低优先权用户模式时间,第三个是系统态时间
第四个是空闲态时间。
(5)配置了多少内存?当前多少可用?
[zhh@localhost ~]$ cat /proc/meminfo
MemTotal: 254064 kB
MemFree: 4940 kB
Buffers: 76204 kB
Cached: 111628 kB
SwapCached: 0 kB
Active: 58740 kB
Inactive: 142732 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 254064 kB
LowFree: 4940 kB
SwapTotal: 524280 kB
SwapFree: 524280 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 13668 kB
Mapped: 13496 kB
Slab: 29236 kB
SReclaimable: 24860 kB
SUnreclaim: 4376 kB
PageTables: 1396 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 651312 kB
Committed_AS: 86556 kB
VmallocTotal: 765944 kB
VmallocUsed: 2940 kB
VmallocChunk: 762664 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 4096 kB
DirectMap4k: 16320 kB
DirectMap
(6)有多少磁盘读写请求
[zhh@localhost ~]$ cat /proc/diskstats
1 0 ram0 0 0 0 0 0 0 0 0 0 0 0
1 1 ram1 0 0 0 0 0 0 0 0 0 0 0
1 2 ram2 0 0 0 0 0 0 0 0 0 0 0
1 3 ram3 0 0 0 0 0 0 0 0 0 0 0
1 4 ram4 0 0 0 0 0 0 0 0 0 0 0
1 5 ram5 0 0 0 0 0 0 0 0 0 0 0
1 6 ram6 0 0 0 0 0 0 0 0 0 0 0
1 7 ram7 0 0 0 0 0 0 0 0 0 0 0
1 8 ram8 0 0 0 0 0 0 0 0 0 0 0
1 9 ram9 0 0 0 0 0 0 0 0 0 0 0
1 10 ram10 0 0 0 0 0 0 0 0 0 0 0
1 11 ram11 0 0 0 0 0 0 0 0 0 0 0
1 12 ram12 0 0 0 0 0 0 0 0 0 0 0
1 13 ram13 0 0 0 0 0 0 0 0 0 0 0
1 14 ram14 0 0 0 0 0 0 0 0 0 0 0
1 15 ram15 0 0 0 0 0 0 0 0 0 0 0
7 0 loop0 0 0 0 0 0 0 0 0 0 0 0
7 1 loop1 0 0 0 0 0 0 0 0 0 0 0
7 2 loop2 0 0 0 0 0 0 0 0 0 0 0
7 3 loop3 0 0 0 0 0 0 0 0 0 0 0
7 4 loop4 0 0 0 0 0 0 0 0 0 0 0
7 5 loop5 0 0 0 0 0 0 0 0 0 0 0
7 6 loop6 0 0 0 0 0 0 0 0 0 0 0
7 7 loop7 0 0 0 0 0 0 0 0 0 0 0
8 0 sda 23736 3024 419447 149551 2858 9456 98500 51298 0 119902 200815
8 1 sda1 115 986 2232 1266 2 0 4 7 0 910 1273
8 2 sda2 23611 2025 417031 148228 2856 9456 98496 51291 0 119443 199485
253 0 dm-0 25318 0 416042 172428 12312 0 98496 339814 0 119582 512237
253 1 dm-1 82 0 656 512 0 0 0 0 0 101 512
2 0 fd0 0 0 0 0 0 0 0 0 0 0 0
(7)内核已经进行了多少次上下文切换?
cat /proc/stat
cpu 4539 68 3104 11326798 10843 15 132 0 0
cpu0 4539 68 3104 11326798 10843 15 132 0 0
intr 1837656 146 2 0 2 2 0 5 0 1 0 0 0 4 0 0 26579 0 0 1140180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ctxt 1777453
btime 1283390031
processes 3761
procs_running 2
procs_blocked 0
(8)从系统启动以来已经创建了多少进程?
cat /proc/stat
cpu 4539 68 3104 11326798 10843 15 132 0 0
cpu0 4539 68 3104 11326798 10843 15 132 0 0
intr 1837656 146 2 0 2 2 0 5 0 1 0 0 0 4 0 0 26579 0 0 1140180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ctxt 1777453
btime 1283390031
processes 3761
procs_running 2
procs_blocked 0
chinaunix网友2010-09-07 11:14:15
Download More than 1000 free IT eBooks: http://free-ebooks.appspot.com