Linux kernel development Chapter2 进程管理
1 进程管理相关代码
1.1 thread_info结构,在文件<asm/thread_info.h>中定义
struct thread_info {
struct task_struct *task;
struct exec_domain *exec_domain;
unsigned long flags;
__u32 cpu;
__s32 preempt_count;
mm_segment_t addr_limit;
u8 supervisor_stack[0];
};
每个任务的thread_info结构在其内核栈顶端分配,其task域指向该任务的事件task_struct结构。
1.2 任务队列(task list)
双向循环链表,链表每一项都是一个task_struct(定义在include/linux/sched.h中),该进程描述符包含了一个仅进程的所有信息。
1.3 slab
linux通过slab机制分配task_struct结构,以达到对象复用和缓存着色的目的。
1.4 pid
linux通过pid(pid_t类型,integer)来标示每一个任务进程。为了与老版本unix和linux兼容,pid最大值为32767.如果需要更多进程,可以通过
修改/proc/sys/kernel/pid_max来提高上限。
1.5 current宏
current宏用于查找当前正在运行进程的进程描述符。不同的硬件体系结构的实现不同。
在x86架构中,寄存器不多,不能使用专门的寄存器指向当前进程的task_struct.它的方式是通过在内核栈顶端创建thread_info结构,间接的
查找task_struct结构:
(1)通过屏蔽栈指针(esp)的后13个有效位获得thread_info结构,在current_thread_info()函数完成:
&n
相关文档:
例一:发送Signaling Packet:
Signaling Command是2个Bluetooth实体之间的L2CAP层命令传输。所以得Signaling Command使用CID 0x0001.
多个Command可以在一个C-frame(control frame)中发送。
如果要直接发送Signaling Command.需要建立SOCK_RAW类型的L2CAP连接Socket。这样才有机会自己填充Command Code,Identi ......
sys_execve
| - do_execve
|
| - search_binary_handler
|- linux_binfmt= elf_format
|- elf_format-> load_elf_binary
| -&nbs ......
/*
kmalloc can apply 128KB memory only. This func support any continous memory allocate more than 2MB.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kallsyms.h>
#define KMEM_PAGES &nb ......
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
A:link { so-language: zxx }
-->
一个
Linux
发行版,体积很小,用处反而很大。此话当真?
一般而言,老式计算机内存都不大, ......
<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@宋体" ......