Passing Arguments to thread function

void f(vector<double>& v);
// function do something with v
struct F {
// function object: do something with v
vector<double>& v;
F(vector<double>& vv) :v{vv} { }
void operator()();
// application operator ; §3.4.3
};
int main()
{
vector<double> some_vec {1,2,3,4,5,6,7,8,9};
vector<double> vec2 {10,11,12,13,14};
thread t1 {f,some_vec}; // f(some_vec) executes in a separate thread
thread t2 {F{vec2}};// F(vec2)() executes in a separate thread
t1.join();
t2.join();
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Contents Foreword to the Second Edition xix Preface xxi Preface to the Second Edition xxv Preface to the First Edition xxix Chapter 1. UNIX System Overview 1 1.1 Introduction 1 1.2 UNIX Architecture 1 1.3 Logging In 2 1.4 Files and Directories 4 1.5 Input and Output 8 1.6 Programs and Processes 10 1.7 Error Handling 14 1.8 User Identification 16 1.9 Signals 18 1.10 Time Values 20 1.11 System Calls and Librar y Functions 21 1.12 Summary 23 Chapter 2. UNIX Standardization and Implementations 25 2.1 Introduction 25 ix www.it-ebooks.info x Contents 2.2 UNIX Standardization 25 2.2.1 ISO C 25 2.2.2 IEEE POSIX 26 2.2.3 The Single UNIX Specification 30 2.2.4 FIPS 32 2.3 UNIX System Implementations 33 2.3.1 UNIX System V Release 4 33 2.3.2 4.4BSD 34 2.3.3 FreeBSD 34 2.3.4 Linux 35 2.3.5 Mac OS X 35 2.3.6 Solaris 35 2.3.7 Other UNIX Systems 35 2.4 Relationship of Standards and Implementations 36 2.5 Limits 36 2.5.1 ISO C Limits 37 2.5.2 POSIX Limits 38 2.5.3 XSI Limits 41 2.5.4 sysconf, pathconf, and fpathconf Functions 42 2.5.5 Indeterminate Runtime Limits 49 2.6 Options 53 2.7 Feature Test Macros 57 2.8 Primitive System Data Types 58 2.9 Differences Between Standards 58 2.10 Summary 60 Chapter 3. File I/O 61 3.1 Introduction 61 3.2 File Descr iptors 61 3.3 open and openat Functions 62 3.4 creat Function 66 3.5 close Function 66 3.6 lseek Function 66 3.7 read Function 71 3.8 write Function 72 3.9 I/O Efficiency 72 3.10 File Shar ing 74 3.11 Atomic Operations 77 3.12 dup and dup2 Functions 79 3.13 sync, fsync, and fdatasync Functions 81 3.14 fcntl Function 82 www.it-ebooks.info Contents xi 3.15 ioctl Function 87 3.16 /dev/fd 88 3.17 Summary 90 Chapter 4. Files and Directories 93 4.1 Introduction 93 4.2 stat, fstat, fstatat, and lstat Functions 93 4.3 File Types 95 4.4 Set-User-ID and Set-Group-ID 98 4.5 File Access Per missions 99 4.6 Ownership of New Files and Directories 101 4.7 access and faccessat Functions 102 4.8 umask Function 104 4.9 chmod, fchmod, and fchmodat Functions 106 4.10 Sticky Bit 108 4.11 chown, fchown, fchownat, and lchown Functions 109 4.12 File Size 111 4.13 File Tr uncation 112 4.14 File Systems 113 4.15 link, linkat, unlink, unlinkat, and remove Functions 116 4.16 rename and renameat Functions 119 4.17 Symbolic Links 120 4.18 Creating and Reading Symbolic Links 123 4.19 File Times 124 4.20 futimens, utimensat, and utimes Functions 126 4.21 mkdir, mkdirat, and rmdir Functions 129 4.22 Reading Director ies 130 4.23 chdir, fchdir, and getcwd Functions 135 4.24 Device Special Files 137 4.25 Summary of File Access Per mission Bits 140 4.26 Summary 140 Chapter 5. Standard I/O Library 143 5.1 Introduction 143 5.2 Streams and FILE Objects 143 5.3 Standard Input, Standard Output, and Standard Error 145 5.4 Buffer ing 145 5.5 Opening a Stream 148 www.it-ebooks.info xii Contents 5.6 Reading and Writing a Stream 150 5.7 Line-at-a-Time I/O 152 5.8 Standard I/O Efficiency 153 5.9 Binary I/O 156 5.10 Positioning a Stream 157 5.11 For matted I/O 159 5.12 Implementation Details 164 5.13 Temporar y Files 167 5.14 Memory Streams 171 5.15 Alternatives to Standard I/O 174 5.16 Summary 175 Chapter 6. System Data Files and Information 177 6.1 Introduction 177 6.2 Password File 177 6.3 Shadow Passwords 181 6.4 Group File 182 6.5 Supplementary Group IDs 183 6.6 Implementation Differences 184 6.7 Other Data Files 185 6.8 Login Accounting 186 6.9 System Identification 187 6.10 Time and Date Routines 189 6.11 Summary 196 Chapter 7. Process Environment 197 7.1 Introduction 197 7.2 main Function 197 7.3 Process Termination 198 7.4 Command-Line Arguments 203 7.5 Environment List 203 7.6 Memory Lay out of a C Program 204 7.7 Shared Librar ies 206 7.8 Memory Allocation 207 7.9 Environment Var iables 210 7.10 setjmp and longjmp Functions 213 7.11 getrlimit and setrlimit Functions 220 7.12 Summary 225 Chapter 8. Process Control 227 8.1 Introduction 227 www.it-ebooks.info Contents xiii 8.2 Process Identifiers 227 8.3 fork Function 229 8.4 vfork Function 234 8.5 exit Functions 236 8.6 wait and waitpid Functions 238 8.7 waitid Function 244 8.8 wait3 and wait4 Functions 245 8.9 Race Conditions 245 8.10 exec Functions 249 8.11 Changing User IDs and Group IDs 255 8.12 Interpreter Files 260 8.13 system Function 264 8.14 Process Accounting 269 8.15 User Identification 275 8.16 Process Scheduling 276 8.17 Process Times 280 8.18 Summary 282 Chapter 9. Process Relationships 285 9.1 Introduction 285 9.2 Ter minal Logins 285 9.3 Networ k Logins 290 9.4 Process Groups 293 9.5 Sessions 295 9.6 Controlling Terminal 296 9.7 tcgetpgrp, tcsetpgrp, and tcgetsid Functions 298 9.8 Job Control 299 9.9 Shell Execution of Programs 303 9.10 Orphaned Process Groups 307 9.11 FreeBSD Implementation 310 9.12 Summary 312 Chapter 10. Signals 313 10.1 Introduction 313 10.2 Signal Concepts 313 10.3 signal Function 323 10.4 Unreliable Signals 326 10.5 Interrupted System Calls 327 10.6 Reentrant Functions 330 10.7 SIGCLD Semantics 332 www.it-ebooks.info xiv Contents 10.8 Reliable-Signal Ter minology and Semantics 335 10.9 kill and raise Functions 336 10.10 alarm and pause Functions 338 10.11 Signal Sets 344 10.12 sigprocmask Function 346 10.13 sigpending Function 347 10.14 sigaction Function 349 10.15 sigsetjmp and siglongjmp Functions 355 10.16 sigsuspend Function 359 10.17 abort Function 365 10.18 system Function 367 10.19 sleep, nanosleep, and clock_nanosleep Functions 373 10.20 sigqueue Function 376 10.21 Job-Control Signals 377 10.22 Signal Names and Numbers 379 10.23 Summary 381 Chapter 11. Threads 383 11.1 Introduction 383 11.2 Thread Concepts 383 11.3 Thread Identification 384 11.4 Thread Creation 385 11.5 Thread Termination 388 11.6 Thread Synchronization 397 11.6.1 Mutexes 399 11.6.2 Deadlock Avoidance 402 11.6.3 pthread_mutex_timedlock Function 407 11.6.4 Reader–Writer Locks 409 11.6.5 Reader–Writer Locking with Timeouts 413 11.6.6 Condition Variables 413 11.6.7 Spin Locks 417 11.6.8 Barriers 418 11.7 Summary 422 Chapter 12. Thread Control 425 12.1 Introduction 425 12.2 Thread Limits 425 12.3 Thread Attr ibutes 426 12.4 Synchronization Attr ibutes 430 12.4.1 Mutex Attr ibutes 430 www.it-ebooks.info Contents xv 12.4.2 Reader–Writer Lock Attr ibutes 439 12.4.3 Condition Variable Attributes 440 12.4.4 Barrier Attributes 441 12.5 Reentrancy 442 12.6 Thread-Specific Data 446 12.7 Cancel Options 451 12.8 Threads and Signals 453 12.9 Threads and fork 457 12.10 Threads and I/O 461 12.11 Summary 462 Chapter 13. Daemon Processes 463 13.1 Introduction 463 13.2 Daemon Character istics 463 13.3 Coding Rules 466 13.4 Error Logging 469 13.5 Single-Instance Daemons 473 13.6 Daemon Conventions 474 13.7 Client–Server Model 479 13.8 Summary 480 Chapter 14. Advanced I/O 481 14.1 Introduction 481 14.2 Nonblocking I/O 481 14.3 Record Locking 485 14.4 I/O Multiplexing 500 14.4.1 select and pselect Functions 502 14.4.2 poll Function 506 14.5 Asynchronous I/O 509 14.5.1 System V Asynchronous I/O 510 14.5.2 BSD Asynchronous I/O 510 14.5.3 POSIX Asynchronous I/O 511 14.6 readv and writev Functions 521 14.7 readn and writen Functions 523 14.8 Memory-Mapped I/O 525 14.9 Summary 531 Chapter 15. Interprocess Communication 533 15.1 Introduction 533 15.2 Pipes 534 15.3 popen and pclose Functions 541 www.it-ebooks.info xvi Contents 15.4 Coprocesses 548 15.5 FIFOs 552 15.6 XSI IPC 556 15.6.1 Identifiers and Keys 556 15.6.2 Per mission Str ucture 558 15.6.3 Configuration Limits 559 15.6.4 Advantages and Disadvantages 559 15.7 Message Queues 561 15.8 Semaphores 565 15.9 Shared Memor y 571 15.10 POSIX Semaphores 579 15.11 Client–Server Proper ties 585 15.12 Summary 587 Chapter 16. Network IPC: Sockets 589 16.1 Introduction 589 16.2 Socket Descr iptors 590 16.3 Addressing 593 16.3.1 Byte Order ing 593 16.3.2 Address Formats 595 16.3.3 Address Lookup 597 16.3.4 Associating Addresses with Sockets 604 16.4 Connection Establishment 605 16.5 Data Tr ansfer 610 16.6 Socket Options 623 16.7 Out-of-Band Data 626 16.8 Nonblocking and Asynchronous I/O 627 16.9 Summary 628 Chapter 17. Advanced IPC 629 17.1 Introduction 629 17.2 UNIX Domain Sockets 629 17.2.1 Naming UNIX Domain Sockets 634 17.3 Unique Connections 635 17.4 Passing File Descriptors 642 17.5 An Open Server, Version 1 653 17.6 An Open Server, Version 2 659 17.7 Summary 669 Chapter 18. Terminal I/O 671 18.1 Introduction 671 www.it-ebooks.info Contents xvii 18.2 Over view 671 18.3 Special Input Characters 678 18.4 Getting and Setting Ter minal Attr ibutes 683 18.5 Ter minal Option Flags 683 18.6 stty Command 691 18.7 Baud Rate Functions 692 18.8 Line Control Functions 693 18.9 Ter minal Identification 694 18.10 Canonical Mode 700 18.11 Noncanonical Mode 703 18.12 Ter minal Window Size 710 18.13 termcap, terminfo, and curses 712 18.14 Summary 713 Chapter 19. Pseudo Terminals 715 19.1 Introduction 715 19.2 Over view 715 19.3 Opening Pseudo-Ter minal Devices 722 19.4 pty_fork Function 726 19.5 pty Program 729 19.6 Using the pty Program 733 19.7 Advanced Features 740 19.8 Summary 741 Chapter 20. A Database Library 743 20.1 Introduction 743 20.2 History 743 20.3 The Librar y 744 20.4 Implementation Over view 746 20.5 Centralized or Decentralized? 750 20.6 Concurrency 752 20.7 Building the Librar y 753 20.8 Source Code 753 20.9 Perfor mance 781 20.10 Summary 786 Chapter 21. Communicating with a Network Printer 789 21.1 Introduction 789 21.2 The Inter net Pr inting Protocol 789 21.3 The Hyper text Transfer Protocol 792 21.4 Printer Spooling 793 www.it-ebooks.info xviii Contents 21.5 Source Code 795 21.6 Summary 843 Appendix A. Function Prototypes 845 Appendix B. Miscellaneous Source Code 895 B.1 Our Header File 895 B.2 Standard Error Routines 898 Appendix C. Solutions to Selected Exercises 905 Bibliography 947 Index 955
Unix网络编程卷1,第三版,英文版。大名顶顶的Richard Stevens所写 目录: Copyright Addison-Wesley Professional Computing Series Foreword Preface Introduction Changes from the Second Edition Using This Book Source Code and Errata Availability Acknowledgments Part 1: Introduction and TCP/IP Chapter 1. Introduction Section 1.1. Introduction Section 1.2. A Simple Daytime Client Section 1.3. Protocol Independence Section 1.4. Error Handling: Wrapper Functions Section 1.5. A Simple Daytime Server Section 1.6. Roadmap to Client/Server Examples in the Text Section 1.7. OSI Model Section 1.8. BSD Networking History Section 1.9. Test Networks and Hosts Section 1.10. Unix Standards Section 1.11. 64-Bit Architectures Section 1.12. Summary Exercises Chapter 2. The Transport Layer: TCP, UDP, and SCTP Section 2.1. Introduction Section 2.2. The Big Picture Section 2.3. User Datagram Protocol (UDP) Section 2.4. Transmission Control Protocol (TCP) Section 2.5. Stream Control Transmission Protocol (SCTP) Section 2.6. TCP Connection Establishment and Termination Section 2.7. TIME_WAIT State Section 2.8. SCTP Association Establishment and Termination Section 2.9. Port Numbers Section 2.10. TCP Port Numbers and Concurrent Servers Section 2.11. Buffer Sizes and Limitations Section 2.12. Standard Internet Services Section 2.13. Protocol Usage by Common Internet Applications Section 2.14. Summary Exercises Part 2: Elementary Sockets Chapter 3. Sockets Introduction Section 3.1. Introduction Section 3.2. Socket Address Structures Section 3.3. Value-Result Arguments Section 3.4. Byte Ordering Functions Section 3.5. Byte Manipulation Functions Section 3.6. inet_aton, inet_addr, and inet_ntoa Functions Section 3.7. inet_pton and inet_ntop Functions Section 3.8. sock_ntop and Related Functions Section 3.9. readn, writen, and readline Functions Section 3.10. Summary Exercises Chapter 4. Elementary TCP Sockets Section 4.1. Introduction Section 4.2. socket Function Section 4.3. connect Function Section 4.4. bind Function Section 4.5. listen Function Section 4.6. accept Function Section 4.7. fork and exec Functions Section 4.8. Concurrent Servers Section 4.9. close Function Section 4.10. getsockname and getpeername Functions Section 4.11. Summary Exercises Chapter 5. TCP Client/Server Example Section 5.1. Introduction Section 5.2. TCP Echo Server: main Function Section 5.3. TCP Echo Server: str_echo Function Section 5.4. TCP Echo Client: main Function Section 5.5. TCP Echo Client: str_cli Function Section 5.6. Normal Startup Section 5.7. Normal Termination Section 5.8. POSIX Signal Handling Section 5.9. Handling SIGCHLD Signals Section 5.10. wait and waitpid Functions Section 5.11. Connection Abort before accept Returns Section 5.12. Termination of Server Process Section 5.13. SIGPIPE Signal Section 5.14. Crashing of Server Host Section 5.15. Crashing and Rebooting of Server Host Section 5.16. Shutdown of Server Host Section 5.17. Summary of TCP Example Section 5.18. Data Format Section 5.19. Summary Exercises Chapter 6. I/O Multiplexing: The select and poll Functions Section 6.1. Introduction Section 6.2. I/O Models Section 6.3. select Function Section 6.4. str_cli Function (Revisited) Section 6.5. Batch Input and Buffering Section 6.6. shutdown Function Section 6.7. str_cli Function (Revisited Again) Section 6.8. TCP Echo Server (Revisited) Section 6.9. pselect Function Section 6.10. poll Function Section 6.11. TCP Echo Server (Revisited Again) Section 6.12. Summary Exercises Chapter 7. Socket Options Section 7.1. Introduction Section 7.2. getsockopt and setsockopt Functions Section 7.3. Checking if an Option Is Supported and Obtaining the Default Section 7.4. Socket States Section 7.5. Generic Socket Options Section 7.6. IPv4 Socket Options Section 7.7. ICMPv6 Socket Option Section 7.8. IPv6 Socket Options Section 7.9. TCP Socket Options Section 7.10. SCTP Socket Options Section 7.11. fcntl Function Section 7.12. Summary Exercises Chapter 8. Elementary UDP Sockets Section 8.1. Introduction Section 8.2. recvfrom and sendto Functions Section 8.3. UDP Echo Server: main Function Section 8.4. UDP Echo Server: dg_echo Function Section 8.5. UDP Echo Client: main Function Section 8.6. UDP Echo Client: dg_cli Function Section 8.7. Lost Datagrams Section 8.8. Verifying Received Response Section 8.9. Server Not Running Section 8.10. Summary of UDP Example Section 8.11. connect Function with UDP Section 8.12. dg_cli Function (Revisited) Section 8.13. Lack of Flow Control with UDP Section 8.14. Determining Outgoing Interface with UDP Section 8.15. TCP and UDP Echo Server Using select Section 8.16. Summary Exercises Chapter 9. Elementary SCTP Sockets Section 9.1. Introduction Section 9.2. Interface Models Section 9.3. sctp_bindx Function Section 9.4. sctp_connectx Function Section 9.5. sctp_getpaddrs Function Section 9.6. sctp_freepaddrs Function Section 9.7. sctp_getladdrs Function Section 9.8. sctp_freeladdrs Function Section 9.9. sctp_sendmsg Function Section 9.10. sctp_recvmsg Function Section 9.11. sctp_opt_info Function Section 9.12. sctp_peeloff Function Section 9.13. shutdown Function Section 9.14. Notifications Section 9.15. Summary Exercises Chapter 10. SCTP Client/Server Example Section 10.1. Introduction Section 10.2. SCTP One-to-Many-Style Streaming Echo Server: main Function Section 10.3. SCTP One-to-Many-Style Streaming Echo Client: main Function Section 10.4. SCTP Streaming Echo Client: str_cli Function Section 10.5. Exploring Head-of-Line Blocking Section 10.6. Controlling the Number of Streams Section 10.7. Controlling Termination Section 10.8. Summary Exercises Chapter 11. Name and Address Conversions Section 11.1. Introduction Section 11.2. Domain Name System (DNS) Section 11.3. gethostbyname Function Section 11.4. gethostbyaddr Function Section 11.5. getservbyname and getservbyport Functions Section 11.6. getaddrinfo Function Section 11.7. gai_strerror Function Section 11.8. freeaddrinfo Function Section 11.9. getaddrinfo Function: IPv6 Section 11.10. getaddrinfo Function: Examples Section 11.11. host_serv Function Section 11.12. tcp_connect Function Section 11.13. tcp_listen Function Section 11.14. udp_client Function Section 11.15. udp_connect Function Section 11.16. udp_server Function Section 11.17. getnameinfo Function Section 11.18. Re-entrant Functions Section 11.19. gethostbyname_r and gethostbyaddr_r Functions Section 11.20. Obsolete IPv6 Address Lookup Functions Section 11.21. Other Networking Information Section 11.22. Summary Exercises Part 3: Advanced Sockets Chapter 12. IPv4 and IPv6 Interoperability Section 12.1. Introduction Section 12.2. IPv4 Client, IPv6 Server Section 12.3. IPv6 Client, IPv4 Server Section 12.4. IPv6 Address-Testing Macros Section 12.5. Source Code Portability Section 12.6. Summary Exercises Chapter 13. Daemon Processes and the inetd Superserver Section 13.1. Introduction Section 13.2. syslogd Daemon Section 13.3. syslog Function Section 13.4. daemon_init Function Section 13.5. inetd Daemon Section 13.6. daemon_inetd Function Section 13.7. Summary Exercises Chapter 14. Advanced I/O Functions Section 14.1. Introduction Section 14.2. Socket Timeouts Section 14.3. recv and send Functions Section 14.4. readv and writev Functions Section 14.5. recvmsg and sendmsg Functions Section 14.6. Ancillary Data Section 14.7. How Much Data Is Queued? Section 14.8. Sockets and Standard I/O Section 14.9. Advanced Polling Section 14.10. Summary Exercises Chapter 15. Unix Domain Protocols Section 15.1. Introduction Section 15.2. Unix Domain Socket Address Structure Section 15.3. socketpair Function Section 15.4. Socket Functions Section 15.5. Unix Domain Stream Client/Server Section 15.6. Unix Domain Datagram Client/Server Section 15.7. Passing Descriptors Section 15.8. Receiving Sender Credentials Section 15.9. Summary Exercises Chapter 16. Nonblocking I/O Section 16.1. Introduction Section 16.2. Nonblocking Reads and Writes: str_cli Function (Revisited) Section 16.3. Nonblocking connect Section 16.4. Nonblocking connect: Daytime Client Section 16.5. Nonblocking connect: Web Client Section 16.6. Nonblocking accept Section 16.7. Summary Exercises Chapter 17. ioctl Operations Section 17.1. Introduction Section 17.2. ioctl Function Section 17.3. Socket Operations Section 17.4. File Operations Section 17.5. Interface Configuration Section 17.6. get_ifi_info Function Section 17.7. Interface Operations Section 17.8. ARP Cache Operations Section 17.9. Routing Table Operations Section 17.10. Summary Exercises Chapter 18. Routing Sockets Section 18.1. Introduction Section 18.2. Datalink Socket Address Structure Section 18.3. Reading and Writing Section 18.4. sysctl Operations Section 18.5. get_ifi_info Function (Revisited) Section 18.6. Interface Name and Index Functions Section 18.7. Summary Exercises Chapter 19. Key Management Sockets Section 19.1. Introduction Section 19.2. Reading and Writing Section 19.3. Dumping the Security Association Database (SADB) Section 19.4. Creating a Static Security Association (SA) Section 19.5. Dynamically Maintaining SAs Section 19.6. Summary Exercises Chapter 20. Broadcasting Section 20.1. Introduction Section 20.2. Broadcast Addresses Section 20.3. Unicast versus Broadcast Section 20.4. dg_cli Function Using Broadcasting Section 20.5. Race Conditions Section 20.6. Summary Exercises Chapter 21. Multicasting Section 21.1. Introduction Section 21.2. Multicast Addresses Section 21.3. Multicasting versus Broadcasting on a LAN Section 21.4. Multicasting on a WAN Section 21.5. Source-Specific Multicast Section 21.6. Multicast Socket Options Section 21.7. mcast_join and Related Functions Section 21.8. dg_cli Function Using Multicasting Section 21.9. Receiving IP Multicast Infrastructure Session Announcements Section 21.10. Sending and Receiving Section 21.11. Simple Network Time Protocol (SNTP) Section 21.12. Summary Exercises Chapter 22. Advanced UDP Sockets Section 22.1. Introduction Section 22.2. Receiving Flags, Destination IP Address, and Interface Index Section 22.3. Datagram Truncation Section 22.4. When to Use UDP Instead of TCP Section 22.5. Adding Reliability to a UDP Application Section 22.6. Binding Interface Addresses Section 22.7. Concurrent UDP Servers Section 22.8. IPv6 Packet Information Section 22.9. IPv6 Path MTU Control Section 22.10. Summary Exercises Chapter 23. Advanced SCTP Sockets Section 23.1. Introduction Section 23.2. An Autoclosing One-to-Many-Style Server Section 23.3. Partial Delivery Section 23.4. Notifications Section 23.5. Unordered Data Section 23.6. Binding a Subset of Addresses Section 23.7. Determining Peer and Local Address Information Section 23.8. Finding an Association ID Given an IP Address Section 23.9. Heartbeating and Address Failure Section 23.10. Peeling Off an Association Section 23.11. Controlling Timing Section 23.12. When to Use SCTP Instead of TCP Section 23.13. Summary Exercises Chapter 24. Out-of-Band Data Section 24.1. Introduction Section 24.2. TCP Out-of-Band Data Section 24.3. sockatmark Function Section 24.4. TCP Out-of-Band Data Recap Section 24.5. Summary Exercises Chapter 25. Signal-Driven I/O Section 25.1. Introduction Section 25.2. Signal-Driven I/O for Sockets Section 25.3. UDP Echo Server Using SIGIO Section 25.4. Summary Exercises Chapter 26. Threads Section 26.1. Introduction Section 26.2. Basic Thread Functions: Creation and Termination Section 26.3. str_cli Function Using Threads Section 26.4. TCP Echo Server Using Threads Section 26.5. Thread-Specific Data Section 26.6. Web Client and Simultaneous Connections (Continued) Section 26.7. Mutexes: Mutual Exclusion Section 26.8. Condition Variables Section 26.9. Web Client and Simultaneous Connections (Continued) Section 26.10. Summary Exercises Chapter 27. IP Options Section 27.1. Introduction Section 27.2. IPv4 Options Section 27.3. IPv4 Source Route Options Section 27.4. IPv6 Extension Headers Section 27.5. IPv6 Hop-by-Hop Options and Destination Options Section 27.6. IPv6 Routing Header Section 27.7. IPv6 Sticky Options Section 27.8. Historical IPv6 Advanced API Section 27.9. Summary Exercises Chapter 28. Raw Sockets Section 28.1. Introduction Section 28.2. Raw Socket Creation Section 28.3. Raw Socket Output Section 28.4. Raw Socket Input Section 28.5. ping Program Section 28.6. traceroute Program Section 28.7. An ICMP Message Daemon Section 28.8. Summary Exercises Chapter 29. Datalink Access Section 29.1. Introduction Section 29.2. BSD Packet Filter (BPF) Section 29.3. Datalink Provider Interface (DLPI) Section 29.4. Linux: SOCK_PACKET and PF_PACKET Section 29.5. libpcap: Packet Capture Library Section 29.6. libnet: Packet Creation and Injection Library Section 29.7. Examining the UDP Checksum Field Section 29.8. Summary Exercises Chapter 30. Client/Server Design Alternatives Section 30.1. Introduction Section 30.2. TCP Client Alternatives Section 30.3. TCP Test Client Section 30.4. TCP Iterative Server Section 30.5. TCP Concurrent Server, One Child per Client Section 30.6. TCP Preforked Server, No Locking Around accept Section 30.7. TCP Preforked Server, File Locking Around accept Section 30.8. TCP Preforked Server, Thread Locking Around accept Section 30.9. TCP Preforked Server, Descriptor Passing Section 30.10. TCP Concurrent Server, One Thread per Client Section 30.11. TCP Prethreaded Server, per-Thread accept Section 30.12. TCP Prethreaded Server, Main Thread accept Section 30.13. Summary Exercises Chapter 31. Streams Section 31.1. Introduction Section 31.2. Overview Section 31.3. getmsg and putmsg Functions Section 31.4. getpmsg and putpmsg Functions Section 31.5. ioctl Function Section 31.6. Transport Provider Interface (TPI) Section 31.7. Summary Exercises Appendix A. IPv4, IPv6, ICMPv4, and ICMPv6 Section A.1. Introduction Section A.2. IPv4 Header Section A.3. IPv6 Header Section A.4. IPv4 Addresses Section A.5. IPv6 Addresses Section A.6. Internet Control Message Protocols (ICMPv4 and ICMPv6) Appendix B. Virtual Networks Section B.1. Introduction Section B.2. The MBone Section B.3. The 6bone Section B.4. IPv6 Transition: 6to4 Appendix C. Debugging Techniques Section C.1. System Call Tracing Section C.2. Standard Internet Services Section C.3. sock Program Section C.4. Small Test Programs Section C.5. tcpdump Program Section C.6. netstat Program Section C.7. lsof Program Appendix D. Miscellaneous Source Code Section D.1. unp.h Header Section D.2. config.h Header Section D.3. Standard Error Functions Appendix E. Solutions to Selected Exercises Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Chapter 15 Chapter 16 Chapter 17 Chapter 18 Chapter 20 Chapter 21 Chapter 22 Chapter 24 Chapter 25 Chapter 26 Chapter 27 Chapter 28 Chapter 29 Chapter 30 Chapter 31 Bibliography
此书为英文版,但对于大家应该不会有阅读障碍。 此书对于linux环境编程的同志应该是必读的书,目录如下: Copyright Praise for Advanced Programming in the UNIX® Environment, Second Edition Praise for the First Edition Addison-Wesley Professional Computing Series Foreword Preface Introduction Changes from the First Edition Acknowledgments Preface to the First Edition Introduction Unix Standards Organization of the Book Examples in the Text Systems Used to Test the Examples Acknowledgments Chapter 1. UNIX System Overview Section 1.1. Introduction Section 1.2. UNIX Architecture Section 1.3. Logging In Section 1.4. Files and Directories Section 1.5. Input and Output Section 1.6. Programs and Processes Section 1.7. Error Handling Section 1.8. User Identification Section 1.9. Signals Section 1.10. Time Values Section 1.11. System Calls and Library Functions Section 1.12. Summary Exercises Chapter 2. UNIX Standardization and Implementations Section 2.1. Introduction Section 2.2. UNIX Standardization Section 2.3. UNIX System Implementations Section 2.4. Relationship of Standards and Implementations Section 2.5. Limits Section 2.6. Options Section 2.7. Feature Test Macros Section 2.8. Primitive System Data Types Section 2.9. Conflicts Between Standards Section 2.10. Summary Exercises Chapter 3. File I/O Section 3.1. Introduction Section 3.2. File Descriptors Section 3.3. open Function Section 3.4. creat Function Section 3.5. close Function Section 3.6. lseek Function Section 3.7. read Function Section 3.8. write Function Section 3.9. I/O Efficiency Section 3.10. File Sharing Section 3.11. Atomic Operations Section 3.12. dup and dup2 Functions Section 3.13. sync, fsync, and fdatasync Functions Section 3.14. fcntl Function Section 3.15. ioctl Function Section 3.16. /dev/fd Section 3.17. Summary Exercises Chapter 4. Files and Directories Section 4.1. Introduction Section 4.2. stat, fstat, and lstat Functions Section 4.3. File Types Section 4.4. Set-User-ID and Set-Group-ID Section 4.5. File Access Permissions Section 4.6. Ownership of New Files and Directories Section 4.7. access Function Section 4.8. umask Function Section 4.9. chmod and fchmod Functions Section 4.10. Sticky Bit Section 4.11. chown, fchown, and lchown Functions Section 4.12. File Size Section 4.13. File Truncation Section 4.14. File Systems Section 4.15. link, unlink, remove, and rename Functions Section 4.16. Symbolic Links Section 4.17. symlink and readlink Functions Section 4.18. File Times Section 4.19. utime Function Section 4.20. mkdir and rmdir Functions Section 4.21. Reading Directories Section 4.22. chdir, fchdir, and getcwd Functions Section 4.23. Device Special Files Section 4.24. Summary of File Access Permission Bits Section 4.25. Summary Exercises Chapter 5. Standard I/O Library Section 5.1. Introduction Section 5.2. Streams and FILE Objects Section 5.3. Standard Input, Standard Output, and Standard Error Section 5.4. Buffering Section 5.5. Opening a Stream Section 5.6. Reading and Writing a Stream Section 5.7. Line-at-a-Time I/O Section 5.8. Standard I/O Efficiency Section 5.9. Binary I/O Section 5.10. Positioning a Stream Section 5.11. Formatted I/O Section 5.12. Implementation Details Section 5.13. Temporary Files Section 5.14. Alternatives to Standard I/O Section 5.15. Summary Exercises Chapter 6. System Data Files and Information Section 6.1. Introduction Section 6.2. Password File Section 6.3. Shadow Passwords Section 6.4. Group File Section 6.5. Supplementary Group IDs Section 6.6. Implementation Differences Section 6.7. Other Data Files Section 6.8. Login Accounting Section 6.9. System Identification Section 6.10. Time and Date Routines Section 6.11. Summary Exercises Chapter 7. Process Environment Section 7.1. Introduction Section 7.2. main Function Section 7.3. Process Termination Section 7.4. Command-Line Arguments Section 7.5. Environment List Section 7.6. Memory Layout of a C Program Section 7.7. Shared Libraries Section 7.8. Memory Allocation Section 7.9. Environment Variables Section 7.10. setjmp and longjmp Functions Section 7.11. getrlimit and setrlimit Functions Section 7.12. Summary Exercises Chapter 8. Process Control Section 8.1. Introduction Section 8.2. Process Identifiers Section 8.3. fork Function Section 8.4. vfork Function Section 8.5. exit Functions Section 8.6. wait and waitpid Functions Section 8.7. waitid Function Section 8.8. wait3 and wait4 Functions Section 8.9. Race Conditions Section 8.10. exec Functions Section 8.11. Changing User IDs and Group IDs Section 8.12. Interpreter Files Section 8.13. system Function Section 8.14. Process Accounting Section 8.15. User Identification Section 8.16. Process Times Section 8.17. Summary Exercises Chapter 9. Process Relationships Section 9.1. Introduction Section 9.2. Terminal Logins Section 9.3. Network Logins Section 9.4. Process Groups Section 9.5. Sessions Section 9.6. Controlling Terminal Section 9.7. tcgetpgrp, tcsetpgrp, and tcgetsid Functions Section 9.8. Job Control Section 9.9. Shell Execution of Programs Section 9.10. Orphaned Process Groups Section 9.11. FreeBSD Implementation Section 9.12. Summary Exercises Chapter 10. Signals Section 10.1. Introduction Section 10.2. Signal Concepts Section 10.3. signal Function Section 10.4. Unreliable Signals Section 10.5. Interrupted System Calls Section 10.6. Reentrant Functions Section 10.7. SIGCLD Semantics Section 10.8. Reliable-Signal Terminology and Semantics Section 10.9. kill and raise Functions Section 10.10. alarm and pause Functions Section 10.11. Signal Sets Section 10.12. sigprocmask Function Section 10.13. sigpending Function Section 10.14. sigaction Function Section 10.15. sigsetjmp and siglongjmp Functions Section 10.16. sigsuspend Function Section 10.17. abort Function Section 10.18. system Function Section 10.19. sleep Function Section 10.20. Job-Control Signals Section 10.21. Additional Features Section 10.22. Summary Exercises Chapter 11. Threads Section 11.1. Introduction Section 11.2. Thread Concepts Section 11.3. Thread Identification Section 11.4. Thread Creation Section 11.5. Thread Termination Section 11.6. Thread Synchronization Section 11.7. Summary Exercises Chapter 12. Thread Control Section 12.1. Introduction Section 12.2. Thread Limits Section 12.3. Thread Attributes Section 12.4. Synchronization Attributes Section 12.5. Reentrancy Section 12.6. Thread-Specific Data Section 12.7. Cancel Options Section 12.8. Threads and Signals Section 12.9. Threads and fork Section 12.10. Threads and I/O Section 12.11. Summary Exercises Chapter 13. Daemon Processes Section 13.1. Introduction Section 13.2. Daemon Characteristics Section 13.3. Coding Rules Section 13.4. Error Logging Section 13.5. Single-Instance Daemons Section 13.6. Daemon Conventions Section 13.7. ClientServer Model Section 13.8. Summary Exercises Chapter 14. Advanced I/O Section 14.1. Introduction Section 14.2. Nonblocking I/O Section 14.3. Record Locking Section 14.4. STREAMS Section 14.5. I/O Multiplexing Section 14.6. Asynchronous I/O Section 14.7. readv and writev Functions Section 14.8. readn and writen Functions Section 14.9. Memory-Mapped I/O Section 14.10. Summary Exercises Chapter 15. Interprocess Communication Section 15.1. Introduction Section 15.2. Pipes Section 15.3. popen and pclose Functions Section 15.4. Coprocesses Section 15.5. FIFOs Section 15.6. XSI IPC Section 15.7. Message Queues Section 15.8. Semaphores Section 15.9. Shared Memory Section 15.10. ClientServer Properties Section 15.11. Summary Exercises Chapter 16. Network IPC: Sockets Section 16.1. Introduction Section 16.2. Socket Descriptors Section 16.3. Addressing Section 16.4. Connection Establishment Section 16.5. Data Transfer Section 16.6. Socket Options Section 16.7. Out-of-Band Data Section 16.8. Nonblocking and Asynchronous I/O Section 16.9. Summary Exercises Chapter 17. Advanced IPC Section 17.1. Introduction Section 17.2. STREAMS-Based Pipes Section 17.3. UNIX Domain Sockets Section 17.4. Passing File Descriptors Section 17.5. An Open Server, Version 1 Section 17.6. An Open Server, Version 2 Section 17.7. Summary Exercises Chapter 18. Terminal I/O Section 18.1. Introduction Section 18.2. Overview Section 18.3. Special Input Characters Section 18.4. Getting and Setting Terminal Attributes Section 18.5. Terminal Option Flags Section 18.6. stty Command Section 18.7. Baud Rate Functions Section 18.8. Line Control Functions Section 18.9. Terminal Identification Section 18.10. Canonical Mode Section 18.11. Noncanonical Mode Section 18.12. Terminal Window Size Section 18.13. termcap, terminfo, and curses Section 18.14. Summary Exercises Chapter 19. Pseudo Terminals Section 19.1. Introduction Section 19.2. Overview Section 19.3. Opening Pseudo-Terminal Devices Section 19.4. pty_fork Function Section 19.5. pty Program Section 19.6. Using the pty Program Section 19.7. Advanced Features Section 19.8. Summary Exercises Chapter 20. A Database Library Section 20.1. Introduction Section 20.2. History Section 20.3. The Library Section 20.4. Implementation Overview Section 20.5. Centralized or Decentralized? Section 20.6. Concurrency Section 20.7. Building the Library Section 20.8. Source Code Section 20.9. Performance Section 20.10. Summary Exercises Chapter 21. Communicating with a Network Printer Section 21.1. Introduction Section 21.2. The Internet Printing Protocol Section 21.3. The Hypertext Transfer Protocol Section 21.4. Printer Spooling Section 21.5. Source Code Section 21.6. Summary Exercises Appendix A. Function Prototypes Appendix B. Miscellaneous Source Code Section B.1. Our Header File B.2 Standard Error Routines Appendix C. Solutions to Selected Exercises

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值