Linux kernel structure - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Linux kernel structure

Description:

Kernel code structure How it boots itself All the system calls are available System is configured Process handling is available – PowerPoint PPT presentation

Number of Views:45
Avg rating:3.0/5.0
Slides: 20
Provided by: TomN154
Learn more at: https://ece.uprm.edu
Category:

less

Transcript and Presenter's Notes

Title: Linux kernel structure


1
Linux kernel structure
  • Kernel code structure
  • How it boots itself
  • All the system calls are available
  • System is configured
  • Process handling is available

2
The kernel code
  • Obtaining it
  • Information at www.kernel.org
  • ftp ftp.pr.kernel.org
  • Usually it is in/usr/src various directories
  • Most recent stable version is 2.4.19
  • What it contains
  • The source code that compiles and links into a
    bootable system
  • The compressed version is vmlinuz
  • It contains all the openly available device
    drivers
  • Future drivers appear in future versions or can
    be compiled in the current version
  • Makefiles for automated configuration

3
structure
  • Major directories
  • Arch architecture-dependent
  • Documentation read these
  • Drivers all except network
  • Fs the file system
  • Include includes of multiple use
  • Init from boot to running kernel
  • Ipc IPC
  • Kernel the kernel structures
  • Lib libraries for the kernel
  • Mm memory management
  • Net the network code

4
More structure
  • The auxiliary files
  • Makefile and rules
  • These explain quite a bit about kernel structure
  • Note this makefile activates the others in each
    subdirectory
  • README
  • How to compile
  • Others
  • Casual reading how Linux gets developed

5
Linux is ported to these architectures
6
View of the i386 arch area
7
Contents of lib for the i386
  • Comments
  • The .S are assembly language GNU, not Microsoft
  • Note the individual makefile
  • General utilities, as you would expect

8
The makefile for lib
  • Notes
  • The CONFIG shell variables come from the make
    config step
  • Rules.make is used
  • The .S.o rule does assembly instead of
    compilation because of the (AFLAGS) argument

Makefile for i386-specific library
files..   .S.o (CC) (AFLAGS) -c lt -o
.o   L_TARGET lib.a   obj-y checksum.o
old-checksum.o delay.o \ usercopy.o getuser.o
\ memcpy.o strstr.o   obj-(CONFIG_X86_USE_3DNOW)
mmx.o obj-(CONFIG_HAVE_DEC_LOCK)
dec_and_lock.o obj-(CONFIG_DEBUG_IOVIRT)
iodebug.o   include (TOPDIR)/Rules.make
9
A sample of GNU assembler
/ unsigned int csum_partial(const unsigned char
buff, int len, unsigned int sum)
/ .text .align 4 .globl csum_partial pus
hl esi pushl ebx movl 20(esp),eax
Function arg unsigned int sum movl
16(esp),ecx Function arg int len movl
12(esp),esi Function arg unsigned char
buff testl 2, esi Check alignment. jz
2f Jump if alignment is ok. subl 2, ecx
Alignment uses up two bytes. jae 1f Jump if
we had at least two bytes. addl 2, ecx ecx
was lt 2. Deal with it. jmp 4f
10
Some recognizable parts of kernel
  • Notes
  • This is the i386-specific part of kernel
  • Note semaphore.c smp.c signal.c
  • Some of these files will show up in the
    arch-independent part also

11
Tiny piece of kernel code from mm
if CONFIG_HIGHMEM pte_t kmap_pte pgprot_t
kmap_prot   define kmap_get_fixmap_pte(vaddr)
\ pte_offset(pmd_offset(pgd_offset_k(vaddr),
(vaddr)), (vaddr))   void __init
kmap_init(void) unsigned long
kmap_vstart   / cache the first kmap pte
/ kmap_vstart __fix_to_virt(FIX_KMAP_BEGIN)
kmap_pte kmap_get_fixmap_pte(kmap_vstart)   km
ap_prot PAGE_KERNEL endif / CONFIG_HIGHMEM
/
12
The contents of fsThis shows all the file
systems supported by Linux
13
The non-architecture-dependentroutines of the
kernel
14
The driver repertoire in general
15
The block device driversnote paride contains
the IDE drivers
16
A few of the char drivers
17
Comments - drivers
  • Block device drivers
  • All the common block devices these include
    disks and anything else that is block-oriented
  • Character device drivers
  • These include the character-by-character devices
    also some pseudo-devices
  • Note these are architecture-independent

18
Some things that arent in the kernel
  • Anything that isnt in vmlinuz
  • Examples
  • Init it reads /etc/inittab and starts all those
    processes
  • Startup scripts these are called up by init
    using inittab
  • Libraries and most network daemons
  • The kernel and the distribution are different
  • The distribution contains utilities and libraries
    for users
  • It contains the system installation utilities
  • Typical distributions are RedHat, Slackware, Suse
  • X-windows is part of the distribution or
    separately downloadable

19
Some techniques for viewing the kernel
  • This is W2K and WXP
  • Obviously the kernel wont compile here, but it
    makes nice slides
  • Open with permits viewing makefiles, etc.
  • Documentation directory contains .txt files
  • Set the .txt association to word, not notepad
  • Viewing in Linux is a little easier
  • The usual gui lets you view the filesystem
    treewise
  • Clicking on individual .c, .h, .s, etc
    immediately displays the file in editor (emacs)
  • Learn to use grep and fgrep to find out where
    structures, etc. are defined
  • Learn to use du (disk usage) to get an idea of
    the size of the kernel
Write a Comment
User Comments (0)
About PowerShow.com