Synopses & Reviews
This book is about writing software that makes the most effective use of the system you're running on -- code that interfaces directly with the kernel and core system libraries, including the shell, text editor, compiler, debugger, core utilities, and system daemons. The majority of both Unix and Linux code is still written at the system level, and Linux System Programming focuses on everything above the kernel, where applications such as Apache, bash, cp, vim, Emacs, gcc, gdb, glibc, ls, mv, and X exist.
Written primarily for engineers looking to program (better) at the low level, this book is an ideal teaching tool for any programmer. Even with the trend toward high-level development, either through web software (such as PHP) or managed code (C#), someone still has to write the PHP interpreter and the C# virtual machine. Linux System Programming gives you an understanding of core internals that makes for better code, no matter where it appears in the stack. Debugging high-level code often requires you to understand the system calls and kernel behavior of your operating system, too.
Key topics include:
- An overview of Linux, the kernel, the C library, and the C compiler
- Reading from and writing to files, along with other basic file I/O operations, including how the Linux kernel implements and manages file I/O
- Buffer size management, including the Standard I/O library
- Advanced I/O interfaces, memory mappings, and optimization techniques
- The family of system calls for basic process management
- Advanced process management, including real-time processes
- File and directories-creating, moving, copying, deleting, and managing them
- Memory management -- interfaces for allocating memory, managing the memory youhave, and optimizing your memory access
- Signals and their role on a Unix system, plus basic and advanced signal interfaces
- Time, sleeping, and clock management, starting with the basics and continuing through POSIX clocks and high resolution timers
With
Linux System Programming, you will be able to take an in-depth look at Linux from both a theoretical and an applied perspective as you cover a wide range of programming topics.
Synopsis
Covering a wide range of programming topics, this practical guide helps developers better understand Linux systems and application development through coverage of all the major development tools and how they link into the Linux kernel.
Synopsis
Covering a wide range of programming topics, this practical guide helps developers better understand Linux systems and application development through coverage of all the major development tools and how they link into the Linux kernel.
Synopsis
SYSTEM AND LIBRARY CALLS EVERY PROGRAMMER NEEDS TO KNOW
About the Author
Robert Love has been a Linux user and hacker since the early days. Heis active in, and passionate about, both the Linux kernel and GNOMEdesktop communities. His recent contributions to the Linux kernelinclude work on the kernel event layer and inotify. GNOME-relatedcontributions include Beagle, GNOME Volume Manager, NetworkManager,and Project Utopia. Currently Robert works in the Open Source ProgramOffice at Google.
As an author, Robert is responsible for Linux Kernel Development(SAMS), now in its second edition, and Linux System Programming(O'Reilly). He is also a coauthor of the fifth edition of O'Reilly'sLinux in a Nutshell. He's a Contributing Editor for Linux Journal, haswritten numerous articles, and has been invited to speak around theworld on Linux.
Robert graduated from the University of Florida with a B.A. inMathematics and a B.S. in Computer Science. Hailing from SouthFlorida, he currently calls Boston home.
Table of Contents
Foreword; Preface; Audience and Assumptions; Contents of This Book; Versions Covered in This Book; Conventions Used in This Book; Safari® Books Online; Using Code Examples; How to Contact Us; Acknowledgments; Chapter 1: Introduction and Essential Concepts; 1.1 System Programming; 1.2 APIs and ABIs; 1.3 Standards; 1.4 Concepts of Linux Programming; 1.5 Getting Started with System Programming; Chapter 2: File I/O; 2.1 Opening Files; 2.2 Reading via read( ); 2.3 Writing with write( ); 2.4 Synchronized I/O; 2.5 Direct I/O; 2.6 Closing Files; 2.7 Seeking with lseek( ); 2.8 Positional Reads and Writes; 2.9 Truncating Files; 2.10 Multiplexed I/O; 2.11 Kernel Internals; 2.12 Conclusion; Chapter 3: Buffered I/O; 3.1 User-Buffered I/O; 3.2 Standard I/O; 3.3 Opening Files; 3.4 Opening a Stream via File Descriptor; 3.5 Closing Streams; 3.6 Reading from a Stream; 3.7 Writing to a Stream; 3.8 Sample Program Using Buffered I/O; 3.9 Seeking a Stream; 3.10 Flushing a Stream; 3.11 Errors and End-of-File; 3.12 Obtaining the Associated File Descriptor; 3.13 Controlling the Buffering; 3.14 Thread Safety; 3.15 Critiques of Standard I/O; 3.16 Conclusion; Chapter 4: Advanced File I/O; 4.1 Scatter/Gather I/O; 4.2 The Event Poll Interface; 4.3 Mapping Files into Memory; 4.4 Advice for Normal File I/O; 4.5 Synchronized, Synchronous, and Asynchronous Operations; 4.6 I/O Schedulers and I/O Performance; 4.7 Conclusion; Chapter 5: Process Management; 5.1 The Process ID; 5.2 Running a New Process; 5.3 Terminating a Process; 5.4 Waiting for Terminated Child Processes; 5.5 Users and Groups; 5.6 Sessions and Process Groups; 5.7 Daemons; 5.8 Conclusion; Chapter 6: Advanced Process Management; 6.1 Process Scheduling; 6.2 Yielding the Processor; 6.3 Process Priorities; 6.4 Processor Affinity; 6.5 Real-Time Systems; 6.6 Resource Limits; Chapter 7: File and Directory Management; 7.1 Files and Their Metadata; 7.2 Directories; 7.3 Links; 7.4 Copying and Moving Files; 7.5 Device Nodes; 7.6 Out-of-Band Communication; 7.7 Monitoring File Events; Chapter 8: Memory Management; 8.1 The Process Address Space; 8.2 Allocating Dynamic Memory; 8.3 Managing the Data Segment; 8.4 Anonymous Memory Mappings; 8.5 Advanced Memory Allocation; 8.6 Debugging Memory Allocations; 8.7 Stack-Based Allocations; 8.8 Choosing a Memory Allocation Mechanism; 8.9 Manipulating Memory; 8.10 Locking Memory; 8.11 Opportunistic Allocation; Chapter 9: Signals; 9.1 Signal Concepts; 9.2 Basic Signal Management; 9.3 Sending a Signal; 9.4 Reentrancy; 9.5 Signal Sets; 9.6 Blocking Signals; 9.7 Advanced Signal Management; 9.8 Sending a Signal with a Payload; 9.9 Conclusion; Chapter 10: Time; 10.1 Time's Data Structures; 10.2 POSIX Clocks; 10.3 Getting the Current Time of Day; 10.4 Setting the Current Time of Day; 10.5 Playing with Time; 10.6 Tuning the System Clock; 10.7 Sleeping and Waiting; 10.8 Timers; GCC Extensions to the C Language; GNU C; Inline Functions; Suppressing Inlining; Pure Functions; Constant Functions; Functions That Do Not Return; Functions That Allocate Memory; Forcing Callers to Check the Return Value; Marking Functions As Deprecated; Marking Functions As Used; Marking Functions or Parameters As Unused; Packing a Structure; Increasing the Alignment of a Variable; Placing Global Variables in a Register; Branch Annotation; Getting the Type of an Expression; Getting the Alignment of a Type; The Offset of a Member Within a Structure; Obtaining the Return Address of a Function; Case Ranges; Void and Function Pointer Arithmetic; More Portable and More Beautiful in One Fell Swoop; Bibliography; Colophon;