Book reviews

Linux kernel in a nutshell, ISBN-10: 0-596-10079-7, December 2006

Language: English.
Easy explained how to download a new kernel and customizing it.
Interesting chapter regarding driver modules and how to find out which modules that are needed for your specific hardware.
Adding kernel debugging with exact time stamps, seperate debug filesystem (in memory, like sysfs), and Magic SysRq Keys.
Unfortunately, most of the information is only regarding which issues to select when compiling the kernel. It could have been nice with some more examples of how to use it afterwords.
It also explains how to pass options to the kernel for three different situations:
  1. When building the kernel
  2. When starting the kernel.
  3. At runtime by writing to /proc and /sys.
The book is very well written and therefore easy to read.

C++, by Kris Jamsa, ISBN-10: 87-7843-265-0, 1999

Language: Danish.
Very basic at the beginning, but it is so well written that it is very easy to jump forward to the interesting stuff.
Highlights:
  • Explains structs at page 74, and that the reserved word "struct" is only required in C and is optional in C++.
  • Structs: Explains how to use dot notation (reference) and "->" notation (pointer). "->" is used when a pointer to a struct is transferred to a function and the address to the pointer needs to be modified (page74-77). But the example at page 76 with strcpy(ny_medarbejder.navn,"Ole Olsen") is tricky, as you might expect it to be with "&ny_medarbejder->navn". The reason for not using & and "->" is that a string array name is already a pointer (see page 80 column 2).
  • Example:
    #include <iostream.h>
    #include <string.h>
    
    /*  Example showing the difference in use between the formats:
          employee.name
          employee->name
        But why can employee.name be used inside the subroutine strcpy?
    */
    
    struct employee {
      char name[64];
      long id;
      float salary;
    };
    
    void set_id(employee *person)
    {
      cout << "Write employee id: ";
      cin >> person->id;
    }
    
    void main(void)
    {
      employee my_employee;
    
      #Setting a field in the struct:
      strcpy(my_employee.name,"Ole Hansen");
    
      #Setting a field in the struct inside a function or subroutine
      set_id(&my_employee);
    }
    

  • Union and anonymous union: Like a struct, but can only have one field set at a time. An anonymous union does not need the dot notation. An union saves memory space in some cases. See page 77-79.
  • Pointers (page 80-83)
  • Object oriented programming: Classes explained in a simple manner (page 84-87). (There seem to be an error on page 86. The method "vis_race" does not exist. The author probably mean "vis_hund".
  • Private versus public (page 87-90).
  • Contructor and de-constructor (page 91-95).
  • Overload of operators (page 96-101).
  • Static elements (common for all objects of the given class). If specified as public, they can be used even without any objects of the given class. See page 101-104.
  • Inheritance explained with easy-to-read examples. Sub-classes and protected elements explained (page 105-109).
  • Multiple Inheritance (inheritance from more than one class) (page 109-113)
  • Working with files as streams. An object is created of type ifstream or ofstream, and passes the filename to the contructor (page 113-118).
  • Argv (argument values) and argc (argument count) with examples (page 118-121).
  • Constants and macros (page 121-125): They are substituted with the contents of the constants/macros during the pre-processor of the C++ compiler. Constants and macros make the program easier to read (by using meaningfull names) and reduces coding errors (less code to write). They are also easier to modify, as it is only necessary to modify the constants and macros at one location (at the definition) and not on all occurrences. There are no decrease in code speed (as there are for functions), but the compiled code is not reduced either. So there are both advantages and disadvantages for macros compared to functions. Always use parameters in paranthesis (see example page 124), as it might give wrong operator priority otherwise. Example:
  • #include <iostream.h>
    
    #define KUBUS(x) ((x)*(x)*(x))
    
    void main(void)
    {
      for (int i=1; i<=10; i++)
        cout << "Kubus of " << i << " is " << KUBUS(i) << endl;
    }
    
    If it was defined like KUBUS(x) (x*x*x), then the result would change if x=3+5-2, as the result would be (3+5-2*3+5-2*3+5-2) and not ((3+5-2)*(3+5-2)*(3+5-2)).
    (Macro is almost equivalent with the reserved word "inline" in C++, but this is not explained in this book. Read here or here for more details).

    C/C++ grundbog i programmering, Henrik Kressner, ISBN-10: 87-571-2270-9, year: 2001

    I do not like the layout of this book. I have only read small parts of it. Highlights:
    Page 77: It is a good idea to convert any input to integer, if integers (numbers) only are expected in an input string. Example:
    #include <stdio.h>
    
    int charToInt(char input[])
    {
      int i, summa = 0;
    
      for (i=0; input[i] != '\0'; i++)
        {
          summa = summa * 10 + input[i] - '0';
        }
      return summa;
    }
    
    int main()
    {
      char testData[]="3257";
      
      printf("%d\n", charToInt(testData));
      return 0;
    }
    
    Note: Instead of subtracting the value of the char '0', the char itself is subtracted. This way the program can be compiled on different platforms (char value independent).

    Malloc and free is used to handle dynamic memory allocation. A nice example with use of pointers for a card index (see page 115).

    Linux appliance design, ISBN: 978-1-59327-140-4, 2007

    Language: English.
    Interesting chapters:
  • Chapter 3 (starting at page 19) explains a Run Time Access (RTA) protocol used in this book between the User Interface (IU / GUI) and the daemon. While the User Interface (UI) think they are dealing with a PostgreSQL database, they are, in fact talking to the daemon.
  • Chapter 4 (starting at page 43) with code examples of how to write a daemon and how to secure it. Quite advanced.
  • Chapter 6 (starting at page 77) explaining logger, syslog, syslogd, and how to add independent control of logging in each program section supporting on-demand logging.
  • Chapter 8 (starting at page 105) Designing a WEB interface. Explains different methods, including how Linksys WRT54G is written entirely in C including handcrafted functions for each page. It compares 7 different webservers (Apache 2, thttpd, lighttpd, Cherokee, BusyBox, Boa and GoAhead).

  • Linux for Embedded and Real-Time Applications, ISBN-13: 978-0-7506-7932-9, 2. edition 2006

    Language: English.
    MH Rating: 6/10. Read sep-nov 2008.
    See review as pdf here or as html here


    C++ series on youtube

    C++ series on youtube here

    Webmaster