Sei sulla pagina 1di 32

Trace Kernel Source

Advanced Operating Systems


2009

RTLab

Outline

Linux Kernel
Android Linux Kernel

RTLab

Outline

Linux Kernel
Android Linux Kernel

RTLab

Linux Features

Free
Open system
Open source
GNU GPL (General Public License)
POSIX (Portable Operating System Interface) standard
High portability
High performance
Robust
Large development toolset
Large number of device drivers
Large number of application programs

RTLab

Features (Cont.)

Multi-user
allows several users to work on the same machine at the same
time
Multi-process/Multi-processors
more than one program can be executed at a time, whether using
one or several processors
Virtual memory
Loadable kernel modules
Networking
Shared libraries
Support different file systems
Support different executable file formats
Support different networking protocols
Support different architectures
RTLab

Kernel

System call interface kernel

Process control
Memory management

File system management


I/O ,
Device drivers

RTLab

Linux Kernel Architecture

User View of Linux Operating System


Linux Kernel Architecture
Kernel Source Code Organization

RTLab

User View of Linux Operating System


Applications
Shell
Kernel

Hardware

RTLab

System Structure
Processes

System calls interface

File systems
ext2fs

xiafs

proc

minix

nfs

msdos

Central kernel

iso9660

Buffer Cache
Peripheral managers
block

Task management
Scheduler
Signals
Loadable modules
Memory management

Network Manager

character

ipv4
ethernet
...

sound card cdrom isdn


netwo
scsi
pci
rk

Machine interface

Machine
RTLab

Original UNIX System Structure


(the users)

(2)

(1)

system
programs

kernel

shells and commands


compilers and interpreters
system libraries
system-call interface to the kernel
signals
terminal
Handling

file system CPU scheduling


swapping page replacement

char I/O syst. block I/O syst. demand paging


terminal disk and tape
virtual
drivers
drivers
memory
kernel interface to the hardware
hardware

terminal controllers device controllers memory controllers


terminals
RTLab

devices and tapes

physical memory
10

Linux Kernel Architecture

RTLab

11

Analysis of Linux Kernel Architecture

Stability
Safety
Speed
Brevity
Compatability
Portability
Reusability and modifiability
Monolithic kernel vs. microkernel
Linux takes the advantages of monolithic kernel
and microkernel
RTLab

12

Kernel Source

Source code web site:

http://www.kernel.org
latest stable version

Source code version:

http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.31.tar.bz2

X.Y.Z
2.6.31

Distributions:

ftp://linux.cis.nctu.edu.tw/distributions/
RED HAT, Ubuntu, Fedora, Debian, Mandriva

RTLab

13

Source Code Organization

init
ipc
lib
mm
kernel
net
fs
include
arch
drivers

RTLab

14

Outline

Linux Kernel
Android Linux Kernel

RTLab

15

RTLab

16

AndroidKernel - 1

Gold-Fish

Yaffs2 FLASH file system

Goldfish: a virtual CPU that Android emulator runs


Goldfish executes ARM926T instructions and has
hooks for input and output
Yet Another Flash File System, 2nd edition

New Android Functionality

RTLab

17

AndroidKernel - 2

Bluetooth
Scheduler

Slight changes to the CPU process scheduler and


time-keeping algorithms

Binder (IPC)
Low Memory Killer
Ashmem

Anonymous SHared MEMory system


Interfaces so processes can share named blocks
of memory
RTLab

18

AndroidKernel - 3

Debugging

New Real-Time Clock

RAM Console and Log Device


Android Debug Bridge
Switch support
Timed GPIO support

Power Management

RTLab

19

Resource

Android Open Source Project

http://source.android.com/download

WebGit

http://android.git.kernel.org/

RTLab

20

Project

Description

bionic

C runtime: libc, libm, libdl, dynamic linker

bootloader/legacy

Bootloader reference code

build

Build system

dalvik

Dalvik virtual machine

development

High-level development and debugging tools

frameworks/base

Core Android app framework libraries

frameworks/policies/base

Framework configuration policies

hardware/libhardware

Hardware abstraction library

hardware/ril

Radio interface layer

kernel

Linux kernel

prebuilt

Binaries to support Linux and Mac OS builds

recovery

System recovery environment

system/bluetooth

Bluetooth tools

system/core

Minimal bootable environment

system/extras

Low-level debugging/inspection tools

system/wlan/ti

TI 1251 WLAN driver and tools

http://source.android.com/projects

RTLab

21

Resources for Tracing Linux

GNU Global source code tag system


http://www.gnu.org/software/global/
support C, C++, Yacc, Java and PHP4
find the locations of a specified object quickly.
locate not only object definitions but also object
references.
allows duplicate objects.
locate also path which includes specified pattern.

RTLab

22

Resources for Tracing Linux


LXR
Source code navigator
http://lxr.linux.no/source/
function, struct, macro
E-Books

KernelAnalysis-HOWTO:

http://www.linux.org/docs/ldp/howto/KernelAnalysisHOWTO.html

The Linux Kernel:

http://www.tldp.org/LDP/tlk/tlk.html

RTLab

23

Resources for Tracing Linux


Linux Kernel 2.4 Internals:
http://www.moses.uklinux.net/patches/lki.html
LinuxHQ:
http://www.linuxhq.com
Books
Understanding the Linux Kernel, 3/e

Daniel P. Bovet, Marco Cesati


O'Reilly & Associates.

Linux Core Kernel Commentary

In-Depth Code Annotation, S. Maxwell, Coriolis Open Press, 1999.

RTLab

24

Resources for Tracing Linux

The Linux Kernel, Version 0.8-3, D. A Rusling, 1998.


Linux Kernel Internals, 2nd edition, M. Beck et al., AddisonWesley, 1998.
Linux Kernel, R. Card et al., John Wiley & Sons, 1998.
Linux Device Drivers, 2nd Edition: OReilly/()
Linux :

Windows
UltraEdit

RTLab

25

Resources for Tracing Linux

VisualStudio
Source Browser, find in files

Unix

grep: grep [option] pattern [file]

ctags: find -name *.[ch] | xargs ctags

tags

cflow: cflow r fun_name *.c

ex : grep ri return rtlcore.c

call graph

c2html: c2html < file.c > file.html

RTLab

26

Resources for Tracing

Source code browser

Cscope
http://cscope.sourceforge.net/

KScope

http://kscope.sourceforge.net/sshots.shtml

Source Insight

http://www.sourceinsight.com/

RTLab

27

KScope - Screenshots 1

RTLab

28

KScope - Screenshots 2

RTLab

29

KScope - Screenshots 3

RTLab

30

Source Insight - Screenshots

RTLab

31

Thank You!

RTLab

32

Potrebbero piacerti anche