|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
初学阶段只要把上课时候学习过的命令练熟就可以了.单靠学习各种命令而成为高手是不可能的。
*kmalloc
Prototype:
#include<linux/slab.h>
void*kmalloc(size_tsize,intflags);
Kmalloc分派一段未清0的一连物理内存页,并前往虚存地点。有点是快,而且可指定flag,如DMA内存,洼地址地区内存等。弱点是不克不及分派年夜于128KB(处于跨平台思索),几个主要的flag:
GFP_ATOMIC
Usedtoallocatememoryfrominterrupthandlersandothercodeoutsideofaprocesscontext.Neversleeps.
GFP_KERNEL
Normalallocationofkernelmemory.Maysleep.
GFP_USER
Usedtoallocatememoryforuser-spacepages;itmaysleep.
GFP_HIGHUSER
LikeGFP_USER,butallocatesfromhighmemory,ifany.Highmemoryisdescribedinthenextsubsection.
*slaballocator(lookasidecache)
从Memcached的完成晓得有这么一个内存办理战略,其光鲜明显特性是分派一组不异巨细的内存块作为内存池,实在现对应于源代码中的<linux/slab.h>和mm/slab.c。
Prototype:
#include<linux/malloc.h>
kmem_cache_t*kmem_cache_create(char*name,size_tsize,size_toffset,
unsignedlongflags,constructor(),destructor());
intkmem_cache_destroy(kmem_cache_t*cache);
/proc/slabinfo
Avirtualfilecontainingstatisticsonslabcacheusage.
*__get_free_pages
Prototype:
__get_free_pages(unsignedintflags,unsignedintorder);
前往2^order个未清0一连物理页面,flags与kmalloc中flags分歧,同意的最年夜order值为10大概11(依据系统布局分歧)
*alloc_pages
Prototype:
structpage*alloc_pages_node(intnid,unsignedintflags,
unsignedintorder);
Kernel中页分派器完成,__get_free_pages即挪用alloc_pages完成的
TherealcoreoftheLinuxpageallocatorisafunctioncalledalloc_pages_node:
*vmalloc
分派地点一连虚存,而不包管物理地点一连,年夜部分情形下合适“软件”,而不是驱动程序。绝对而言,kmalloc和__get_free_pages虚存map到物理内存只必要增减一个偏移,而利用vmalloc分派必要修正页表,故vmalloc的开支较年夜,分派多数几个页面的效力太低。
*per-cpuvariables
Eachcpuholdanindependantcopyintheirrespectiveprocessorscaches,sothereisnolockrequiredandimprovebetterperformance,implementedasalinux2.6feature.Definedin<linux/percpu.h>.
DEFINE_PER_CPU(type,name);
get_cpu_var(sockets_in_use)++;
put_cpu_var(sockets_in_use);
</p>
无论图形界面发展到什么水平这个原理是不会变的,Linux命令有许多强大的功能:从简单的磁盘操作、文件存取、到进行复杂的多媒体图象和流媒体文件的制作。 |
|