??? Linux?????? - PowerPoint PPT Presentation

1 / 111
About This Presentation
Title:

??? Linux??????

Description:

Title: PowerPoint Author: mwz2 Last modified by: muz Created Date: 1/18/2003 12:58:36 AM Document presentation format: Company – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 112
Provided by: mwz2
Category:
Tags: linux | sigint

less

Transcript and Presenter's Notes

Title: ??? Linux??????


1
??? Linux??????
7.1 Linux?? 7.2 Linux???? 7.3 ????????
7.4 Linux???? 7.5 Linux???? 7.6
Linux????
2
7.1 Linux ? ?
7.1.1 Linux?????
  • 1. UNIX?????
  • 2. Linux???
  • 3. Linux????
  • ???????????????
  • (2) ???????????????
  • (3) ???????????

3
7.1.2 Linux????
  • ???????
  • (1) ???(Clarity)?
  • (2) ???(Compatibility)?
  • ? ?????????
  • ? ?????????
  • ? ?????????
  • (3) ????(Portability)?
  • (4) ???????(Robustness and Security)?
  • (5) ??(Speed)?

4
2. ???????????
?7.1 ???????????
5
?7.1????UNIX?????????, ???????????????????
???????????? ? (1) ?????????????? ? (2)
???????????????, ????????????
6
?7.2 ??????????
7
?7.2????????????????????????????????????
? ? ????????????,?????libc? ? ?
???????system-call????,??????????????????????????
? ? ??????????????????,???????????????????
???????? ? ? ??????????????
8
3. Linux????????
(1) ???(Microkernel Kernel)? ????????4??????
? ? ??????? ? ? ???????? ? ? ???????????? ? ?
????/?????
9
(2) ???(Monolithic Kernel)?
?????????????????,????????????????????????(???????
?)?????????,???????????????????????,??????????????
?????????????, ???????????????????????????????????
????????????? Linux???????????,???????????
????? ?????????????Linux????????
10
4. ?????????? ????????????/usr/src/
linux?????????????????,???????????????????
(1) documentation ??????????, ?????????? ?
(2) arch????????????????????????
???????????????????????? ? kernel
???????????????????SMP??????? ? ? lib
????????????????????? ? mm
???????????????????
11
(3) drivers????????????????????
???SCSI??????????PCI?????Linux????????????? ?
(4)fsLinux??????????fs?????????????? ?
(5)include??????Linux???????????(.h)??,???? ?
? include/asm?/ arch????,
????????????????????????????????????? ? ?
include/linux/ ??????????????????????????????,???
?????
12
? include/net/ ??????????????? ?
? include/scsi/ ??SCSI????SCSI??????????
? include/video/ ??????????????????? (6)
init ??????????main.c, ???????????????????
(7) ipc ??????????System V??????(IPC)??? ?
(8) kernel ????????Linux???????
????????????????????(kernel/sched.c)?
????????????(kernel/fork.c?kernel/exit.c)?
13
(9) lib ?????lib/inflate.c????,
???????????????????lib????????????????C??????? ?
(10) mm ???????????????????,??????????????????
?????????, ????arch/platform/mm?? ? (11)
net??????Linux?????????, ??AppleTalk,TCP/IP??
(12) scripts ??????????,?????????????????ma
ke menuconfig??make xconfig??????????,
????????????????????
14
7.1.3 Linux ????? ????????
??Linux????????????????????
?????????(????)????????????????????, ??????,
????????Shell?????? X-Windows?????????,???????????
?????????????????????????????????????,????????????
???????????,?????????????????????????????,Linux???
????????
15
????????????????????????,
???????????????,??????????????,
??????????????????,????????????????????Linux??????
???????????????????,????????????????????,?????????
??????,?????????????????????????????
???????????????????????????????????,?????????????
????????
16
???????????????? ????????????????????????
?????????????????????????????????(PC),?CPU??????
????,????????,???,??????????????????task-struct??
??????????? ? ?????????????????????????????
,??????????????,??????????? ?????????????????
17
7.2 Linux? ? ? ?
7.2.1 Linux???????
(1) ????(State) ? ??(Running) ? ??(Waiting) ?
??(Stopped) ? ??(Zombie)
18
?7.3 ?????????
19
(2) ????(Scheduling Information )
???State???, ????policy(??)?priority(???)?
rt-priority(?????)?counter(??)????????????????????
?
20
(3) ?????(Identifiers)????????????????????
??????,?????????????????????Linux?????????????????
??, ?????????????????????????????????????,????????
??????????,??????????????????????????????,???????
???????,???????????????????
21
task-struct????4???????? ? ?
uid, gid ?????????????????? ? ? ?? uid
??? gid ??????????uid?gid??,????????????,??????se
tuid(setgid)??????????uid(gid),??????????????????
? ? ????uid ? gid ????????????????? ?
? ?? uid ? gid ??POSIX???????????
22
(4) ???????(Inter?Process Communication)?
Linux?????UNIX IPC??,???????SYSTEM
V?IPC??,????????????????????????????????? ?
(5) ?????(Links)? Linux???????????,???????????????
?????????????,???????????? ???????task-struct?????
????????????(??????????)???????????,??????????????
?????,??????init???task-struct??????????Linux?????
??????????
23
(6) ??????(Times and Timers)?????????????????
?????????????CPU?????????????????????????????Linux
?????????interval???,?????,???????????????
(7) ??????(File System)???????????????,???task-str
uct???????????????????file??????VFS
inode???fs???VFS Inode?????????????????,
????????????????????????????????????????? ???VFS
inode?????count?,?????????,???????
24
(8) ????(Virtual Memory)?????????????(???????
????),task-struct?????mm?????????mm-struc??,??????
?????mmap?????vm-area-struc???????
25
7.2.2 ???????????
??????????????????????????????????,????????
?,????????????????????????????????? ? (1)
???????? (2) ?????? (3) ????
(4) ????
26
7.2.3 ???????
?7.4 ?????????
27
7.2.4 ?????????
?7.5 ???????
28
7.2.5 ????
????????????????????, ??????????????
??I/O??(open, close, read, write,
poll?),????(fork, execve, kill?),????(time,settime
ofday?)??????(mmap,brk?)????????????????????
29
7.2.6 ????????
init???/etc/inittab????????????????
???????????????????????????????????????????????sys
-fork()?sys-clone(),????????????????????,?????????
?????task-struct?????????, ??????????????????(pid)
?
30
???????sys-clone()???,???????????????????,
?????task-struct??fs?files?mm?????????,??????count
??1,??????????????????count??0?,Linux?????????????
???????? ? ????????????,Linux??copy on
write??, ???????????????????,??????mm????????????
??,??????mm???????????????????mm????
31
7.3 ????????
7.3.1 ??(signal)
Linux???????????,?????????????????????????
????????????, ?task-struct??signal???????????kill?
?(kill-l)????????????????,?
32
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5)
SIGTRAP 6) SIGIOT 7) SIGBUS 8) SIGFPE 9)
SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2
13) SIGPIPE 14) SIGALRM 15) SIGTERM 17)
SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22) SIGTTOU 23) SIGURG 24)
SIGXCPU 25) SIGXFSZ 26) SIGVTALRM 27)
SIGPROF ?28) SIGWINCH? 29) SIGIO 30) SIGPWR
33
7.3.2 ??(Pipe)
?7.6 ???????
34
?7-1 ??????????
? ? ? ? ? ?
????????????? ??????????
I/O???, ??? I/O???, ??
????????????????? ??????????????
?Mkfifo?? ?Pipe??
35
7.3.3 ????
?7.7 Linux????
36
7.3.4 ???
?7.8 Linux ???????
37
7.3.5 ????? ???????????????????????????????
???????????????, ?????????????????????????????????
??????????,?????????????????????????????System V
IPC?????????, ????????????????????????????
????????,?????????????????????????,???System
V???,????????????
38
7.4 Linux ????
7.4.1 ?????????
??????????????,????????????????????????????
???????????????, ??????? ?????????????,
?????????????????????????,????????????????????????
???????, ?????????????,???????????????????????????
????????????????,????????????????????????????????
39
7.4.2 80386???????????
? 7.9 ?????????????????
40
7.4.3 Linux??????
1. ????? ?Linux?,??????????4
GB???????????,03 GB?????,????????????34
GB?????,????????????,????????????????34
GB?????????,????????,?????, ????????????
41
2. Linux?????? ?i386???,??????????4
GB,????????4 KB? ??,????????????1
M?????????????????,??????????1 M???,??4
MB??,???????????????Linux??????????????????,??????
?,??i386??CPU??????,?PGD?PMD??????,??????
??? ????? ?? ????
PTE
PMD
PGD
42
3. ????????mm-struct?
??????,Linux????task?-struct??,
????mm-struct??,???????????????????????????????(p
gd),???????????,???????????,??????????/????,??????
??/????,??????????,??AVL???,???????
43
7.4.4 ??????????
1. ???????
?7.10 free-area????
44
2. ??????? Linux??buddy?????????
????????????????,Linux????????????1????,2?????4???
????????????,Linux???free-area????????????????????
??????????????,?????????????????
??????????free-area ??????????????????????????????
????????,???????????????????????,????????,??????fr
ee-area????list???,?????????,??????,??????,???????
?????????bitmap?,?????0??1?
45
3. ??????? ?????????????,??????????
???????????????????,??????????????????????,???????
?, ???????????????????????bitmap?????,?free-area??
??????????????????,??????????????????,????????????
????????????????????????????
46
7.4.5 ??????
?7.11 ?????????
47
7.4.6 ????
?7.12 ?????????
48
7.4.7 ?????????
?vm-area-struct?????????????????????,???vm
-area-struct???????AVL(Adelson-Velskii and
Landis) ???????????????vm-area-struct?????????????
,?????????????????? ??Linux??????SIGSEGV??,???????
??????????????????????,Linux??????????????????????
?????????, ?????????????
49
??Linux??????????,?????????????????Linux??
??????????????????????????????????????????,???????
???,?????????????????? ? ??Linux
nopage????????????????,???????cache???????????????
??????????????,???????????????????????????,???????
?TLB?? ???????????, ????????????????????????
50
7.4.8 ????? Linux?????????????,????????,??
??????,???????????????????????,
??????????????????????????????,????????????4096???
??????swap-space?????,?????????????????,????????
????????????4096?????????????????????????????32-69
7???? ???????????, Linux????????????,????8
????
51
7.4.9 ??????? ???????????,
Linux?????????????????????????????(kswapd )?????
??????????????????????????????,
??????????,????????????????????????????(????????),
???????????????????????????
52
??????,???????init????,????10
ms??????????????,????????????????????????????????
free-pages-high ?free-page-low,???????????????????
???????free-pages-high,??????????????,????????????
??????,????????????????????????????
53
????????????free-pages-high??free-pages-lo
w???,??????????????????????????????? ? ?
?????(Buffer Cache)???Cache(Page Cache)???? ?
? ?System V???????????? ? ?
??????????????
54
7.4.10 ?????????????
(1) Buffer CacheBuffer Cache??????????????
??????????????????????(?512??),???????????????????
??????????????????????????????????????????????????
??Buffer Cache????????????????????Buffer
Cache???? ?????Buffer Cache??????????????(???)???,
?????????
55
(2) Page Cache????????????????????????????
????????????????????????Page Cache??????????????,?
?????Page Cache?????????Page Cache?,???????????mem
-map-t????????????????,??Linux??????,?????????????
?
56
(3) Swap Cache ?????????????????
????????????????????,????????????,???????????,????
????????????????????,Swap Cache??????????????????
? (4) Hardware Caches ?????Hardware
Cache?????Cache,??Cache???Translation Look-aside
Buffers(TLB),?????????????????????????
57
7.5 Linux ????
7.5.1 Linux???????
  • ??????????
  • 2. ???????????
  • 3. ????????(VFS)

58
7.5.2 EXT2????????
??0 ??N-1 ??N
?? ???? ??? ?????? ????? ???
? 7.13 EXT2 ?????????
59
7.5.3 EXT2 ????
? 7.14 EXT2 ????
60
7.5.4 EXT2 ???
???????????? ? (1) ?? ?????????? ? (2)
???? ????? ? (3) ????????? (4) ???
?????????????? ? (5) ??? ???????????, ?? 1024
???? (6) ???? ???????????? (7) ???
????????????????? ? (8) ??????
?????????????????? (9) ??????? ???????????????
61
7.5.5 EXT2 ????
??????????????? ? (1) ????? ??????????? ? (2)
?????? ?????????????? ? (3) ????? ?????????????
62
7.5.6 EXT2 ??
?7.15 EXT2??????
63
7.5.7 EXT2 ????
?????? /home/prog/file,?EXT2?,
?????????? ? (1) ????????????????????????
?????????,????????????? ? (2)
???????????home????,?????????1? (3)
????????1???????,???/home??????? (4)
?/home??????????????prog,??????????2? ?
(5) ????????2???????,????/home/prog??????? ?
(6) ?/home/prog???????????????file??????
64
7.5.8 EXT2??????
??????????????,??????????????????????????,
???????????EXT2???????????????????,???????????????
??,???????64????(??????),????????????????,????????
? ????????????????,??????8???????? ?
?????????,????????EXT2????????????????,???????????
??????? ?????????????????
65
7.5.9 ??????(VFS)??
? 7.16 ????????????
66
7.5.10 VFS ???
  • VFS?????????? ??
  • ??
  • (2) ??????
  • (3) ?????
  • (4) ?????
  • (5) ??????
  • (6) ?????????

67
7.5.11 VFS ????
(1) ?? (2) ????? (3) ?? (4) ????? (5) ?? (6)
????? (7) ?????? (8) ??? (9) ?? (10) ?(dirty)
(11) ?????????
68
7.5.12 ???????
? 7.17 ?????????
69
?? file-system-type ?????????? ?
(1) ?????????????????, VFS??????????????????
(2) ??????????, ?EXT2? ? (3)
????????????????????? ????????????????????/proc??
???????????????????/proc/filesystems?????????????,
? ext2, iso9660??
70
7.5.13 ??????????
????????????????,Linux ???????????????????
?(???????????????????????????????????)? ?? ?
mount - t iso9660 /dev/cdrom /mnt/cdrom
71
?????????????????? ? (1)
???????????VFS??file-systems?file-system-type?????
?????????????????????? ? (2)
???????????,?????????????????????????????????????,
????????????????,??,??????VFS???????? ? (3)
???????,??VFS???????????, ?????? ? (4)
VFS???????????????,????,??????
72
(5) VFS??????????????VFS????? (6)
?????????????????,?????? (7)
VFS?????????????VFS???,??????????????????????
??????VFS???????super-blocks???super-block????????
?? ? (8) ?????????????????????????VFS????? ?
? (9) ??????, ???????????????7.18????????
73
? 7.18 ?????????
74
7.5.14 ???????????
?7-2 Linux?????Cache
Cache? ? ? ?
Inode Cache (VFS ??????) node???? ??? ??
Inode Directory Cache (????) ?????????????Inode
Buffer Cache (?????) I/O????
75
1. VFS ??????
VFS?????????,????????VFS???????????????????
??? ?VFS???????, ?????VFS???????
???VFS???????????????, ?????????????,
??????????????????????????????????????????????????
,????????????inode????????????????????,????????(co
unt)??1??????????????
76
2. ????? ?????????????,
????????????, Linux?????????????????????,????????
?????????????????,??????????,??????????,??????????
??????? ???????????????,??????????????????
??????????,??????????????????????????15???????????
?????? ?
77
3. ?????(Buffer Cache)
? 7.19 ?????
78
7.5.15 bdflush ??????? bdflush
???????????????????????????????,?????????
?????????????????, ???????kflushd??????????,????
????????, ??????????????????????
????????????????????,?????????????????????????????
??????????,bdflush ????? ????? 60?
?????????,?bdflush ?????????
79
7.6 Linux ????
7.6.1 ????????? 1. ??PCI??
?7.20 ????PCI??????
80
2. PCI I/O????
Linux ??????I/O??????????? ? 0000001f dma1
0020003f pci1 0040005f timer
0060006f keybord 0070007f rtc
0080008f dma page reg 00a000bf pci2
00c000df dma2 00f000ff fpu
01700177 ide1 01f001f7 ide0
03f803ff serial(auto) d800d811 eth0
ffa0ffa8 ide0 ffa8ffaf ide1
81
3. PCI ???
?7.21 PCI???
82
(1) ????(Vendor Identification)
??????PCI?????????? ? (2) ????(Device
Identification) ???????????? (3) ??(Status)
????????????? (4) ??(Command) ??????????,
????????? ? (5) ????(Class Code) ???????????
? (6) ??????(Base Address Registers)
???????????????????PCI I/O?PCI???????? ??????
(7) ????(Interrupt Pin) PCI?????????????????????
?PCI????
83
4. PCI ???? (1) PCI-ISA ????
????????PCI I/O?PCI???????????ISA
I/O?ISA????????ISA??? PCI???PCI
I/O?PCI??????????????ISA??,?????PCI-ISA??????PCI??
???ISA????????
84
(2) PCI-PCI ??????????????PCI?????????PCI????
??????????PCI??, ??????????,?????PCI?????????PCIC
D2PCI?????????????PCI???????????????????Linux???
?PCI-PCI?????????
85
5. Linux ??PCI????
(1) PCI?????? (2) PCI BIOS ?? (3) PCI ???? ?
???????PCI I/O?PCI????? ? ? ??????PCI-PCI?????PCI
I/O?PCI??????? ? ????????????, ????????????
86
?7.22 Linux??PCI????
87
6. ???????
(1) ???
?7.23 ????????
88
(2) ???????????IBM PC??Intel 8259A-2
CMOS???????????????????ISA??????????????????7.23??
??????8????PIC1?PIC2,???????????????????????
??????????0x21?0xA1,?????????0x20?0xA0????????????
???1,???????, ??0??????????????????????????
???????,???????????????????(ISR)???0x20??ISR????16
????????8?, ??0xA0??ISR????8??
89
(3) ?????????? ??????????Linux???????????????
??????????????????????????????????
PC????????,??????????????????,???????????????6?
??????????????????,Linux?????????????????????????
90
(4) ?????
?7.24 Linux????????
91
7.6.2 ????
1. ????? Linux???????????
???????????????????????,???????????,????????/dev/c
ua0?/dev/cua1??????????????,???????512?1024???????
?????buffer cache????,??????????,???????????,
?????????? ??????????????????,???????????????????
????????????????? ????????BSD?????,??Linux????????
??/proc/devices?
92
????? ? men pty ttyp ttys
cua vcs misc fb netlink ptm pts?
???? ? ramdisk fd ide0 md ide1
93
2. ?????????? ??????????????,?????
??????????????????????????????????????????????????
?,????????IDE??????/dev/hda?Linux??????????,??????
???????????????,????????,???(??)??????????????????
mknod?????,????????????????????????????????,?Linux
?????????????????????????????????????,
??????????????????
94
3. ????
Linux?????????/dev???????????????????????
?2??3?????,????????? ?IDE????????hd,
SCSI???sd, ???fd, ???lp???????????,
????????? ?/dev/hda? /dev/hdb? /dev/hdc????? ???
?????, ?/dev/hda1? /dev/hda2?/dev/hda3????????????
??? ????? ?Linux???, ??????????file??????
95
struct file ? mode-t f?-mode?
loff-t f?-pos? unsigned
short f?-flags? unsigned short f?-count?
unsigned long f?-reada,f?-ramax,f?-raend,f?-raw
in? struct file f?-next, f?-prev?
struce fown?-struct f?-owner? struct
inode f?-inode? struct file?-operations f?
-op? unsigned long f?-version?
void private?-data?
96
7.6.3 ????????
1. ????? CPU?????????????,???????,
??????????????????????????????I/O??????,IDE?????ID
E???SCSI?????SCSI??,???????????????????????(CSR),?
???????Linux?,?????????????????????????,??????????
????????????????????????Linux???????????????????,
?????????????????,???????????
97
2. ??????????
  • ????
  • (2) ????
  • (3) ???????
  • (4) ?????
  • (5) ???

98
3. ?????? ??????????,????????????
??????????????????????????????????????,???????????
?????????????????????????,???????????????,????????
??,???????????
99
4. ?????? (DMA)?
???????????,??????????????????????????????????????
???????????????????????????(?2 ms),
?????????????????????(DMA)??????????????????????DM
A??????????DMA?????????????,??????????????
??,DMA????????????????,????????????????????DMA???,
DMA????????????,??????????16 MB???
100
5. ??
Linux?????????????????????????????2??????
????,? 512 B? 128 B? ??, ?????????????????,???????
???,?????????????????????????????,??????????????
101
6. ????????????
???????? ? lseek( ) ????????? read( )
?????????? write( ) ????????? readdir(
) ???????, ???????? select( )
?????????? ioctl( ) ??????? mmap( )
?????????????? ? open( ) ????,
??????? release( ) ????, ?????? fsync( )
???????(???)???????? check-media-change( )
??????, ??????????
102
7.6.4 ?????????
1. ??????????? ??????????????
????????,?????????,???????????????????,???????????
????Linux?????????????? ? (1) ????????????????
? (2) ?????????????? ? (3) ?????????????
103
????,Linux??????????????????? ? (1)
???????????? ? (2) ???????? ? (3) ???????
? (4) ??????? ? (5) ???????????
104
2. ???????????
(1) ???????????????????????????????????????
lp-fops????? Struct file?-operation lp?-fops?
lp?-lseek( )? NULL? lp?-write( )? NULL?
NULL? lp?-ioctl( )? NULL? lp?-open( )?
lp?-release( )? NULL? NULL?
105
(2) ??????????? ??????????lp?-init(
)???????lp-probe( )??????????register-chrdev(
)??????? ? ???????lp-release( )?????,
????????????????,???cleanup-module(
)?????,?????????????lp-open( )??????
106
(3) ????????????????????,??????,????lp-(
)???????????????, lp-write( )???lp-write(
)-interrupt( ), ??,lp-write( )???lp-write(
)-polled( )? ? (4) ?????????????????(lp-lse
ek( ))???(lp-ioctl( ))???
107
3. ??????????
?7.25 ???????
108
(1) IDE???????????? IDE???????????????????
ide-fops????? ?????? ? Struct file-operation
ide-fops? NULL? block?-read?
block?-write? NULL? NULL? ide0?-ioctl( )?
NULL? ide?-open( )? ide?-release( )?
block?-fsync? NULL? ide?-check?-media?-change?
revalidate?-disk?
109
(2) IDE???????????????IDE????????ide-init(
)?????,?????IDE????????PCI-IDE?????,????????????re
gister-blkdev( )?????????? ?
IDE???????????????ide-open( )?ide-elease( )????
110
(3) ??????????????????????????????????????
?????,???????????,?????????????????,??????????????
???????? ? ? ?????????? ? ? ??????? ?
??????? ? ?????, ????????
111
(4) ???????IDE????????request??????IDE???
??????request?????????? ? ??????rq-status ? ?
??????????rq-dev ? ? ???????????cmd ? ?
????????????sector ? ? ???????????current-nr-sect
ors ? ? ???????????buffer ? ? ?????????????bh,
bhtail ? ? ???sem ? ? ??????next?
Write a Comment
User Comments (0)
About PowerShow.com