Linux System Programming: Talking Directly to the Kernel and C Library

Linux System Programming: Talking Directly to the Kernel and C Library

Robert Love

Language: English

Pages: 456

ISBN: 1449339530

Format: PDF / Kindle (mobi) / ePub

Write software that draws directly on services offered by the Linux kernel and core system libraries. With this comprehensive book, Linux kernel contributor Robert Love provides you with a tutorial on Linux system programming, a reference manual on Linux system calls, and an insider’s guide to writing smarter, faster code.

Love clearly distinguishes between POSIX standard functions and special services offered only by Linux. With a new chapter on multithreading, this updated and expanded edition provides an in-depth look at Linux from both a theoretical and applied perspective over a wide range of programming topics, including:

  • A Linux kernel, C library, and C compiler overview
  • Basic I/O operations, such as reading from and writing to files
  • 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
  • Thread concepts, multithreaded programming, and Pthreads
  • File and directory management
  • Interfaces for allocating memory and optimizing memory access
  • Basic and advanced signal interfaces, and their role on the system
  • Clock management, including POSIX clocks and high-resolution timers

Linux User & Developer: Get Started With Raspberry Pi (i118)

Java 2D Graphics

Access 2007 All-in-One Desk Reference For Dummies

Programming Hive

Ubuntu Certified Professional Study Guide (Exam LPI 199)
















Event-driven graphical user interface (GUI) applications may contend with literally hundreds of pending events via their mainloops.* Without the aid of threads—essentially servicing each file descriptor separately—a single process cannot reasonably block on more than one file descriptor at the same time. Working with multiple file descriptors is fine, so long as they are always ready to be read from or written to. But as soon as one file descriptor that is not yet ready is encountered—say, if a.

That fits neatly inside of a block guarantees block-aligned I/O requests, and prevents extraneous work inside the kernel. Figuring out the block size for a given device is easy using the stat( ) system call (covered in Chapter 7) or the stat(1) command. It turns out, however, that you don’t usually need to know the actual block size. The primary goal in picking a size for your I/O operations is to not pick an oddball size such as 1,130. No block in the history of Unix has been 1,130 bytes, and.

Made for a given chunk of a file, the kernel also reads the following chunk of the file. If a request is subsequently made for that chunk—as is the case when reading a file sequentially—the kernel can return the requested data immediately. Because disks have track buffers (basically, hard disks perform their own readahead internally), and because files are generally laid out sequentially on disk, this optimization is low-cost. Some readahead is usually advantageous, but optimal results depend on.

Kernel through this well-defined mechanism, and execute only code that the kernel allows it to execute. The exact mechanism varies from architecture to architecture. On i386, for example, a user-space application executes a software interrupt instruction, int, with a value of 0x80. This instruction causes a switch into kernel space, the protected realm of the kernel, where the kernel executes a software interrupt handler—and what is the handler for interrupt 0x80? None other than the system call.

Bash, has the pid 1700. The user’s bash instance is now the sole member and leader of a new process group, with the process group ID 1700. This process group is inside a new session with the session ID 1700, and bash is the sole member and the leader of this session. New commands that the user runs in the shell run in new process groups within session 1700. One of these process groups—the one connected directly to the user and in control of the terminal—is the foreground process group. All the.

Download sample