Linux Debugging 1 - Kernel Introduction
来源:互联网 发布:sai mac下下来打不开 编辑:程序博客网 时间:2024/06/01 10:37
1. linux kernel version
Major.Minor.Release[extra]
Minor: Even minor numbers denote stable "production" kernel, whereas odd ones are reserved for development kernels.
API changes in the 2.6 kernel series refer to http://lwn.net/Articles/2.6-kernel-api/
解压kernel代码:
打补丁命令:
2. Linux Kernel的Feature
1) Implement generic UNIX kernel structure
2) Monolithic, thread kernel
3) user threads are LWP
4) kernel is preemptive (in 2.6)
5) small footprint
6) Modular and Extensible
3. 2.6的内核实现了抢占调度,抢占点在于:
- On return from Interrupt handlers
- On blocking Kernel calls
- when the Kernel preemption is reenabled (call preempt_enable)
- when a kernel thread voluntarily yields by calling schedule.
4. Schedulers
refer to : http://lwn.net/Articles/230574/
1) in 2.4 version, scheduler is O(n), while in 2.6 it is O(1), which is more efficient and provide natural CPU affinity. It has one runqueue per processor(每个CPU都有自己的runqueue), and each runqueue contains 2 priority arrays. And it use bitmap to find the highest priority task(进程或者线程) to run.
We can check the codes from LXR.
RT task priority is from 0 to 100, and normal task priority is from 101 to 139 (from sched.h)
调度算法(from sched.c)
看一下sched_find_first_bit的实现,常数时间即可选择出最小的不为0的bit,所以为O(1)调度算法。
问题:高优先级的任务总是先被调度,低优先级的任务无法被调度,starvation.
2) In 2.6.23 release, a CFS (Completely Fair Scheduler) is added, see this from wiki (http://en.wikipedia.org/wiki/Completely_Fair_Scheduler), and we can get more info from http://kerneltrap.org/node/8059
High priority tasks still get larger slices, but tasks are ordered by "vruntime", which means schedule cpu-starved threads first, low priority threads get their smaller slice but at least execute.
3) IO scheduler
2.6 kernel has 4 I/O schedulers, No-op I/O scheduler, Anticipatory I/O scheduler(default), Deadline I/O scheduler与CFQ I/O scheduler. In 2.4, use the "Linus Elevator" (No-op I/O scheduler).问题主要是“请求饥饿”。
5. Kernel Architecture
old system call is using "int $0x80", and 2.6 use "sysenter" and the syscall number is in EAX. see syscall_table.S
6. Devices
分类:字符设备(例如:内存,终端,IO ports,键盘,鼠标等), 块设备 (buffered) device(硬盘,闪存等).
例如: mknod /dev/testdev c 254 0创建一个字符设备,major号(the number of the device registered in the kernel)是254,minor号(the number of device registered in the driver)是0.
- Linux Debugging 1 - Kernel Introduction
- 《Linux Kernel Development》chapter 1 Introduction to Linux Kernel
- Linux Debugging 8 - Kernel Module
- Linux Kernel Testing and Debugging
- Introduction - Linux Kernel Crash Dump
- Debugging the Linux kernel with JTAG
- debugging the linux kernel under ubuntu 11.04
- Debugging Linux Kernel Lockup / Panic / Oops
- Debugging the Linux Kernel with debugfs
- Debugging Linux kernel code on Android platforms
- 《Understanding the Linux kernel》学习笔记 Chapter 1: Introduction
- Writing a Linux Kernel Module — Part 1: Introduction
- Debugging the kernel using Ftrace - part 1
- Kernel low-level debugging functions linux汇编的调试方法
- [MEMO] Linux Kernel Debugging Training 琐碎(补充ing)
- Tutorial: Debugging Linux Kernel with GDB under VirtualBox
- Debugging the linux kernel using kgdb and VirtualBox
- Kernel low-level debugging functions linux汇编的调试方法
- 继续转,DXperience换肤
- 今天……
- 求cass软件
- POJ2478 Farey Sequence 欧拉函数与素数 数论题
- oracle监听连接超时转移配置实例
- Linux Debugging 1 - Kernel Introduction
- 华为面试/笔试题目(附答案)
- 工作任务状态显示
- FFMPEG第三方库编译
- V8 JavaScript Engine 编译与使用注意事项-编译V8(win7+VS2008)
- 膨胀与腐蚀的组合(开运算与闭运算)
- 第一课android的介绍
- 关于“消抖”
- 单发点无权最短路径C语言