LinuxÄÚ´æ¹ÜÀíÖ®slab·ÖÅäÆ÷·ÖÎö(ÐøÈý)
Áù£ºkmem_cache_allocµÄʵÏÖ·ÖÎö:
ÎÒÃÇÔÚÉÏÃæ¿ÉÒÔ¿´µ½£¬´´½¨Ò»¸öcacheÃèÊö·ûµÄʱºò£¬²¢Ã»ÓÐÕâÖ®·ÖÅäslabÊý¾Ý¡£ÏÖÔÚÎÒÃÇÀ´¿´Ò»ÏÂÔõô´ÓcacheÖÐÉêÇë¶ÔÏó
void * kmem_cache_alloc (kmem_cache_t *cachep, int flags)
{
return __cache_alloc(cachep, flags);
}
ʵ¼ÊÉÏ»áµ÷ÓÃ__cache_alloc
ÈçÏ£º
static inline void * __cache_alloc (kmem_cache_t *cachep, int flags)
{
unsigned long save_flags;
void* objp;
struct array_cache *ac;
//Èç¹û¶¨ÒåÁË__GFP_WAIT¡£¿ÉÄÜ»áÒýÆð˯Ãß
cache_alloc_debugcheck_before(cachep, flags);
local_irq_save(save_flags);
//È¡µÃµ±Ç°´¦ÀíÆ÷ËùÔÚµÄarray_cache(¼ò³ÆΪAC£¬ÎÒÃÇÏÂÃæÒ²ÕâÑù³ÆºôËü)
ac = ac_data(cachep);
//ac->avail:ACÖеںóÒ»¸ö¿ÉÓõĶÔÏóË÷Òý
//Èç¹ûACÖл¹ÓпÉÓõĶÔÏó
if (likely(ac->avail)) {
STATS_INC_ALLOCHIT(cachep);
//ÿ´Î·ÖÅ䶼»á°Ñac->touchedÖÃΪ1
ac->touched = 1;
objp = ac_entry(ac)[--ac->avail];
} else {
//Èç¹ûACÖÐûÓпÉÓöÔÏó£¬ÄÇÖ»ÄÜ´Ól3ÖГ°á³ö”¶ÔÏóµ½ACÖÐ
STATS_INC_ALLOCMISS(cachep);
objp = cache_alloc_refill(cachep, flags);
}
local_irq_restore(save_flags);
objp = cache_alloc_debugcheck_after(cachep, flags, objp, __builtin_return_address(0));
return objp;
}
Ê
Ïà¹ØÎĵµ£º
1¡¢¼òµ¥²âÊÔʵÀý
for i in `find . -type f -name "*.c"`
do
echo $i
basename $i »ñÈ¡*.cÎļþÃû
dirname $i »ñÈ¡*.c¶ÔÓ¦µÄĿ¼Ãû
done
2¡¢Êµ¼ÊÓ¦ÓÃ
diff LinuxÔ´Â룬²¢½«Óв»Ò»ÑùµÄÔ´ÂëÕûÀíÔÚÒ»Æð£¬ÒªÇó£ºÎļþ ......
ÍøÉÏÕÒÁ˺ܶ࣬Õâ¸ö×îÓÐЧ£¬×ªÔØÏÂ
ÏÂÔسɹ¦ºóÉÏ´«ÖÁ·þÎñÆ÷ÈÎÒâĿ¼
2. ÔÚµ±Ç°Ä¿Â¼ÊäÈë
sh jdk-6u2-linux-i586-rpm.bin
3.¿´µ½ °²×°³ÌÐòÔÚѯÎÊÄúÊÇ·ñ×ðÊØÐí¿ÉÐÒéÒ³Ãæ ,»Ø³µ ......
ÔÚLinuxÏÂÓÃbuildroot´î½¨mips/armµÄ½»²æ±àÒëƽ̨
Õâ¸ö±àÒë»·¾³ÊDz»ÄܱàÒëfor¿ªÔ´ÎÞÏß·ÓÉÆ÷µÄ³ÌÐòµÄ£¬ÒòΪÄÚºËÊÇ2.6µÄ
½¨Òé²Î¿¼Õâƪ: http://www.felix021.com/blog/read.php?1467
Ç°Á½ÌìÂòÁËNetGear WRT614 V9£¬´îÔصÄÊÇBroadcomµÄ200MHz MIPS´¦ÀíÆ÷¡£
ÓÉÓÚʹÓõÄÊÇ¿ªÔ´²Ù×÷ϵͳLinux£¬ËùÒÔ¿ÉÒÔË¢ÍøÉÏһЩNBµÄ ......
Î壺kmem_cache_create£¨£©·ÖÎö
ÎÒÃÇÒÔÒ»¸öÀý×ÓÀ´¸ú×Ù·ÖÎöÒ»ÏÂslabµÄ»úÖÆ£º
ÏÂÃæÊÇÒ»¸ö²âÊÔÄ£¿éµÄ´úÂ룺
#include <linux/config.h>
#include <linux/module.h>
#include <linux/slab.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("ericxiao <xgr178@163.com>");
MODULE_DESCRI ......