• Complain

Robert Love - Linux system programming: talking directly to the kernel and C library

Here you can read online Robert Love - Linux system programming: talking directly to the kernel and C library full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2013, publisher: OReilly Media, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Robert Love Linux system programming: talking directly to the kernel and C library
  • Book:
    Linux system programming: talking directly to the kernel and C library
  • Author:
  • Publisher:
    OReilly Media
  • Genre:
  • Year:
    2013
  • Rating:
    3 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 60
    • 1
    • 2
    • 3
    • 4
    • 5

Linux system programming: talking directly to the kernel and C library: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Linux system programming: talking directly to the kernel and C library" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

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 insiders 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

Robert Love: author's other books


Who wrote Linux system programming: talking directly to the kernel and C library? Find out the surname, the name of the author of the book and a list of all author's works by series.

Linux system programming: talking directly to the kernel and C library — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Linux system programming: talking directly to the kernel and C library" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Appendix A. GCC Extensions to the C Language

The GNU Compiler Collection (GCC) provides many extensions to the C language, some of which have proven to be of particular value to system programmers. The majority of the additions to the C language that well cover in this appendix offer ways for programmers to provide additional information to the compiler about the behavior and intended use of their code. The compiler, in turn, utilizes this information to generate more efficient machine code. Other extensions fill in gaps in the C programming language, particularly at lower levels.

GCC provides several extensions now available in the latest C standard, ISO C11. Some of these extensions function similarly to their C11 cousins, but ISO C11 implemented other extensions rather differently. New code should use the standardized variants of these features. We wont cover such extensions here; well discuss only GCC-unique additions.

GNU C

The flavor of C supported by GCC is often called GNU C. In the 1990s, GNU C filled in several gaps in the C language, providing features such as complex variables, zero-length arrays, inline functions, and named initializers. But after nearly a decade, C was finally upgraded, and with the standardization of ISO C99 and then ISO C11, GNU C extensions grew less relevant. Nonetheless, GNU C continues to provide useful features, and many Linux programmers still use a subset of GNU Coften just an extension or twoin their C99- or C11-compliant code.

One prominent example of a GCC-specific code base is the Linux kernel, which is written strictly in GNU C. Recently, however, Intel has invested engineering effort in allowing the Intel C Compiler (ICC) to understand the GNU C extensions used by the kernel. Consequently, many of these extensions are now growing less GCC-specific.

Inline Functions

The compiler copies the entire code of an inline function into the site where the function is called. Instead of storing the function externally and jumping to it whenever it is called, it runs the contents of the function directly. Such behavior saves the overhead of the function call and allows for potential optimizations at the call site because the compiler can optimize the caller and callee together. This latter point is particularly valid if the parameters to the function are constant at the call site. Naturally, however, copying a function into each and every chunk of code that invokes it can have a detrimental effect on code size. Therefore, functions should be inlined only if they are small and simple or are not called in many different places.

For many years, GCC has supported the inline keyword, instructing the compiler to inline the given function. C99 formalized this keyword:

staticinlineintfoo(void){/* ... */}

Technically, however, the keyword is merely a hinta suggestion to the compiler to consider inlining the given function. GCC further provides an extension for instructing the compiler to always inline the designated function:

staticinline__attribute__((always_inline))intfoo(void){/* ... */}

The most obvious candidate for an inline function is a preprocessor macro. An inline function in GCC will perform as well as a macro and receives type checking. For example, instead of this macro:

#define max(a,b) ({ a > b ? a : b; })

one might use the corresponding inline function:

staticinlinemax(inta,intb){if(a>b)returna;returnb;}

Programmers tend to overuse inline functions. Function call overhead on most modern architecturesx86 in particularis very, very low. Only the most worthy of functions should receive consideration!

Suppressing Inlining

In its most aggressive optimization mode, GCC automatically selects functions that appear suitable for inlining and inlines them. This is normally a good idea, but sometimes the programmer knows that a function will perform incorrectly if inlined. One example of this is when using __builtin_return_address (discussed later in this appendix). To suppress inlining, use the noinline keyword:

__attribute__((noinline))intfoo(void){/* ... */}
Pure Functions

A pure function is one that has no side effects and whose return value reflects only the functions parameters or nonvolatile global variables. Any parameter or global variable access must be read-only. Loop optimization and subexpression elimination can be applied to such functions. Functions are marked as pure via the pure keyword:

__attribute__((pure))intfoo(intval){/* ... */}

A common example is strlen(). Given identical inputs, this functions return value is invariant across multiple invocations, and thus it can be pulled out of a loop and called just once. For example, consider the following code:

/* character by character, print each letter in 'p' in uppercase */for(i=0;i<strlen(p);i++)printf("%c",toupper(p[i]));

If the compiler does not know that strlen() is pure, it would need to invoke the function with each iteration of the loop.

Smart programmersas well as the compiler, if strlen() were marked purewould write or generate code like this:

size_tlen;len=strlen(p);for(i=0;i<len;i++)printf("%c",toupper(p[i]));

Parenthetically, even smarter programmers (such as this books readers) would write:

while(*p)printf("%c",toupper(*p++));

It is illegal and indeed makes no sense for a pure function to return void, as the return value is the sole point of such functions. An example of a nonpure function is random().

Constant Functions

A constant function is a stricter variant of a pure function. Such functions cannot access global variables and cannot take pointers as parameters. Thus, the constant functions return value reflects nothing but the passed-by-value parameters. Additional optimizations, on top of those possible with pure functions, are possible for such functions. Math functions, such as

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Linux system programming: talking directly to the kernel and C library»

Look at similar books to Linux system programming: talking directly to the kernel and C library. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Linux system programming: talking directly to the kernel and C library»

Discussion, reviews of the book Linux system programming: talking directly to the kernel and C library and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.