6.  2 . - " " - , - . 6.1 UNIX . , . - , . - . , , - . 6.2 , - . 6.3 , - . 6.4 , , , - . 6.5 , - , - . , , 6.6 . 6.1  2, , . : 1. . 2. . 3. , . 4. . 5. , ( ) , . 9 . 6. - , . 7. ( ) - ( ), . 3 ( ) . 8. ; - , , . , . 9. exit . - , , , , . - 137 . 6.1 . - . , , , +-------+ | 1 | - | | , - ++------+ | ^ ^ - +-----+ +-------+ | | , | | | +-------+ +---+ | | | | | -| | | | | -| v v | - | +-------+ | +------++ - ++------+ | | +-->| | | | | 9 |<-----------+ 2 +------------>| 7 | | | | | -| | +-------+ ++------+ +-------+ | ^ - - | | - +---------------+ +------+ -------- | | - v | - -+-------+ +-+-----+ - | | | | - | 4 +----------------------->| 3 | -| | | | +---+---+ ++------+ - | | ^ ^ | | | | | | | | | | | +---+ | - - | | | | | | | | | |- ++------+ | | |-| | fork | | | | 8 |<----- | | | ++------+ | | | | - | | | +---+ | | | | | | | | ( | | | | ) v v | v +-------+ +---+---+ | | | | | 6 +----------------------->| 5 | +-------+ +-------+ , , 6.1. - 138 . - fork; - (3 5). , " " (3). - " ", , - fork. " ". - "- ". , , - "", - . "" " " ( , , ), , , , - , , . , - "". " ". , "- " " ". , - -. - " ", , -. - , , " ". , , - , ( ) , , " , ". , , . , " ". - " ". , exit, " " , , " ". . -, . , (.. " - , " " , - ") . . -- , , " " " ", . , ; - - " " (. 7.2, - ). , exit , , - exit. - 139 , - , , , . - : , , , . : - . , - , - , - . : , . : * , . * , . , " , " " " "" " ". , - ( " " ""). , - . * (UID), - . UID, , , (. ). * (PID), . PID "" fork. * ( , ). - sleep wakeup. * , " " "- ". * , , , ( 7.2). * , - . - , ( 8.3). , . - , : * , , - . * , , , (. 7.6). * , ( ) - . * , . * , " - ", . * , , . * , . 140 * -: , ( ) , ( -) .. * , , . * , , . * , - , . * , - , . - - . , , , . - ; - , "- ", " ", "" " ( )". "" " ", 8 - "- ". 9 - . 6.2  , , 0 , . 2, UNIX : , . ( , 11, ). - , ; ( - ), ( ) - ( , - ). , , - . , - , , - , . , - , - , . - , , , , - , , . , . , : , - , . - , , . 6.2.1  V - 141 . - , - . , , , . . , , , - . , - . - . 6.5 - , - , , - . - . , , , - ; , - . - . . , , - : , . : , , ; , , - , . 6.2 , A B, , - , - . 'a' 8 4 . A 8, ( ) +--------+ -+--------------+ | | | 8 +-----+ +-->| b | -+--------------+ | | | | A | 16 +-----|---+ +--------+ +--------+ +--------------+ | | | | 32 +-----|-------------------->| c | +--------------+ | +--------+ | | +------>| | +--------+ | a | -+--------------+ +------>| | | 4 +-----+ +--------+ +--------+ -+--------------+ | | B | 8 +-------------------------->| e | +--------------+ +--------+ | | | 32 +-----+ | | +--------+ +--------------+ +------>| d | | | +--------+ 6.2. 142 B 4, 'a'. . , . - , - . - 9 - . - : , , . , - ( 9), , , , - , , . 6.2.2  , , UNIX. , , , . 512 4 - . , , ( , ). , 2 32- , 1 , - 2 22- ; , 32- 22- 10- ( 6.3). , - . - +------------------------------------------------------------+ | 58432 | | | | 0101 1000 0100 0011 0010 | | | | , | | 01 0110 0001 00 0011 0010 | | | | 161 32 | +------------------------------------------------------------+ 6.3. +------------------------------------------------------+ | | | | | 0 177 | | 1 54 | | 2 209 | | 3 17 | +------------------------------------------------------+ 6.4. 143 , . , , - ( - ) . - , 6.4. - , - . , . - , - . - , . 6.5 . 1 - , 68432. , - 65536 (64), , . 68432 - , 2896. 1 , - 848 2- ( 0) , 986. 6.5.5 ( - ) , "- ". , - . , , ( ) +--------------+ | 8 +--------------+ +--------------+ +-------->+--------------+ | 32 +-------+ | | +--------------+ | +--------------+ | 64 +---+ | | 137 | +--------------+ | v +--------------+ | +--------------+ | 852 | | | 87 | +--------------+ +------------+ +--------------+ | 764 | v | 552 | +--------------+ +--------------+ +--------------+ | 433 | | 541 | | 727 | +--------------+ +--------------+ +--------------+ | 333 | | 783 | | 941 | +--------------+ +--------------+ +--------------+ | - | | 986 | | 1096 | | - | +--------------+ +--------------+ | - | | 897 | | 2001 | | - | +--------------+ +--------------+ +--------------+ | - | | - | +--------------+ +--------------+ 6.5. 144 . - -, . , , . . 1 , . - ; - , , , , ( , ). . - , - . , , - . , 16 ( 6.5), 26, - , . , , , , . , ( ). 6.2.3  , , - , , - . . - - . - , , , , - . - , , - . - , . - , - , - , . - , . 6.6 , 0 4-1 , 4 - . - , , , - . - - ; , - , - 145 . , - - . , , , . - - - +-----------+------------+-----------+ 1 | --------+ 0 | | +-----------+-|----------+-----------+ 2 | ---+ | | 1 | | +--------|--+-|----------+-----------+ 3 | --+| | | 2 | | +-------||--+-|----------+-----------+ 1 | +--- || | | 4 | | +-|-----||--+-|----------+-----------+ 2 | |+-- || | | | | +-||----||--+-|----------+-----------+ 3 | ||+- || | | | | +-|||---||--+-|----------+-----------+ +------------------------+|| || | | +--------------+| |+----|-------+ | | +----+ +-----|-------|----------+ | | | +--+ | | v v v v v v +------+ +------+ +------+ +------+ +------+ +------+ | 856K | | 747K | | 556K | | 0K | | 128K | | 256K | +------+ +------+ +------+ +------+ +------+ +------+ | 917K | | 950K | | 997K | | 4K | | 97K | | 292K | +------+ +------+ +------+ +------+ +------+ +------+ | 564K | | 333K | | 458K | | 3K | | 135K | | 304K | +------+ +------+ +------+ +------+ +------+ +------+ | 444K | | - | | 632K | | 17K | | 139K | | 279K | +------+ | - | +------+ +------+ +------+ +------+ | - | | - | | - | | - | | - | | - | | - | | - | | - | | - | | - | | - | +------+ +------+ +------+ +------+ +------+ +------+ () 6.6. ( ) ( ) 6.2.4  , - , . , . 'u' ( ) . , , ( 6.4.3). , 146 , , - . , - . , , , . - , , - , . , - . - - - +-----------+------------+-----------+ 1 | | | | +-----------+------------+-----------+ 2 | | | | +-----------+------------+-----------+ (- 3 | ---+ | 2M | 4 | +--------|--+------------+-----------+ ) | +---------------------+ | | v +------+ +------+ +------+ +------+ | 114K | | 843K | |1879K | | 184K | +------+ +------+ +------+ +------+ | 708K | | 794K | | 290K | | 176K | +------+ +------+ +------+ +------+ | 143K | | 361K | | 450K | | 209K | +------+ +------+ +------+ +------+ | 565K | | 847K | | 770K | | 477K | +------+ +------+ +------+ +------+ A B C D 6.7. , , 4 2. 6.7 , (- ), - D. A, . , , . 1 2 , - . 6.3  - , , - 147 . , , (*