本站支持尊重有效期内的版权/著作权,所有的资源均来自于互联网网友分享或网盘资源,一旦发现资源涉及侵权,将立即删除。希望所有用户一同监督并反馈问题,如有侵权请联系站长或发送邮件到ebook666@outlook.com,本站将立马改正
商品名称: UNIX系统编程-通信.并发与线程-(英文版) | 出版社: 电子工业出版社 | 出版时间:2017-04-01 |
作者:凯罗.宾斯 | 译者: | 开本: 32开 |
定价: 198.00 | 页数: | 印次: 1 |
ISBN号:9787121308536 | 商品类型:图书 | 版次: 1 |
本书是一本基于*新UNIX 标准的完备的参考书,对UNIX 编程的要点进行了清晰易懂的介绍,从一些用于说明如何使用系统调用的短小代码段开始,逐渐过渡到能帮助读者扩展自己技能水平的实际项目中。书中对通信、并发和线程问题进行了深入探讨,对复杂的概念,例如信号和并发,进行了全面且清晰的解释。本书还覆盖了与文件、信号、信号量、POSIX 线程和客户机—服务器通信相关的内容。书中不仅提供了大量实例和练习,还专门设计了有针对性的项目并给出了参考答案。
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 a