The Linux Kernel

From Wikibooks, the open-content textbooks collection

(Redirected from Linux kernel)
Jump to: navigation, search

Contents

[edit] Introduction

"The Linux Kernel" is intended to be the sequel to Updating the Linux kernel, going beyond user-level options and discussing details of interest to programmers.

[edit] System

System means general functions used to support and manage other kernel functionality. Synonym: infrastructure.

[edit] Booting and Halting

Booting


cat /proc/cmdline
arch/i386/boot/bootsect.S
arch/i386/kernel/head.S: calls start_kernel
In init/main.c:
start_kernel, rest_init, init, run_init_process

Halting and rebooting


sys_reboot calls machine_restart or machine_halt or machine_power_off

[edit] Userspace communication

syscall, /proc, /dev, /sys
linux/proc_fs.h
create_proc_entry etc

[edit] Devices

ls /dev
cat /proc/devices

[edit] Char devices

Chapter 13. I/O Architecture and Device Drivers

[edit] DMA

SAC Single Address Cycle

[edit] Modules

lsmod
cat /proc/modules

[edit] Hardware interfaces

[edit] I/O ports and registers

#include <asm/io.h>
#include <linux/io.h>
include/linux/ioport.h
inb,  outb etc

[edit] Hardware Device Drivers=

Hardware Device Drivers are different from char and block devices.

or just Device Drivers

Keywords: kobjects, sysfs, buses, devices, drivers, classes, firmware, hotplug

[edit] Busses: input, PCI, USB

Input bus: keyboard and mouse

cat /proc/bus/input/devices

PCI bus

pci_register_driver
lspci
cat /proc/pci
cat /proc/bus/pci/devices

USB bus

lsusb
cat /proc/bus/usb/devices

[edit] Debugging

oops

printk

linux/arch/i386/kernel/traps.c
dump_stack
show_registers
die
printk
cat /proc/kmsg
SysRq, SysInfo (C/A/S - Scrol Lock) keys

KDB (Built-in Kernel Debugger) Local debugging.

Other

KGDB Remote GDB debugging.

# gdb -q vmlinux
(gdb) target remote /dev/ttyS0

Loading a module file in gdb with kgdb 1.8 and earlier

[edit] Processing

Processing: from process to CPU Processes and Tasks

current task_struct
cat /proc/self/


Synchronization

semaphore
spinlock_t, timer_list, wait_queue_head_t

Time and Timers

jiffies, irq0, timer_interrupt, do_timer_interrupt


Interrupts

/proc/interrupts

Bottom Halves

IPC

ls /proc/sysvipc/

[edit] Memory

Memory: from sys_bkr, sys_mmap2 to RAM

http://linux-mm.org/LinuxMM
cat /proc/meminfo
include/linux/sched.h
mm_struct
#include <linux/mm.h>
#include <linux/malloc.h>
kmalloc,  kfree
#include <linux/vmalloc.h>
vmalloc, vfree
#include <asm/io.h>
ioremap, iounmap

Internal representation:

page at #include <linux/mm.h>

Cache

Documentation/cachetlb.txt

[edit] Storage

Storage: from file to hard disk

cat /proc/filesystems

VFS

See also: #NFS, #procfs, #sysfs

[edit] Block devices

[edit] Networking

Networking: from socket to network card

netif_rx


Data link layer and Ethernet

Transport layer and TCP

ls /proc/net/ 
socket @ include/linux/net.h

Application layer and NFS

ls /proc/fs/

[edit] See also

[edit] External links

Books (paper and ebooks):

Linux kernel based projects:

Historical books:

Embedded Linux references: using Linux in an Embedded Systems:

Personal tools
Create a book