Typographic conventions

This is a book published on the web and so it doesn't have any "typography", but certain parts of text are decorated with certain styles, thus we describe them in this section of the book.

Meaning Example
First appearance of new terms Central processing unit (CPU) executes program code.
Multiple terms linked with each other CPU consists of execution units, cache and memory controller.
Definition of a term Definition

According to this book,

A central processing unit (CPU) executes program code.

Additional information about OS or hardware internals Information

Do not read me if you already know me the answer

Notes and some additional information Note

I am note and I am providing external information about the implementation

Warning

I will warn you about some implementation quirks

Information that some of the examples or code in the section is not suitable for production use DANGER!

Never try to do rm -rf / on your home computer.

Function name, or name of the probe, any other entity that exist in source code If you want to print a line on standard output in pure C, use puts()
Chunk of the code that has to be used or command to be executed

int main() {
    puts("Hello, world");
}

$ perl -se '                     
    print "Hello, $who" . "\n"
    ' -- -who=world

Placeholders in program examples are covered in italic

puts(output-string)

Large portions of example outputs may have some output outlined with bold:

$ gcc hello.c -o hello
$ ./hello
Hello, world

Large program listing (if you want to show it, press on "+" button)

  Script file hellouser.py

import os
print "Hello, " + os.getenv('LOGNAME', 'anonymous') + '!'

Structural diagrams

Many kernel-related topics will contain structural diagrams which will represent kernel data structures like this:

image

In this example two instances of mblk_t structure (which is typedef alias) are shown which are linked together through pair of mblk_t pointers b_next and b_prev. Not all fields are shown on this diagram, types are omitted, while order of fields may not match real one. Following conventions are used in this type of diagrams:

Example code Diagram and explanation

struct structB {
    int field10;
    char field20;
};
struct structA {
    struct structB* bp;
    int field1;
};

ab
structure structA points to instance of structB

struct structA;
struct structB {
    int field10;
    struct structA* ap;
};
struct structA {
    struct structB* bp;
    int field1;
};

ab
structure structB contains backward pointer to structure structA

struct structA {
    struct structB* bp;
    int field1;
    struct {
        char c1;
        char c2;
    } cobj;
};

ab
structure structA has embedded structure (not neccessarily to be anonymous)

struct structB {
    int field10;
    char field20;
};
struct structA {
    struct structB* bp;
    int field1;
};

ab
structure structA points to a dynamic array of structures structB

struct structB {
    int field10;
    char field20;
    struct list_head node;
};
struct structA {
    struct list_head blist;
    int field1;
};

ab
structure structA contains head of linked list of structB instances
Various structure relations can be shown with this type of arrows:
  • Single solid glyph shows node-to-node relations in linked list
  • Double solid glyphs shows head-to-node relations in linked list
  • Double dashed glyphs shows various tree-like relations like RB tree in Linux

Timeline diagrams

Timeline diagrams are used to show various processes that exist in traced system and chain of events or operations happening with them and at the same time contains names of probes:

image:timeline

This diagram should be read like this:

Virtual time axis beginning at the top and it is vertical.

DANGER!

Probes shown in this example are purely fictional.