linux内核空间申请超过2MB连续空间的实现函数。
/*
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 //apply more than one page
#define KMEM_DEBUG //debug message switch
/*
// Pure 2^n version of get_order
static __inline__ __attribute_const__ int get_order(unsigned long size)
{
int order;
size = (size - 1) >> (PAGE_SHIFT - 1);
order = -1;
do {
size >>= 1;
order++;
} while (size);
return order;
}
*/
/*
alloc memory for DMA using in kernel space.
*/
void *kmem_alloc(size_t size, dma_addr_t *dma_handle, unsigned long flags)
{
struct page *page; //start page address
void *cpu_addr = NULL; //cpu io address
struct page *end; //end of pages
unsigned int PageOrder=0;
size = PAGE_ALIGN(size); //must be times of 4KB
PageOrder=get_order(size);
#ifdef CONFIG_ISOLATE_HIGHMEM //allocate in high memory
page = alloc_pages(GFP_HIGHUSER, PageOrder);
#else //allocate from low memory
page = alloc_pages(GFP_KERNEL, PageOrder); //get_order(size) means how many 4KB page do you want to apply. 2^n
#end
相关文档:
例一:发送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 ......
如何在linux下查看当前登录的用户,并且踢掉你认为应该踢掉的用户?
看了网络中的一些例子.在这里总结一下.主要用到的命令有,w,who,ps,kill,pkill
查看当前登录用户:
node8:/home # who
root :0 2009-11-04 16:26
root pts/0 &n ......
转来的,没事可以看看
bin = BINaries
/dev = DEVices
/etc = ETCetera
/lib = LIBrary
/proc = PROCesses
/sbin = Superuser BINaries
/tmp = TeMPorary
/usr = Unix Shared Resources
/var = VARiable ?
FIFO = First In, First Out
GRUB = GRand Unified Bootloader
IFS = Internal Field Seperators
LILO ......
六:kmem_cache_alloc的实现分析:
我们在上面可以看到,创建一个cache描述符的时候,并没有这之分配slab数据。现在我们来看一下怎么从cache中申请对象
void * kmem_cache_alloc (kmem_cache_t *cachep, int flags)
{
return __cache_alloc(cachep, flags);
}
实际上会调用__cache_allo ......
一、要求:
1、能够显示出Makefile的总数
2、能显示一级目录下的Makefile总数、Makefile列表及其Makefile的内容
3、能将上述内容写入相应的文件
二、实例
rm -rf ~/Desktop/linux_Makefile/*
for i in `find . -maxdepth 1 -type d`
#仅仅是当前目录,所以请将本脚本放在linux源码目录下执行。
do
e ......