Chapter 13 Configuring the Kernel

13.1 Introduction:

    1. what is the purpose of the kernel:
    2. kernel hides the system’s hardware underneath an abstract, high-level programming interface. It is responsible for implementing many of the facilities that users and user-level programs take for granted.

       

    3. what kernel contains:
    4. à device drivers: manage specific pieces of hardware

      à other device-independent stuffs.

       

    5. how kernel works:
    6. à a process asks the kernel do something

      à the kernel translate this into a device driver instruction

      à the driver further break this command down into sequences of bit patterns to be presented to the device’s control registers.

       

    7. what kernel written by:

kernel is written mostly in C, with a little assembly language for low-level processing.

 

13.2 Differences Between ATT and BSD

BSD kernels ask for guidance in advance, while ATT kernels forge blindly ahead and then beg for forgiveness after something gone horribly wrong.

13.3 when to configure the kernel

    1. Installing a New System
    2. à you should reconfigure the kernel every time you bring up a new machine and every time you upgrade the operating system. Most versions of UNIX come with a "generic" kernel already configred. You will usually be supplied with both a generic configuration

      file and the corresponding executable kernel.

       

    3. Adding Device Driver

à to add a new type of device to your system, you must include its driver in your kernel. The driver code has to be integrated into the kernel’s data structures and tables.

à several ways of adding device drivers:

    1. go back to the configuratin files for the kernel and add in the new device,rebuilding the kernel from scratch, which is static.
    2. "loadable" device driver, in most cases implying that new code can be loaded into the kernel while it is running, which is dynamic.

 

    1. Tuning table sizes

à the kernel runs in constant space. When you boot the system, the kernel figures out the number of process table slots, filesystem buffers, and file table entries to allocate, then goes out and scarfs up the appropriate amount of memory. We can not start more processes or oen or files than the kernel is configured to support. So, if we have too few or two many table entries which makes the system not work properly, we have to reconfigure the kernel.

 

13.4 Building a BSD kernel

building a kernel is a nine-step process:

    1. Auditing the System’s Hardware
    2. à Before you can configure a kernel, you need to know what devices it must handle. Make a list of all the devices connected to the computer, including:

      Terminal interfaces

      Disk drives and their controllers

      Tape drives and their controllers

      Network interfaces

      Coprocessors(graphics processors, etc)

      Frame buffers

      Keyboard and mouse

       

    3. Creating a Configuration File in SYS/conf
    4. à Once you know how you want your kernel configured, you must put this information into a form that config can understand. To do this , you create a configuration file in SYS/conf. You can copy the GENERIC configuration and delete the part you don’t want instead of creating the configuration from scratch.

       

    5. Creating the Kernel’s Compilation Directory
    6. à cd to your SYS area and run the command mkdir kernel.

       

    7. Running config
    8. à cd to the SYS/conf directory before running config, because it expects to find the configuration file specified on the command line in the current directory.

      à do config < the name of the kernel file >

       

    9. Running make depend
    10. à after config finishes, cd to the compilation directory for the new kernel. Now run make depend inside the compilation directory. This will initialize the file dependency information used by make.

       

    11. Building the Kernel
    12. à In the compilation directory, type make kernel, where kernel is the name of one of the configurations you specified with a config keyword inside the configuration file,. This will usually be vmunix.

      à For extra protection, have make keep a record of everything that gets sent to your terminal with the tee command.

      make vmunix | & tee ERRS.LOG

       

    13. Installing the Kernel
    14. à Before you boot a new kernel, make sure that you can recover your system if it doesn’t work.

       

    15. Testing and Debugging the Kernel
    16. à Before you reboot the machine, bring it down to single-user mode and use fsck –p to clean the root partition of the disk. Then reboot.

      à you can do a ps, and a ls check whether you system is in good shape.

       

    17. Documenting the Kernel

à Go back to your original SYS/conf/Kernel file and put in copious comments so that you will understand what you have done when you come back to read it six months or a year later.

à send mail to the users of your system describing the changes you have made.