函数杂七杂八

vsnprintf()函数
int vsnprintf (char *s, size_t size, const char *template, va_list ap)
本函数跟snprintf函数很类似,只是将参数的数目可变的,变成了一个指针的列表。

 

va_list   ap;                   //声明一个变量来转换参数列表   
va_start(ap,fmt);               //初始化变量   
va_end(ap);                     //结束变量列表,和va_start成对使用   
可以根据va_arg(ap,type)取出参数

 

创建kernel thread时调用allow_signal指定它响应什么信号;

 

kmalloc()

       1. 以字节为单位进行分配,在<linux/slab.h>

       2. void *kmalloc(size_t size, int flags) 分配的内存物理地址上连续,虚拟地址上自然连续

       3. gfp_mask标志:什么时候使用哪种标志?如下:

              ----------------------------------------------------------------------------------------------

              情形                                                        相应标志

              ----------------------------------------------------------------------------------------------

              进程上下文,可以睡眠                     GFP_KERNEL

              进程上下文,不可以睡眠                  GFP_ATOMIC

              中断处理程序                                   GFP_ATOMIC

              软中断                                              GFP_ATOMIC

              Tasklet                                              GFP_ATOMIC

              用于DMA的内存,可以睡眠            GFP_DMA | GFP_KERNEL

              用于DMA的内存,不可以睡眠        GFP_DMA | GFP_ATOMIC

              ----------------------------------------------------------------------------------------------

       4. void kfree(const void *ptr)

              释放由kmalloc()分配出来的内存块

vmalloc()

       1. 以字节为单位进行分配,在<linux/vmalloc.h>

       2. void *vmalloc(unsigned long size) 分配的内存虚拟地址上连续,物理地址不连续

       3. 一般情况下,只有硬件设备才需要物理地址连续的内存,因为硬件设备往往存在于MMU之外,根本不了解虚拟地址;但为了性能上的考虑,内核中一般使用kmalloc(),而只有在需要获得大块内存时才使用vmalloc(),例如当模块被动态加载到内核当中时,就把模块装载到由vmalloc()分配的内存上。

       4.void vfree(void *addr),这个函数可以睡眠,因此不能从中断上下文调用。

 

You need to separate the declaration of your struct from the declaration of a variable of that struct type. As written, your struct has no name, so it is impossible to refer to it.

In the .h

Code:
struct foo {
  int member;
};
extern struct foo eQ1;

In ONE .c file only

Code:
#include "myheader.h"
struct foo eQ1;

In all other .c files which use it

Code:
#include "myheader.h"
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值