由于Linux驱动程序在内核中运行,因此在设备驱动程序需要申请/释放内存时,不能使用用户级的malloc/free函数,而需由内核级的函数kmalloc/kfree () 来实现,kmalloc()函数的原型为: void kmalloc (size_t size ,int priority); 参数size为申请分配内存的字节数,kmalloc最多只能开辟128k的内存;参数priority说明若kmalloc()不能马上分配内存时用户进程要采用的动作:GFP_kernel 表示等待,即等kmalloc()函数将一些内存安排...
by gaofei8530 - Linux文档专区 - 2009-09-10 10:39:22 阅读(895) 回复(0)
分析kernel的initcall函数 Author: Dongas Data: 08-07-15 先来看看这些initcall函数的声明: /* include/linux/init.h */ /* initcalls are now grouped by functionality into separate * subsections. Ordering inside the subsections is determined * by link order. * For backwards compatibility, initcall() puts the call in * the device init subsection. */ #define __define_initcall(level,fn) \ ...
请问内核下开线程函数kernel_thread如果在软中断中开辟一个线程 那么这个线程属于软中断的一部分吗? 我现在在软中断中要访问一个队列 而这个在软中断中由kernel_thread开辟的线程中也要访问这个队列 这就涉及到加锁的问题,不知道这个线程属于那部分就没有办法知道加什么锁,请知道的朋友赐教
请问内核下开线程函数kernel_thread如果在软中断中开辟一个线程 那么这个线程属于软中断的一部分吗? 我现在在软中断中要访问一个队列 而这个在软中断中由kernel_thread开辟的线程中也要访问这个队列 这就涉及到加锁的问题,不知道这个线程属于那部分就没有办法知道加什么锁,请知道的朋友赐教
分析kernel的initcall函数 Author: Dongas Data: 08-07-15 先来看看这些initcall函数的声明: /* include/linux/init.h */ /* initcalls are now grouped by functionality into separate * subsections. Ordering inside the subsections is determined * by link order. * For backwards compatibility, initcall() puts the call in * the device init subsection. */ #define __define_initcall(level,fn) \ ...
asmlinkage void __init start_kernel(void) { char * command_line; extern struct kernel_param __start___param[], __stop___param[]; /* * Interrupts are still disabled. Do necessary setups, then * enable them */ lock_kernel(); 如果内核配置成支持抢占,那么在这里禁止抢占,将0号进程的init_thread_info.preempt_count加1; 如果配置成不支持抢占,那么内核全局自选锁kernel_flag上锁。 page_address_init();...
asmlinkage void __init start_kernel(void) { char * command_line; extern struct kernel_param __start___param[], __stop___param[]; /* * Interrupts are still disabled. Do necessary setups, then * enable them */ lock_kernel(); 如果内核配置成支持抢占,那么在这里禁止抢占,将0号进程的init_thread_info.preempt_count加1; 如果配置成不支持抢占,那么内核全局自选锁kernel_flag上锁。 page_address_init();...
下面将介绍start_kernel关于每个内存初始化函数。 在内核启动函数中,使用全局变量kernel_param即内核参数,同时调用了下面的内存初始化函数: page_address_init()//这个函数初始化页地址,使用链表将其链接起来。 setup_arch()//内存初始化,这个函数是相当重要的,下面将详细地对这个函数进行功能上的总结。 这个函数设置了cpu引导数据,对前期CPU数据进行了初始化,以及对一些硬件数据进行了设...
asmlinkage void __init start_kernel(void) { char * command_line; extern struct kernel_param __start___param[], __stop___param[]; /* * Interrupts are still disabled. Do necessary setups, then * enable them */ lock_kernel(); 如果内核配置成支持抢占,那么在这里禁止抢占,将0号进程的init_thread_info.preempt_count加1; 如果配置成不支持抢占,那么内核全局自选锁kernel_flag上锁。 page_address_init(); ...
不管本地发送的还是转发的都将调用xfrm_lookup()。 xfrm_lookup() -> __xfrm_lookup() -> xfrm_sk_policy_lookup()查找策略,如果策略的action为XFRM_POLICY_ALLOW则 -> xfrm_find_bundle()查找是否存在bundle, 否则 -> xfrm_tmpl_resolve() -> xfrm_tmpl_resolve_one() -> xfrm_state_find() -> km_query() -> km->acquire()实际调用的是pfkey_send_acquire()通过PF_KEY2向应用层请求协商SA信息 xfrm_bundle_create() 经过处理后...