Unixlinux Programming Tutorial

Source: Internet
Author: User

Unixlinux Programming Tutorial
Basic information:
Author: Zhao kejia Shen Zhiyu
Series name: Original Series
Press: Machinery Industry Press
ISBN: 9787111403890
Mounting time:
Published on: February 1, January 2013
Start: 16
Page number: 1
Version: 1-1 category: Computer> operating system> Linux

For more information, unixlinux Programming Tutorial

Introduction:
Computer books
The Unix/Linux Programming Tutorial follows the latest "unified UNIX Specification Version 4" and systematically describes programming methods for various functions of UNIX APIs on the Linux platform. This book covers the development history and standards of UNIX, standard I/O and low-level I/O, file and directory operations, process environment and process control, signal processing, time and timing, terminal I /O, advanced I/O, inter-process communication, socket-network communication, and multi-thread programming.
The Unix/Linux Programming Tutorial introduces the functions and usage of various functions of UNIX APIs, and clearly describes the basic operating system principles they imply. The book provides a large number of program design examples, which helps readers better master the functions, usage methods and programming skills of these functions.
The Unix/Linux programming course is particularly suitable for computer teachers in colleges and universities, Senior undergraduates, and graduate students as teaching materials and reference books, it is also particularly suitable for engineers and technicians engaged in computer system software and application software development as practical programming manuals.
Directory
Unix/Linux Programming Tutorial
Preface
Chapter 2
Introduction to Unix 1
1.1 UNIX Brief History 1
1.1.1 The Birth of UNIX 1
1.1.2 early development of UNIX 2
1.1.3 bsd unix 3
1.1.4 System v unix 3
1.1.5 commercialization of UNIX 4
1.1.6 Linux 4
Standard 5 1.2
1.2.1 svid 5
1.2.2 POSIX 6
1.2.3 unified UNIX specification 6
1.2.4 c Standard 8
1.3 Basic UNIX concepts 8
1.3.1 programs and processes 8
1.3.2 kernel 9
1.3.3 shell 10
1.3.4 user name and user ID, user group and group ID 12
1.3.5 privileged user 12
1.3.6 System Call and database function 12
1.4 system library 13
1.4.1 header file 14
1.4.2 reserved words 14
1.4.3 feature test macro 15
1.5 sample program and compiling environment 16
1.6 error handling 17
1.7 system information 19
1.7.1 machine identification 19
1.7.2 hardware/software type identification 19
1.8 system capability Limit 20
1.8.1 general capability limit value 21
1.8.2 system and file feature Option 22
1.8.3 sysconf (), pathconf (), and fpathconf () functions 23
1.9 thinking and practice 27
Chapter 2 standard input and output 28
2.1 Basic UNIX Input and Output concepts 28
2.2 stream and file object 30
2.3 enable and disable stream 31
2.4 read and write streams 33
2.4.1 character I/O 33
2.4.2 rows I/O 34
2.4.3 read rollback 37
2.4.4 I/O 38
2.5 file location 40
2.6 file end and error indicator 42
2.7 stream buffer 43
2.8 format I/O 46
2.8.1 format output 47
2.8.2 format input 50
2.9 temporary file 53
2.10 thoughts and exercises 55
Chapter 1 low-level input and output 56
3.1 open, create, and close file description 56
3.2 read () and write () functions 60
3.3 set the File Location of the description word 61
3.4 DUP () and dup2 () functions 64
3.5 fdopen () and fileno () functions 65
3.6 file control function fcntl () 65
3.6.1 duplicate file description 66
3.6.2 file description tag 67
3.6.3 File status tag 68
3.7 non-blocking I/O 71
3.8 readv () and writev () functions 73
3.9 fsync () and fdatasync () functions 74
3.10 thinking and exercises 75
Chapter 7 files and directories 77
4.1 file 77
4.1.1 Stat (), fstat (), and lstat () functions 78
4.2 file type 79
4.2.1 common file 79
4.2.2 directory 80
4.2.3 link and link () function 80
4.2.4 symbolic links and symlink () and readlink () functions 82
4.2.5 special file 83
4.2.6 test file type 84
4.3 owner and user group of files 85
4.3.1 chown (), fchown (), and lchown () functions 86
4.4 file method 87
4.4.1 file access permission 88
4.4.2 adjust user ID and group ID 89
4.4.3 Sticky Bit 90
4.4.4 file mode location summary 91
4.5 identify and change the file method 92
4.5.1 umask () function 92
4.5.2 chmod () and fchmod () functions 94
4.5.3 access () function 94
4.6 file size 96
4.6.1 file truncation 97
4.7 file time 99
4.7.1 utime () and utimes () functions 99
4.8 Delete and rename a file 101
4.8.1 delete files and directories 101
4.8.2 file name 103
4.9 directory operations 104
4.9.1 working directory 104
4.9.2 create directory 105
4.9.3 read directory stream 106
4.9.4 Random Access to directory streams 109
4.10 thinking and exercises 109
Chapter 2 process environment 5th
5.1 main () function 111
5.2 command line parameters 111
5.2.1 syntax conventions of command line parameters 112
5.2.2 scan command line option 113
5.3 environment variable 115
5.3.1 stage 116
5.3.2 access environment 117
5.4 terminate process 118
5.4.1 exit status 119
5.4.2 clean up before termination 119
5.4.3 abortion procedure 120
5.5 process storage space 121
5.5.1 process address space: 122
5.5.2 allocation and release of dynamic storage 123
5.5.3 release allocated storage unit 126
5.6 setjmp () and longjmp () functions 127
5.7 Process Resource 130
5.7.1 view and set a resource limit of 131
5.7.2 132 resource usage statistics
5.8 user information 133
5.8.1 username 133
5.8.2 user database 134
5.8.3 group databases 136
5.9 Process Identity creden139
5.10 adjust Process Identity 141
5.11 thinking and exercises 146
Chapter 4 Process Control 6th
6.1 process ID 147
6.2 Process Creation 148
6.3 execute a new program 151
6.4 wait for the process to complete 155
6.5 Process Termination and zombie process 159
6.6 system () function 163
6.7 process group 164
6.8 meeting period 165
6.9 control terminal 166
6.10 job control 168
6.11 thinking and exercises 174
Chapter 1 signal processing 7th
7.1 signal concept 175
7.2 UNIX signal 177
7.2.1 program error signal 179
7.2.2 program abort signal 180
7.2.3 alarm signal 180
7.2.4 I/O signal 180
7.2.5 job control signal 181
7.2.6 operation error signal 181
7.2.7 other signals 182
7.3 generate signal 182
7.3.1 raise () function 182
7.3.2 kill () function 183
7.4 set the signal action 184
7.4.1 signal () function 184
7.4.2 signal action at the beginning of a process 186
7.4.3 unreliable signal 187
7.4.4 sigaction () function 188
7.5 signal handle 191
7.5.1 Normal Return Signal handle 192
7.5.2 Process Termination handle 192
7.6 blocking signal 193
7.6.1 sigset_t type and Signal Set operation 193
7.6.2 set signal shielding 194
7.6.3 check suspension signal 196
7.7 wait signal 197
7.7.1 pause () function 197
7.7.2 sigsuspend () function 198
7.8 use separate signal stack 201
7.9 signal handle programming skills 204
7.9.1 non-local transfer control within the handle 204
7.9.2 reentrant function and asynchronous signal security function 207
7.9.3 system call interrupted by signal 210
7.9.4 atomic data 211
7.10 real-time signal 212
7.10.1 sa_siginfo flag 213
7.10.2 send real-time signal 217
7.10.3 waiting for real-time signal 219
7.11 thinking and exercises 221
Chapter 1 time and timing 8th
8.1 system clock 222
8.1.1 time (): function 222
8.1.2 gettimeofday () function 223
8.2 convert the time format to 224
8.2.1 decomposed calendar time 224
8.2.2 format Date and Time 227
8.3 CPU time and wall clock time 229
8.3.1 clock () function 230
8.3.2 times () function 231
8.4 sleep and timing 233
8.4.1 sleep () function 233
8.4.2 set the timer 233
8.5 real-time clock and timing 237
8.5.1 real-time clock 238
8.5.2 real-time sleep 240
8.5.3 real-time timers 241
8.5.4 create and delete a Real-Time timer 241
8.5.5 set the Real-Time timer 243
8.5.6 timer expiration count 244
8.6 thinking and exercises 246
Chapter 4 Terminal I/O 9th
9.1 example of changing terminal settings 247
9.2 terminal I/O overview 249
9.2.1 terminal 249
9.2.2 serial port 250
9.2.3 terminal device file 252
9.2.4 input/output queue 252
9.2.5 processing and non-processing Input Method 253
9.3 GTI control interface 254
9.3.1 termios Data Structure 254
9.3.2 GTI controls function 255
9.4 terminal properties 256
9.4.1 input mode 256
9.4.2 output mode 257
9.4.3 control mode 258
9.4.4 Local Mode 259
9.4.5 special character 260
9.4.6 stty command 263
9.5 terminal ID 263
9.6 changing terminal attributes 265
9.7 input 266 for processing and non-processing Modes
9.7.1 Processing Method Input 266
9.7.2 input 267 for non-processing mode
9.8 set the baud rate to 272
9.9 row control functions 273
9.10 serial port programming 275
9.11 thinking and exercises 278
Chapter 2 advanced I/O 10th
10.1 file lock 279
10.1.1 fcntl () filelock operation 280
10.1.2 lock test, request, and release 282
10.1.3 relationship between file locks and processes and files 286
10.1.4 deadlock 287
10.1.5 recommended lock and force lock 288
10.2 signal-driven I/O 289
10.3 multi-channel transfer I/O 291
10.3.1 select () function 291
10.3.2 poll () function 294
10.4 asynchronous I/O 296
10.4.1 asynchronous I/O control block 297
10.4.2 signal delivery at I/O completion 298
10.4.3 priority of asynchronous I/O is 299
10.4.4 async I/O function 299
Example of 10.4.5 asynchronous I/O 304
10.4.6 precautions for asynchronous I/O 307
10.5 storage ing I/O 308
10.6 thinking and exercises 314
Chapter 2 inter-process communication 11th
11.1 pipelines 316
11.1.1 create an MPS queue 317
11.1.2 pipe communication between parent and child processes 317
11.1.3 connect standard input and standard output pipelines 319
11.1.4 popen () and pclose () functions 321
11.1.5 atomicity of pipeline I/O 322
11.2 FIFO special file 323
11.2.1 create FIFO 323
11.2.2 FIFO 325
11.2.3 FIFO for customer/service communication 328
11.3 System v ipc 331
11.3.1 keyword and ID 332
11.3.2 structure of IPC Resource Description and member ipc_perm 333
11.3.3 IPCS and ipcrm commands 334
11.4 Message Queue 334
11.4.1 create and obtain Message Queue 336
11.4.2 query, set, and delete a Message Queue 337
11.4.3 send and receive messages 339
11.5 shared storage segment 343
11.5.1 create and obtain a shared storage segment 343
11.5.2 querying, setting, and deleting shared storage segments 344
11.5.3 connection and separation of shared storage segments 345
11.6 semaphores 347
11.6.1 create and obtain the semaphore ID 348
11.6.2 querying, setting, and deleting semaphores 350
11.6.3 semaphore operation 352
11.7 thinking and exercises 357
Chapter 2 socket and network communication 12th
12.1 TCP/IP 358
12.2 socket 360
12.3 socket address structure 364
12.3.1 IP address 364
12.3.2 domain address 366
12.3.3 service and port number 369
12.3.4 socket address data structure 371
12.3.5 byte order 373
12.4 named socket 374
12.5 socket communication mode 377
12.6 stream socket operation 379
12.6.1 request connection 379
12.6.2 receive connection 381
12.6.3 getsockname () and getpeername () functions 385
12.6.4 multi-Customer Service 386
12.6.5 the send () and Recv () functions 388
12.7 socket option 390
12.8 out-of-band data 392
12.8.1 TCP out-of-band data 392
12.8.2 sending and receiving of out-of-band data 393
12.8.3 out-of-band data flag 397
12.9 datagram socket operation 399
12.9.1 functions of sendto () and recvfrom (): 399
12.9.2 example of a datagram socket client/service 400
12.9.3 use the connect () function 403
12.10 timeout processing 404
12.11 thinking and exercises 405
Chapter 4 thread 13th
13.1 thread concept 406
13.1.1 what is thread 406
13.1.2 thread benefits 409
13.1.3 pthreads thread 412
13.1.4 thread identification 413
13.2 create thread 414
13.3 terminate thread 415
13.3.1 wait for the thread to terminate 416
13.3.2 a confluence and separation thread 418
13.4 create a thread with special attributes 420
13.5 mutex variable 425
13.5.1 initialization and destruction of mutex variables 427
13.5.2 mutex variable attribute 428
13.5.3 lock and unlock of mutex variables 431
13.5.4 mutex variables and spin locks 433
13.6 read/write lock 435
13.6.1 initialization and destruction of read/write locks 435
13.6.2 lock and unlock 436 of read/write locks
13.7 condition variable 439
13.7.1 create and destroy condition variable 441
13.7.2 condition variable property 441
13.7.3 wait condition variable 443
13.7.4 wake up condition variable wait 445
13.8 thinking and exercises 448
Chapter 2 advanced features of threads 14th
14.1 thread-specific data 450
14.1.1 creation and deletion of thread-specific data keys 451
14.1.2 Use thread-specific data 454
14.2 cancel thread 456
14.2.1 cancelling attributes of a thread 457
14.2.2 cancel thread and cancel point 458
14.2.3 security of asynchronous cancellation 461
14.2.4 Onsite Cleaning 462
14.3 Thread Scheduling 464
14.3.1 Thread Scheduling competition range: 465
14.3.2 scheduling strategy and priority 467
14.3.3 469 Thread Scheduling attributes
14.3.4 dynamically changing the thread scheduling policy and priority 471
14.4 threads and signals 474
14.4.1 signal action 474
14.4.2 signal shielding 475
14.4.3 send a 476 signal to the thread
14.4.4 wait signal 477
14.4.5 a new event notification method: sigev_thread 480.
14.5 thinking and exercises 483 references 484

This book is from: China Interactive publishing network

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.