230 likes | 439 Views
Trace Linux Kernel Source. Operation System. Outline. Introduction Reference Trace tool Presentation. Features. Free Open system Open source GNU GPL (General Public License) POSIX standard High portability High performance Robust Large development toolset
E N D
Trace Linux Kernel Source Operation System
Outline • Introduction • Reference • Trace tool • Presentation
Features • Free • Open system • Open source • GNU GPL (General Public License) • POSIX standard • High portability • High performance • Robust • Large development toolset • Large number of device drivers • Large number of application programs
(the users) shells and commands compilers and interpreters System Structure system libraries system programs (2) system-call interface to the kernel signals file system CPU scheduling terminal swapping page replacement Handling kernel (1) char I/O syst. block I/O syst. demand paging terminal disk and tape virtual drivers drivers memory kernel interface to the hardware memory controllers device controllers terminal controllers hardware terminals devices and tapes physical memory
Linux System • kernel : 負責管理及維護系統, 如 memory management, process management • system library: 提供函式給應用程式使用,使其可以與kernel溝通,實作系統功能 • system utility: 負責某些特殊的管理工作,如 接收終端機的登入要求
Kernel Role • System call interface :使用者程式與 kernel 溝通的介面 • Process control :系統程序控制中心 • Memory management :控制整個系統的記憶體管理; • File system management :檔案系統的管理,例如 I/O 等等,還有不同檔案格式的支援 • Device drivers
Linux • Linux OS 取得方式 • ftp://linux.cis.nctu.edu.tw/distributions/iso • RED HAT , Debian, Mandrake…
Outline • Introduction • Kernel Source • Reference • Trace tool • Presentation
Kernel Source • 目標 Linux-2.6.2/i386 • 取得方式 ftp://ftp.tw.kernel.org/linux/kernel/v2.6/linux-2.6.2.tar.gz
內容 • init • ipc • lib • mm • kernel • net • fs
內容(Con.) • include • arch • driversDocument 中有不少文件
System call • system call 是 process 傳送給kernel的要求,使得process 可以轉換至kernel mode • 參照arch/i386/kernel/traps.c:987 • set_system_gate(0x80,&system_call); • 以攔截 software interrupt 0x80來切入kernel mode並呼叫system_call() • 參照arch/i386/kernel/entry.S:210 • 作一些基本檢查之後 • call *SYMBOL_NAME(sys_call_table) (,%eax,4)
Outline • Introduction • Kernel Source • Reference • Trace tool • Presentation
線上書籍 • KernelAnalysis-HOWTO: • http://www.linux.org/docs/ldp/howto/KernelAnalysis-HOWTO.html • The Linux Kernel: • http://www.tldp.org/LDP/tlk/tlk.html • Linux Kernel 2.4 Internals: • http://www.moses.uklinux.net/patches/lki.html • LinuxHQ: • http://www.linuxhq.com
實體書籍 • Understanding the Linux Kernel, 2nd Edition: • O‘Reilly • Linux Device Drivers, 2nd Edition: • O’Reilly/歐萊禮(中文) • Linux Core Kernel – Commentary, In-Depth Code Annotation, S. Maxwell, Coriolis Open Press, 1999. • The Linux Kernel, Version 0.8-3, D. A Rusling, 1998. • Linux Kernel Internals, 2nd edition, M. Beck et al., Addison-Wesley, 1998. • Linux Kernel, R. Card et al., John Wiley & Sons, 1998 • Linux 核心研究篇: • 學貫
Outline • Introduction • Kernel Source • Reference • Trace tool • Presentation
trace工具 • Cross-Referencing Linux:http://lxr.linux.no/source/ • function, struct, macro都直接有hyperlink • Windows下工具 • UltraEdit • 基礎工具 • VisualStudio • Source Browser, find in files
trace工具(Con.) • Unix下工具 • grep: “grep [option] …pattern… [file] ” • ex : grep –ri return rtlcore.c • 無敵的指令,雖然可能找很久 • ctags: “find -name ‘*.[ch]’ | xargs ctags” • 這樣檔案tags裡就有各種關鍵字的索引了 • cflow: “cflow –r fun_name *.c” • 產生call graph • c2html: “c2html < file.c > file.html”
trace工具(Con.) • 結構圖繪制工具 • Jude • http://objectclub.esm.co.jp/Jude/
Outline • Introduction • Kernel Sourc • Reference • Trace tool • Presentation
Presentation • 基礎知識介紹 • 主要的 data structure • 重要的 function • related system call • 版本比較