You are here:
Linux Internals

This Linux Internals course focuses on the elements of the Linux Kernel that allow the programmer to build software components that are heavily linked to the hardware level in computer systems. The Linux operating system benefits from a modular Kernel structure that allows programmers to focus on a particular area without interfering with other parts of the Kernel. Given that the programmer knows how to use the various interfaces and tools already built into the Kernel, adding a new feature to the OS is greatly simplified.

This course allows the student to gain a good general understanding of these basic tools and interfaces in order to successfully modify features and develop new aspects of the Linux Kernel. Since this course is based on the latest versions of the Linux Kernel (version 2.4.x), students will be able to contribute to current Linux development efforts.

The course includes many questions to facilitate an interactive learning experience. There are five major labs that give students strong practical experience of the steps involved in Kernel development by focusing on real world exercises.

 
Who Should Attend
This course is aimed at programmers, software designers and technical managers who plan to use Linux below the application level. For instance, it is useful as an introduction for the development of Linux in embedded systems and device drivers programming.
 
Prerequisites
Students are expected to have a good working knowledge of the C programming language. For example, UNIX signals, processes and filesystem access methods will be used in this course but will not be extensively explained. An intermediate knowledge of the UNIX/Linux shell commands is needed. Students should also know how to use one of the commonly used UNIX editors (Vi, Emacs or others)
 
Features

Hands-on sessions will cover issues involved in modifying the current Linux kernel. This includes writing and making changes to actual device drivers, designing new components and Kernel development in the C programming language.

Students are expected to spend one to two hours each day on lab sessions, depending on the topics covered and the students overall technical level. About 25% of the course will be spent on hands-on exercises.

 
Benefits of Attending this Class

Upon completion of this course, students should be able to:

  • Install and configure the Linux Kernel.
  • Understand the structure under which the Linux Kernel was built and continues to evolve.
  • Gain an understanding of the tasks that we use the Kernel for.
  • Modify, test and implement new features in the Linux Kernel.
  • Identify the difference between user space and Kernel space on the Linux operating system, and understand how we can link these two levels.
  • Be able to use the various hardware abstraction levels that the Kernel makes available to the programmer, in order to produce code that is both architecture and version independent.
  • Distinguish the differences between the version 2.4 and 2.2 of the Linux Kernel.
 
Course Contents

Introduction to Linux Internals

Introduction and Environmental Setup
Main Characteristics of the Linux Operating System
Linux Distributions
Kernel Configuration facilities
Building the Kernel
Location of components
Compiling

Kernel Overview

Important Data structures
Processes and tasks
Files and Inodes
Dynamic memory management
Queues and semaphores
System time and timers

Primary algorithms

  • Signals
    Interrupts
    System booting
    Timer interrupt
    Scheduler

System call implementation

  • Description of system calls
    Practical examples
    Adding new system calls

Memory Management

Architecture-dependent memory model

  • Pages
    Virtual address space
    Linear address conversion
    Page table and page directory
    Middle page directory

Virtual address space model

  • User segment
    Virtual memory
    The brk system call
    Mapping functions
    Kernel segment
    Static and dynamic memory allocation in the Kernel

Block device caching

  • Block buffering
    Update and bdflush
    List structures for the buffer cache
    How to use the buffer cache

Paging in Linux

  • Page cache management
    Finding free pages

Page exceptions

Inter-Process Communication

Synchronization
Communication via files
Pipes
Debugging using “ptrace”
SysV Inter-Process communication
Socket based communications

File System

Basic aspects
VFS
Mouting a file system
Superblock
The Inode concept and operations
File operations
Directory cache
Proc filesystem
Ext2 filesystem

  • Structure
    Directories
    Block allocation
    Extensions

System Calls

Initialization
Process management
Memory management
Communication
Filesystem

Kernel-Related Commands

Ps
top
free
init
shutdown
strace
traceroute
mount

Device Drivers

Character vs Block devices

Polling and interrupts

  • Polling and interrupt mode
    Interrupt sharing
    Bottom halves
    Task queues

Implementation

  • Setup
    Init
    Open and release
    Read and write

IOCTL

  • Select
    Lseek
    Mmap

Readdir
Fsync and fasync
Check_mdeai_change and revalidate

Module management

Interfaces to modules
Adding/removing modules to the Kernel
Insmod
Modprobe
rmmod
Implementation details

Network

Layer model
Network communications

Data structures

  • Socket
    sk_buff
    Inet socket
    proto

Devices

  • Ethernet
    SLIP and PPP
    Loopback
    Dummy device

Protocols

Arp
IP

  • Functions
    Routing
    Multicasting
    Packet filters
    Accounting
    Firewalls

UDP

  • Standard and extra functions

TCP

  • Standard functions
    Communication details

SCSI Subsystem

Architecture overview
Names and conventions
Upper level
Block devices (hard disks, CD-ROM)
Character devices (Tape)
Generic drivers
Mid level (Boot parameters, proc interface)
Lower (Hardware) level and Pseudo drivers

Boot process

Booting details
LILO

  • Started by MBR
    Started by a boot manager
    Structure in the MBR

Files
Parameters
Start-up messages
Error messages

Debugging Tools

ptrace
SysRq
KDB
User Mode Linux
kgdb

Hands-on:

Day 1: Basic Kernel configuration, building and testing.
Day 2: Filesystem internals
Day 3: Implementing a new system call and integrating it in the Kernel
Day 4: Device driver development: design and implementation
Day 5: Making modules out of device drivers