編輯推薦
適讀人群 :本書適閤作為高等院校計算機專業教材,也可供軟件開發人員參考使用。 √ 經典原味,UNIX必備寶典。
√ 基於*新UNIX標準的獨立參考書,專業、全麵、清晰。
√ 大量實例、練習、可重用的代碼和用於網絡通信應用程序的簡化庫。
√ 作者為麻省理工學院博士,現任德州大學聖安東尼奧分校計算機科學係講師。
內容簡介
本書是一本基於*新UNIX 標準的完備的參考書,對UNIX 編程的要點進行瞭清晰易懂的介紹,從一些用於說明如何使用係統調用的短小代碼段開始,逐漸過渡到能幫助讀者擴展自己技能水平的實際項目中。書中對通信、並發和綫程問題進行瞭深入探討,對復雜的概念,例如信號和並發,進行瞭全麵且清晰的解釋。本書還覆蓋瞭與文件、信號、信號量、POSIX 綫程和客戶機―服務器通信相關的內容。書中不僅提供瞭大量實例和練習,還專門設計瞭有針對性的項目並給齣瞭參考答案。
作者簡介
無(影印版無譯者……………………………………………………………………………………………………………………) Kay A. Robbins , Steve Robbins (凱羅?賓斯,史蒂夫?羅賓斯)擁有麻省理工學院博士學位,就任於德州大學聖安東尼奧分校計算機學院。
目錄
Contents
I Fundamentals 1
1 Technology’s Impact on Programs 3
1.1 TerminologyofChange . . . . . . . . . . . . . . . . . . . . . 4
1.2 Time andSpeed . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3 Multiprogramming and Time Sharing . . . . . . . . . . . . . . 7
1.4 Concurrency at the Applications Level . . . . . . . . . . . . . 9
1.5 Security and Fault Tolerance . . . . . . . . . . . . . . . . . . 13
1.6 Buffer Overflows for Breaking and Entering . . . . . . . . . . 14
1.7 UNIXStandards . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.8 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 20
2 Programs, Processes and Threads 21
2.1 How a Program Becomes a Process . . . . . . . . . . . . . . . 22
2.2 Threads andThreadofExecution . . . . . . . . . . . . . . . . 23
2.3 Layout of a Program Image . . . . . . . . . . . . . . . . . . . 24
2.4 LibraryFunctionCalls . . . . . . . . . . . . . . . . . . . . . 26
2.5 Function Return Values and Errors . . . . . . . . . . . . . . . 29
2.6 ArgumentArrays . . . . . . . . . . . . . . . . . . . . . . . . 31
2.7 Thread-SafeFunctions . . . . . . . . . . . . . . . . . . . . . 38
2.8 UseofStaticVariables . . . . . . . . . . . . . . . . . . . . . 40
2.9 StructureofStaticObjects . . . . . . . . . . . . . . . . . . . 42
2.10 Process Environment . . . . . . . . . . . . . . . . . . . . . . 48
2.11 Process Termination . . . . . . . . . . . . . . . . . . . . . . . 51
2.12 Exercise: An env Utility . . . . . . . . . . . . . . . . . . . 54
2.13 Exercise: Message Logging . . . . . . . . . . . . . . . . . . . 55
2.14 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 56
3 Processes in UNIX 59
3.1 Process Identification . . . . . . . . . . . . . . . . . . . . . . 60
3.2 ProcessState . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.3 UNIX Process Creation and fork . . . . . . . . . . . . . . . 64
3.4 The wait Function . . . . . . . . . . . . . . . . . . . . . . 71
3.5 The exec Function . . . . . . . . . . . . . . . . . . . . . . 78
3.6 Background Processes and Daemons . . . . . . . . . . . . . . 84
3.7 Critical Sections . . . . . . . . . . . . . . . . . . . . . . . . . 86
3.8 Exercise: Process Chains . . . . . . . . . . . . . . . . . . . . 87
3.9 Exercise: Process Fans . . . . . . . . . . . . . . . . . . . . . 88
3.10 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 89
4 UNIX I/O 91
4.1 DeviceTerminology . . . . . . . . . . . . . . . . . . . . . . . 92
4.2 Reading and Writing . . . . . . . . . . . . . . . . . . . . . . 92
4.3 OpeningandClosingFiles . . . . . . . . . . . . . . . . . . . 102
4.4 The select Function . . . . . . . . . . . . . . . . . . . . . 107
4.5 The pollFunction . . . . . . . . . . . . . . . . . . . . . . . 116
4.6 File Representation . . . . . . . . . . . . . . . . . . . . . . . 119
4.7 Filters and Redirection . . . . . . . . . . . . . . . . . . . . . 128
4.8 FileControl . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
4.9 Exercise: Atomic Logging . . . . . . . . . . . . . . . . . . . 135
4.10 Exercise: A cat Utility . . . . . . . . . . . . . . . . . . . . 141
4.11 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 143
5 Files and Directories 145
5.1 UNIXFileSystemNavigation . . . . . . . . . . . . . . . . . 146
5.2 Directory Access . . . . . . . . . . . . . . . . . . . . . . . . 152
5.3 UNIX File System Implementation . . . . . . . . . . . . . . . 158
5.4 Hard Links and Symbolic Links . . . . . . . . . . . . . . . . 162
5.5 Exercise: The which Command . . . . . . . . . . . . . . . 173
5.6 Exercise: Biffing . . . . . . . . . . . . . . . . . . . . . . . . 174
5.7 Exercise: News biff . . . . . . . . . . . . . . . . . . . . . 177
5.8 Exercise: Traversing Directories . . . . . . . . . . . . . . . . 179
5.9 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 181
6 UNIX Special Files 183
6.1 Pipes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
6.2 Pipelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
6.3 FIFOs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
6.4 Pipes and the Client-Server Model . . . . . . . . . . . . . . . 196
6.5 TerminalControl . . . . . . . . . . . . . . . . . . . . . . . . 203
6.6 AudioDevice . . . . . . . . . . . . . . . . . . . . . . . . . . 214
6.7 Exercise:Audio . . . . . . . . . . . . . . . . . . . . . . . . . 219
6.8 Exercise: Barriers . . . . . . . . . . . . . . . . . . . . . . . . 221
6.9 Exercise: The stty Command . . . . . . . . . . . . . . . . 223
6.10 Exercise: Client-Server Revisited . . . . . . . . . . . . . . . . 223
6.11 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 223
7 Project: The Token Ring 225
7.1 RingTopology . . . . . . . . . . . . . . . . . . . . . . . . . . 226
7.2 RingFormation . . . . . . . . . . . . . . . . . . . . . . . . . 227
7.3 RingExploration . . . . . . . . . . . . . . . . . . . . . . . . 234
7.4 SimpleCommunication . . . . . . . . . . . . . . . . . . . . . 236
7.5 MutualExclusionwithTokens . . . . . . . . . . . . . . . . . 237
7.6 MutualExclusionbyVoting . . . . . . . . . . . . . . . . . . . 238
7.7 Leader Election on an Anonymous Ring . . . . . . . . . . . . 239
7.8 TokenRingforCommunication . . . . . . . . . . . . . . . . . 241
7.9 Pipelined Preprocessor . . . . . . . . . . . . . . . . . . . . . 243
7.10 Parallel Ring Algorithms . . . . . . . . . . . . . . . . . . . . 246
7.11 FlexibleRing . . . . . . . . . . . . . . . . . . . . . . . . . . 250
7.12 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 251
II Asynchronous Events 253
8 Signals 255
8.1 BasicSignalConcepts . . . . . . . . . . . . . . . . . . . . . . 256
8.2 GeneratingSignals . . . . . . . . . . . . . . . . . . . . . . . 256
8.3 Manipulating Signal Masks and Signal Sets . . . . . . . . . . 261
8.4 Catching and Ignoring Signals―sigaction . . . . . . . . . 267
8.5 Waiting for Signals―pause, sigsuspend and sigwait 273
8.6 Handling Signals: Errors and Async-signal Safety . . . . . . . 283
8.7 Program Control with siglongjmp and sigsetjmp . . . 286
8.8 Programming with Asynchronous I/O . . . . . . . . . . . . . 288
8.9 Exercise:DumpingStatistics . . . . . . . . . . . . . . . . . . 299
8.10 Exercise: Spooling a Slow Device . . . . . . . . . . . . . . . 299
8.11 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 300
9 Times and Timers 301
9.1 POSIXTimes . . . . . . . . . . . . . . . . . . . . . . . . . . 302
9.2 SleepFunctions . . . . . . . . . . . . . . . . . . . . . . . . . 314
9.3 POSIX:XSI IntervalTimers . . . . . . . . . . . . . . . . . . . 315
9.4 Realtime Signals . . . . . . . . . . . . . . . . . . . . . . . . 320
9.5 POSIX:TMRIntervalTimers . . . . . . . . . . . . . . . . . . 324
9.6 Timer Drift, Overruns and Absolute Time . . . . . . . . . . . 329
9.7 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 339
10 Project: Virtual Timers 341
10.1 ProjectOverview . . . . . . . . . . . . . . . . . . . . . . . . 342
10.2 SimpleTimers . . . . . . . . . . . . . . . . . . . . . . . . . . 344
10.3 Setting One of Five Single Timers . . . . . . . . . . . . . . . 347
10.4 Using Multiple Timers . . . . . . . . . . . . . . . . . . . . . 357
10.5 A Robust Implementation of Multiple Timers . . . . . . . . . 363
10.6 POSIX:TMRTimer Implementation . . . . . . . . . . . . . . 367
10.7 mycron, a Small Cron Facility . . . . . . . . . . . . . . . . . 367
10.8 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 368
11 Project: Cracking Shells 369
11.1 BuildingaSimpleShell . . . . . . . . . . . . . . . . . . . . . 370
11.2 Redirection . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
11.3 Pipelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
11.4 Signal Handling in the Foreground . . . . . . . . . . . . . . . 380
11.5 Process Groups, Sessions and Controlling Terminals . . . . . . 386
11.6 Background Processes in ush . . . . . . . . . . . . . . . . . 391
11.7 JobControl . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
11.8 Job Control for ush . . . . . . . . . . . . . . . . . . . . . . 402
11.9 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 405
III Concurrency 407
12 POSIX Threads 409
12.1 A Motivating Problem: Monitoring File Descriptors . . . . . . 410
12.2 Use of Threads to Monitor Multiple File Descriptors . . . . . . 411
12.3 ThreadManagement . . . . . . . . . . . . . . . . . . . . . . 415
12.4 ThreadSafety . . . . . . . . . . . . . . . . . . . . . . . . . . 431
12.5 User Threads versus Kernel Threads . . . . . . . . . . . . . . 433
12.6 Thread Attributes . . . . . . . . . . . . . . . . . . . . . . . . 436
12.7 Exercise: ParallelFileCopy . . . . . . . . . . . . . . . . . . . 443
12.8 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 444
13 Thread Synchronization 447
13.1 POSIX Synchronization Functions . . . . . . . . . . . . . . . 448
13.2 MutexLocks . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
13.3 At-Most-Once and At-Least-Once-Execution . . . . . . . . . 461
13.4 Condition Variables . . . . . . . . . . . . . . . . . . . . . . . 465
13.5 Signal Handling and Threads . . . . . . . . . . . . . . . . . . 473
13.6 Readers and Writers . . . . . . . . . . . . . . . . . . . . . . . 478
13.7 A strerror_r Implementation . . . . . . . . . . . . . . . 483
13.8 Deadlocks and Other Pesky Problems . . . . . . . . . . . . . 483
13.9 Exercise: Multiple Barriers . . . . . . . . . . . . . . . . . . . 485
13.10 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 486
14 Critical Sections and Semaphores 487
14.1 Dealing with Critical Sections . . . . . . . . . . . . . . . . . 488
14.2 Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
14.3 POSIX:SEM Unnamed Semaphores . . . . . . . . . . . . . . 494
14.4 POSIX:SEM Semaphore Operations . . . . . . . . . . . . . . 496
14.5 POSIX:SEM Named Semaphores . . . . . . . . . . . . . . . . 502
14.6 Exercise: LicenseManager . . . . . . . . . . . . . . . . . . . 507
14.7 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 509
15 POSIX IPC 511
15.1 POSIX:XSI Interprocess Communication . . . . . . . . . . . 512
15.2 POSIX:XSI Semaphore Sets . . . . . . . . . . . . . . . . . . 514
15.3 POSIX:XSISharedMemory . . . . . . . . . . . . . . . . . . 525
15.4 POSIX:XSI Message Queues . . . . . . . . . . . . . . . . . . 535
15.5 Exercise: POSIX Unnamed Semaphores . . . . . . . . . . . . 542
15.6 Exercise: POSIX Named Semaphores . . . . . . . . . . . . . 543
15.7 Exercise: Implementing Pipes with Shared Memory . . . . . . 544
15.8 Exercise: Implementing Pipes with Message Queues . . . . . 547
15.9 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 548
16 Project: Producer Consumer Synchronization 549
16.1 The Producer-Consumer Problem . . . . . . . . . . . . . . . . 550
16.2 Bounded Buffer Protected by Mutex Locks . . . . . . . . . . . 551
16.3 Buffer Implementation with Semaphores . . . . . . . . . . . . 555
16.4 Introduction to a Simple Producer-Consumer Problem . . . . . 560
16.5 Bounded Buffer Implementation Using Condition Variables . . 564
16.6 Buffers with Done Conditions . . . . . . . . . . . . . . . . . 565
16.7 ParallelFileCopy . . . . . . . . . . . . . . . . . . . . . . . . 573
16.8 ThreadedPrintServer . . . . . . . . . . . . . . . . . . . . . . 575
16.9 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 580
17 Project: The Not Too Parallel Virtual Machine 581
17.1 PVM History, Terminology, and Architecture . . . . . . . . . 582
17.2 The Not Too Parallel Virtual Machine . . . . . . . . . . . . . 584
17.3 NTPVMProjectOverview . . . . . . . . . . . . . . . . . . . 585
17.4 I/OandTestingofDispatcher . . . . . . . . . . . . . . . . . . 591
17.5 Single Task with No Input . . . . . . . . . . . . . . . . . . . . 600
17.6 SequentialTasks . . . . . . . . . . . . . . . . . . . . . . . . . 601
17.7 ConcurrentTasks . . . . . . . . . . . . . . . . . . . . . . . . 604
17.8 Packet Communication, Broadcast and Barriers . . . . . . . . 605
17.9 TerminationandSignals . . . . . . . . . . . . . . . . . . . . . 605
17.10 Ordered Message Delivery . . . . . . . . . . . . . . . . . . . 606
17.11 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 606
IV Communication 607
18 Connection-Oriented Communication 609
18.1 TheClient-ServerModel . . . . . . . . . . . . . . . . . . . . 610
18.2 CommunicationChannels . . . . . . . . . . . . . . . . . . . . 610
18.3 Connection-Oriented Server Strategies . . . . . . . . . . . . . 614
18.4 Universal Internet Communication Interface (UICI) . . . . . . 618
18.5 UICI Implementations of Different Server Strategies . . . . . . 621
18.6 UICIClients . . . . . . . . . . . . . . . . . . . . . . . . . . . 624
18.7 Socket ImplementationofUICI . . . . . . . . . . . . . . . . . 629
18.8 Host Names and IP Addresses . . . . . . . . . . . . . . . . . 641
18.9 Thread-SafeUICI . . . . . . . . . . . . . . . . . . . . . . . . 649
18.10 Exercise: PingServer . . . . . . . . . . . . . . . . . . . . . . 652
18.11 Exercise: Transmission of Audio . . . . . . . . . . . . . . . . 653
18.12 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 655
19 Project: WWWRedirection 657
19.1 TheWorldWideWeb . . . . . . . . . . . . . . . . . . . . . . 658
19.2 Uniform Resource Locators (URLs) . . . . . . . . . . . . . . 658
19.3 HTTPPrimer . . . . . . . . . . . . . . . . . . . . . . . . . . 660
19.4 WebCommunicationPatterns . . . . . . . . . . . . . . . . . . 665
19.5 Pass-through Monitoring of Single Connections . . . . . . . . 672
19.6 Tunnel Server Implementation . . . . . . . . . . . . . . . . . 674
19.7 ServerDriver forTesting . . . . . . . . . . . . . . . . . . . . 675
19.8 HTTPHeaderParsing . . . . . . . . . . . . . . . . . . . . . . 676
19.9 SimpleProxyServer . . . . . . . . . . . . . . . . . . . . . . 679
19.10 ProxyMonitor . . . . . . . . . . . . . . . . . . . . . . . . . . 680
19.11 ProxyCache . . . . . . . . . . . . . . . . . . . . . . . . . . . 683
19.12 Gateways asPortals . . . . . . . . . . . . . . . . . . . . . . . 684
19.13 GatewayforLoadBalancing . . . . . . . . . . . . . . . . . . 685
19.14 Postmortem . . . . . . . . . . . . . . . . . . . . . . . . . . . 686
19.15 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 690
20 Connectionless Communication and Multicast 691
20.1 Introduction to Connectionless Communication . . . . . . . . 692
20.2 Simplified Interface for Connectionless Communication . . . . 693
20.3 Simple-RequestProtocols . . . . . . . . . . . . . . . . . . . . 697
20.4 Request-ReplyProtocols . . . . . . . . . . . . . . . . . . . . 702
20.5 Request-Reply with Timeouts and Retries . . . . . . . . . . . 708
20.6 Request-Reply-Acknowledge Protocols . . . . . . . . . . . . 714
20.7 ImplementationofUICIUDP . . . . . . . . . . . . . . . . . . 715
20.8 ComparisonofUDPandTCP . . . . . . . . . . . . . . . . . . 724
20.9 Multicast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725
20.10 Exercise:UDPPortServer . . . . . . . . . . . . . . . . . . . 729
20.11 Exercise: StatelessFileServer . . . . . . . . . . . . . . . . . 730
20.12 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 732
21 Project: Internet Radio 733
21.1 ProjectOverview . . . . . . . . . . . . . . . . . . . . . . . . 734
21.2 AudioDeviceSimulation . . . . . . . . . . . . . . . . . . . . 735
21.3 UDP Implementation with One Program and One Receiver . . 735
21.4 UDP Implementation with Multiple Programs and Receivers . 746
21.5 UDP Implementation of Radio Broadcasts . . . . . . . . . . . 747
21.6 Multicast Implementation of Radio Broadcasts . . . . . . . . . 750
21.7 TCPImplementationDifferences . . . . . . . . . . . . . . . . 750
21.8 Receiving Streaming Audio Through a Browser . . . . . . . . 755
21.9 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 759
22 Project: Server Performance 761
22.1 ServerPerformanceCosts . . . . . . . . . . . . . . . . . . . . 762
22.2 ServerArchitectures . . . . . . . . . . . . . . . . . . . . . . . 762
22.3 ProjectOverview . . . . . . . . . . . . . . . . . . . . . . . . 767
22.4 Single-ClientDriver . . . . . . . . . . . . . . . . . . . . . . . 767
22.5 Multiple-Client Driver . . . . . . . . . . . . . . . . . . . . . . 771
22.6 Thread-per-request and Process-per-request Implementations . 774
22.7 Thread-worker-pool Strategy . . . . . . . . . . . . . . . . . . 774
22.8 Thread-worker Pool with Bounded Buffer . . . . . . . . . . . 775
22.9 Process-worker Pool . . . . . . . . . . . . . . . . . . . . . . . 775
22.10 InfluenceofDiskI/O . . . . . . . . . . . . . . . . . . . . . . 776
22.11 PerformanceStudies . . . . . . . . . . . . . . . . . . . . . . 780
22.12 Report Writing . . . . . . . . . . . . . . . . . . . . . . . . . 790
22.13 AdditionalReading . . . . . . . . . . . . . . . . . . . . . . . 792
前言/序言
前言
本書是1995年由Prentice Hall齣版社齣版的Practical UNIX Programming: A Guide to Communication, Concurrency and Multithreading一書的第二版。為瞭更好地傳達本書的內容,我們將書名修改為UNIX Systems Programming: Communication, Concurrency and Threads。與上一版相比,第二版不僅改變瞭書名,還對很多內容進行瞭修改。
互聯網已經成為計算和社會領域的一個主導方麵。私人信息已經聯網,軟件經常會受到不停的攻擊。因此,編寫正確的代碼顯得尤為重要。在這一版中,我們嘗試盡量生成能夠正確處理錯誤和特殊情況的代碼。我們已經意識到,聲稱處理瞭所有的錯誤、但在給齣的代碼中卻省略錯誤處理是沒有效果的。不幸的是,錯誤處理會讓代碼變得更復雜,所以我們努力讓代碼變得更加清晰。
本書對第一版的另一個重要改進是采用瞭單一的UNIX規範,我們將其稱為POSIX。我們再也不需要決定使用哪個廠商的庫函數瞭——現在有正式的版本瞭。我們已經盡瞭最大努力來遵循這個標準。
練習和項目讓本書變得與眾不同。實際上,本書由美國國傢科學基金會(National Science Foundation Grant)項目手冊的一部分發展而來。在完成這個項目的初期開發後,我們逐漸認識到:完成這個項目所需要的資料分散在不同的地方——通常可以在提供瞭大量細節、但幾乎沒有概念陳述的參考書中找到。因此,本書逐漸成為一本基於最新UNIX標準的完整參考書。
本書分為4個部分,每個部分都包含主題章節和項目章節。主題章節以循序漸進的方式涵蓋瞭指定的內容,並以“試試看”和“看看會發生什麼”的形式包含瞭很多示例和小練習。最後都以一個或者多個練習小節結束。本書還為進程管理、並發和通信的基本概念提供瞭很多編程練習。這些編程練習與傳統科學課程中的實驗作用相同,隻有通過實踐纔能真正理解書中的概念。這些練習由易到難,很多練習隻需要不到100行代碼就能實現。
下錶對本書的結構進行瞭總結——21個章節被分為4個部分。其中的15個主題章節與8個項目章節相互獨立。第一次通讀本書時可以跳過項目章節。
部分 主題章節 項目章節
第一部分:基礎知識 第1章 技術對程序的影響
第2章 程序
第3章UNIX中的進程
第4章UNIX I/O
第5章 文件和目錄
第6章 UNIX特殊文件 第7章 令牌環
第二部分:異步事件 第8章 信號
第9章 時間和定時器 第10章 虛擬定時器
第11章 破解命令解釋程序
第三部分:並發 第12章POSIX綫程
第13章 進程同步
第14章 信號量
第15章 POSIX IPC 第16章 生産者消費者
第17章 虛擬機
第四部分:通信 第18章 麵嚮連接的通信
第20章 無連接通信 第19章 WWW重定嚮
第21章 互聯網廣播
第22章 服務器性能
項目章節通過開發一個規模較大的應用程序來整閤幾個主題章節的資料。這些項目包含兩個層麵:除瞭說明編程思想,還引導讀者理解與應用程序相關的高級主題。這些項目都是分階段設計的,大多數完整的實現都隻需要幾百行代碼。由於不需要編寫大量代碼,因此讀者可以將注意力集中在概念的理解,而不是代碼調試上。為瞭簡化編程,我們提供瞭可用於網絡通信和輸齣日誌記錄的庫。對專業的程序員來說,主題章節結尾部分的練習提供瞭對概念的基本介紹。通常,使用本書的教師可以從中挑選幾個練習和一個項目章節讓學生在一學期的課程中實現。每個項目都有多種變化,因此這些項目可以在多個學期反復使用。
讀者可以用不同的方式閱讀本書。第一部分的主題章節是閱讀本書其他部分的基礎。閱讀完第一部分的主題章節後,讀者可以以任何順序閱讀第二部分~第四部分的內容。但後繼章節結尾部分關於交互的討論除外(例如,綫程如何與信號交互)。
本書讀者應該是優秀的C程序員,但不一定是UNIX C的程序員。讀者應該熟悉C語言編程和基本的數據結構。對於剛剛接觸UNIX的讀者來說,附錄A中給齣瞭程序開發的必備知識。
本書包含標準函數的概要。概要右下角列齣瞭指定函數的相關標準。
本書的內容是有限的。歡迎讀者給我們提齣意見和建議,讀者可以給我們寫電子郵件authors@usp.cs.utsa.edu。雖然我們已經盡最大努力保證本書沒有錯誤。但如果你是第一個嚮我們指齣某個錯誤的人,我們會在本書的配套網站上對你錶示誠摯的感謝。http://usp.cs.utsa.edu/usp上提供瞭本書的相關信息,從這個Web站點可以下載本書中的所有代碼。
緻謝
非常感謝Mike Speciner和Bob Lynch通讀瞭本書的全部手稿,並提齣瞭很多有用的建議。我們尤其要對Mary Lou Nohr細心睿智的編輯工作錶示感謝。還要感謝Neal Wagner和Radia Perlman給予我們的鼓勵和建議。
從1988年至今(2003年),我們為本科生和研究生開設瞭操作係統課程,本書中的很多材料都曾經作為這些教學課程的一部分內容。學習這些課程的學生們經曆瞭書稿發展的不同階段,並對不斷齣現的項目進行瞭現場測試。他們在編程中的bug、注釋、抱怨和建議讓本書變得更好,並讓我們對如何將這些主題聯係起來有瞭深刻的認識。發現瞭早期書稿中錯誤的學生有Joseph Bell、Carlos Cadenas、Igor Grinshpan、Jason Jendrusch和James Manion。我們要感謝美國國傢科學基金會通過NSFILI授權的USE-0950497在我們組建實驗室時所提供的支持,這樣我們纔有機會開展最初的課程,而本書正是根據這些課程編寫的。NSF(DUE-975093、DUE-9752165和DUE-0088769)還為那些用於探討和分析操作係統概念的工具提供瞭支持。
我們還要感謝Prentice Hall齣版社的編輯Greg Doench,感謝他在整個過程中為我們提供指導。還要感謝齣版編輯William Mara讓本書得以齣版。感謝LATEX2ε的製作者為我們提供瞭可以免費使用的排版軟件。
我們還要感謝我們的傢人,感謝他們給予我們無限的愛和支持,尤其要感謝我們的孩子Nicole和Thomas對這個艱巨的工程所展現齣的熱情和理解。