亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? malloc.c

?? linux1.1源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* * malloc.c --- a general purpose kernel memory allocator for Linux. * * Written by Theodore Ts'o (tytso@mit.edu), 11/29/91 * * This routine is written to be as fast as possible, so that it * can be called from the interrupt level. * * Limitations: maximum size of memory we can allocate using this routine *	is 4k, the size of a page in Linux. * * The general game plan is that each page (called a bucket) will only hold * objects of a given size.  When all of the object on a page are released, * the page can be returned to the general free pool.  When kmalloc() is * called, it looks for the smallest bucket size which will fulfill its * request, and allocate a piece of memory from that bucket pool. * * Each bucket has as its control block a bucket descriptor which keeps * track of how many objects are in use on that page, and the free list * for that page.  Like the buckets themselves, bucket descriptors are * stored on pages requested from get_free_page().  However, unlike buckets, * pages devoted to bucket descriptor pages are never released back to the * system.  Fortunately, a system should probably only need 1 or 2 bucket * descriptor pages, since a page can hold 256 bucket descriptors (which * corresponds to 1 megabyte worth of bucket pages.)  If the kernel is using * that much allocated memory, it's probably doing something wrong.  :-) * * Note: kmalloc() and kfree() both call get_free_page() and free_page() *	in sections of code where interrupts are turned off, to allow *	kmalloc() and kfree() to be safely called from an interrupt routine. *	(We will probably need this functionality when networking code, *	particularily things like NFS, is added to Linux.)  However, this *	presumes that get_free_page() and free_page() are interrupt-level *	safe, which they may not be once paging is added.  If this is the *	case, we will need to modify kmalloc() to keep a few unused pages *	"pre-allocated" so that it can safely draw upon those pages if * 	it is called from an interrupt routine. * * 	Another concern is that get_free_page() should not sleep; if it *	does, the code is carefully ordered so as to avoid any race *	conditions.  The catch is that if kmalloc() is called re-entrantly, *	there is a chance that unecessary pages will be grabbed from the *	system.  Except for the pages for the bucket descriptor page, the *	extra pages will eventually get released back to the system, though, *	so it isn't all that bad. *//* I'm going to modify it to keep some free pages around.  Get free page   can sleep, and tcp/ip needs to call kmalloc at interrupt time  (Or keep   big buffers around for itself.)  I guess I'll have return from   syscall fill up the free page descriptors. -RAB *//* since the advent of GFP_ATOMIC, I've changed the kmalloc code to   use it and return NULL if it can't get a page. -RAB  *//* (mostly just undid the previous changes -RAB) *//* I've added the priority argument to kmalloc so routines can   sleep on memory if they want. - RAB *//* I've also got to make sure that kmalloc is reentrant now. *//* Debugging support: add file/line info, add beginning+end markers. -M.U- */#include <linux/kernel.h>#include <linux/mm.h>#include <linux/string.h>#include <linux/malloc.h>#include <asm/system.h>struct bucket_desc {	/* 16 bytes */	void			*page;	struct bucket_desc	*next;	void			*freeptr;	unsigned short		refcnt;	unsigned short		bucket_size;};struct _bucket_dir {	/* 8 bytes */	unsigned int		size;	struct bucket_desc	*chain;};#ifdef CONFIG_DEBUG_MALLOCstruct hdr_start {	const char *file;	const char *ok_file;	unsigned short line;	unsigned short ok_line;	unsigned short size;	int magic;};struct hdr_end {	int magic;};#define DEB_MAGIC_FREE  0x13579BDF /* free block */#define DEB_MAGIC_ALLOC 0x2468ACE0 /* allocated block */#define DEB_MAGIC_USED  0x147AD036 /* allocated but bad */#define DEB_MAGIC_FREED 0x258BE169 /* free but abused */#define DEB_MAGIC_END   0x369CF258 /* end marker */#endif/* * The following is the where we store a pointer to the first bucket * descriptor for a given size. * * If it turns out that the Linux kernel allocates a lot of objects of a * specific size, then we may want to add that specific size to this list, * since that will allow the memory to be allocated more efficiently. * However, since an entire page must be dedicated to each specific size * on this list, some amount of temperance must be exercised here. * * Note that this list *must* be kept in order. */struct _bucket_dir bucket_dir[] = {#ifndef CONFIG_DEBUG_MALLOC /* Debug headers have too much overhead */	{ 16,	(struct bucket_desc *) 0},#endif	{ 32,	(struct bucket_desc *) 0},	{ 64,	(struct bucket_desc *) 0},	{ 128,	(struct bucket_desc *) 0},	{ 256,	(struct bucket_desc *) 0},	{ 512,	(struct bucket_desc *) 0},	{ 1024,	(struct bucket_desc *) 0},	{ 2048, (struct bucket_desc *) 0},	{ 4096, (struct bucket_desc *) 0},	{ 0,    (struct bucket_desc *) 0}};   /* End of list marker *//* * This contains a linked list of free bucket descriptor blocks */static struct bucket_desc *free_bucket_desc = (struct bucket_desc *) 0;/* * This routine initializes a bucket description page. *//* It assumes it is called with interrupts on. and will   return that way.  It also can sleep if priority != GFP_ATOMIC. */ static inline void init_bucket_desc(unsigned long page){	struct bucket_desc *bdesc;	int i;	bdesc = (struct bucket_desc *) page;	for (i = PAGE_SIZE/sizeof(struct bucket_desc); --i > 0; bdesc++ )		bdesc->next = bdesc+1;	/*	 * This is done last, to avoid race conditions in case	 * get_free_page() sleeps and this routine gets called again....	 */	cli();	bdesc->next = free_bucket_desc;	free_bucket_desc = (struct bucket_desc *) page;}/* * Re-organized some code to give cleaner assembly output for easier * verification.. LBT */#ifdef CONFIG_DEBUG_MALLOCvoid *deb_kmalloc(const char *deb_file, unsigned short deb_line,	unsigned int len, int priority)#elsevoid *kmalloc(unsigned int len, int priority)#endif{	int i;	unsigned long		flags;	unsigned long		page;	struct _bucket_dir	*bdir;	struct bucket_desc	*bdesc;	void			*retval;#ifdef CONFIG_DEBUG_MALLOC	len += sizeof(struct hdr_start)+sizeof(struct hdr_end);#endif	/*	 * First we search the bucket_dir to find the right bucket change	 * for this request.	 */	/* The sizes are static so there is no reentry problem here. */	bdir = bucket_dir;	for (bdir = bucket_dir ; bdir->size < len ; bdir++) {		if (!bdir->size)			goto too_large;	}	/*	 * Now we search for a bucket descriptor which has free space	 */	save_flags(flags);	cli();			/* Avoid race conditions */	for (bdesc = bdir->chain; bdesc != NULL; bdesc = bdesc->next)		if (bdesc->freeptr)			goto found_bdesc;	/*	 * If we didn't find a bucket with free space, then we'll	 * allocate a new one.	 */		/*	 * Note that init_bucket_descriptor() does its	 * own cli() before returning, and guarantees that	 * there is a bucket desc in the page.	 */	if (!free_bucket_desc) {		restore_flags(flags);		if(!(page=__get_free_page(priority)))			return NULL;		init_bucket_desc(page);	}		bdesc = free_bucket_desc;	free_bucket_desc = bdesc->next;	restore_flags(flags);	if(!(page=__get_free_page(priority))) {	/*	 * Out of memory? Put the bucket descriptor back on the free list	 */		cli();		bdesc->next = free_bucket_desc;		free_bucket_desc = bdesc;		restore_flags(flags);		return NULL;	}			bdesc->refcnt = 0;	bdesc->bucket_size = bdir->size;	bdesc->page = bdesc->freeptr = (void *) page;		/* Set up the chain of free objects */	for (i=PAGE_SIZE/bdir->size; i > 0 ; i--) {#ifdef CONFIG_DEBUG_MALLOC		struct hdr_start *hd;		struct hdr_end *he;		hd = (struct hdr_start *) page;		he = (struct hdr_end *)(page+(bdir->size-sizeof(struct hdr_end)));		hd->magic = DEB_MAGIC_FREE;		hd->file = hd->ok_file = "(expand)"; 		hd->line = hd->ok_line = 0;		hd->size = bdir->size-sizeof(struct hdr_start)-sizeof(struct hdr_end);		he->magic = DEB_MAGIC_END;		memset(hd+1,0xF8,hd->size);		*((void **) (hd+1)) = (i==1) ? NULL : (void *)(page + bdir->size);#else		*((void **) page) = (i==1) ? NULL : (void *)(page + bdir->size);#endif		page += bdir->size;	}		/* turn interrupts back off for putting the	   thing onto the chain. */	cli();	/* remember bdir is not changed. */	bdesc->next = bdir->chain; /* OK, link it in! */	bdir->chain = bdesc;found_bdesc:	retval = (void *) bdesc->freeptr;#ifdef CONFIG_DEBUG_MALLOC

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产精品久久不卡毛片| 中文字幕在线不卡| 视频一区在线播放| 欧美精品一区二区三区久久久| 亚洲综合图片区| 在线免费亚洲电影| 亚洲女同一区二区| 色偷偷成人一区二区三区91| 亚洲欧洲制服丝袜| 色乱码一区二区三区88| 欧美日韩国产三级| 免费成人小视频| 欧美国产国产综合| 成人福利在线看| 亚洲最新视频在线观看| 在线不卡免费欧美| 91久久精品一区二区三| 国产精品色婷婷久久58| 在线观看视频欧美| 亚洲美女屁股眼交3| 国产一区二区三区四| 久久精品一区四区| 成人福利在线看| 亚洲三级在线免费观看| 91福利区一区二区三区| 亚洲午夜免费电影| 欧美一级专区免费大片| 精品一区二区三区视频在线观看| 欧美不卡123| 粉嫩嫩av羞羞动漫久久久| 中文字幕亚洲视频| 欧美日韩一级视频| 蜜臀精品一区二区三区在线观看| 精品国产91洋老外米糕| 成人性生交大片免费看中文| 亚洲精品亚洲人成人网| 精品视频免费看| 狠狠v欧美v日韩v亚洲ⅴ| 国产偷国产偷亚洲高清人白洁| 豆国产96在线|亚洲| 亚洲激情图片小说视频| 日韩一级二级三级| 岛国av在线一区| 一区二区三区四区av| 欧美一区二区啪啪| 成人午夜视频网站| 亚洲午夜视频在线观看| 2023国产精品| 91视频精品在这里| 五月激情丁香一区二区三区| 欧美变态凌虐bdsm| av电影在线不卡| 亚洲欧美日韩国产一区二区三区| 欧美色倩网站大全免费| 韩国欧美一区二区| 国产精品不卡一区二区三区| 欧美肥胖老妇做爰| 国产精品一区二区在线观看网站| 亚洲欧美自拍偷拍色图| 欧美精品欧美精品系列| 风流少妇一区二区| 亚洲国产成人精品视频| 亚洲精品一区二区在线观看| 99久久精品99国产精品| 欧美aaa在线| 中文字幕一区二区在线观看| 欧美二区在线观看| 成人精品视频.| 午夜婷婷国产麻豆精品| 久久精品亚洲麻豆av一区二区| 色国产综合视频| 国产一区二区三区在线观看免费| 亚洲黄色免费电影| 天堂一区二区在线免费观看| 国产亚洲视频系列| 欧美日韩中文一区| 成人av动漫在线| 美女性感视频久久| 尤物av一区二区| 久久色在线观看| 9191精品国产综合久久久久久| 粉嫩aⅴ一区二区三区四区五区| 天天做天天摸天天爽国产一区| 亚洲精品久久久蜜桃| 欧美精品一区二区在线播放| 97se亚洲国产综合自在线| 免费视频一区二区| 国产精品激情偷乱一区二区∴| 日韩欧美中文一区二区| 在线观看视频一区| 丁香激情综合国产| 久久69国产一区二区蜜臀| 性久久久久久久久久久久| 国产精品国产三级国产a| 精品久久久久久久人人人人传媒| 欧美日韩三级一区| 99久久精品国产观看| 国产成人精品午夜视频免费| 日本成人在线不卡视频| 亚洲一区在线观看免费| 中文字幕日韩欧美一区二区三区| 亚洲精品一区二区三区99 | 亚洲欧美日韩人成在线播放| 久久一留热品黄| 日韩一级欧美一级| 欧美丝袜丝交足nylons| 91麻豆国产香蕉久久精品| 91香蕉视频mp4| 韩国精品免费视频| 久久激情五月激情| 日本欧美一区二区三区| 午夜不卡av免费| 亚洲午夜电影网| 亚洲一卡二卡三卡四卡无卡久久| 亚洲欧美怡红院| 成人免费一区二区三区视频| 国产欧美一区二区精品性| 欧美精品一区二区蜜臀亚洲| 欧美一区二区三区在线观看| 欧美视频在线一区二区三区| 91久久久免费一区二区| 91国产精品成人| 色88888久久久久久影院按摩| 91影院在线免费观看| 成人永久aaa| av色综合久久天堂av综合| 成人激情小说乱人伦| 成人午夜碰碰视频| 99久久综合狠狠综合久久| 国产成人精品亚洲日本在线桃色| 国产麻豆午夜三级精品| 国产经典欧美精品| 成人一级黄色片| av电影天堂一区二区在线观看| 成人三级伦理片| eeuss鲁片一区二区三区在线看| 99久久精品99国产精品| 色综合一个色综合| 99久久精品免费看| 在线观看中文字幕不卡| 欧亚一区二区三区| 欧美精品vⅰdeose4hd| 日韩欧美在线一区二区三区| 欧美成人一级视频| 国产婷婷色一区二区三区在线| 中文字幕第一区二区| 自拍偷在线精品自拍偷无码专区| 亚洲天堂网中文字| 亚洲国产精品久久久久婷婷884| 午夜电影久久久| 久久91精品久久久久久秒播| 国产精品 日产精品 欧美精品| 成人在线综合网| 91在线视频在线| 欧美日免费三级在线| 91精品免费在线| 国产亚洲一区二区在线观看| 国产精品毛片高清在线完整版| 亚洲欧美精品午睡沙发| 婷婷久久综合九色综合绿巨人| 裸体在线国模精品偷拍| 国产suv精品一区二区三区| 91视频国产观看| 3751色影院一区二区三区| 久久综合狠狠综合| 一区视频在线播放| 图片区小说区区亚洲影院| 精品一区二区三区不卡| 成人av在线网站| 欧美性色黄大片手机版| 欧美va亚洲va| 国产精品初高中害羞小美女文| 亚洲成人一二三| 国产精品一区二区男女羞羞无遮挡 | 视频一区视频二区中文字幕| 国产在线视频不卡二| 91丨porny丨户外露出| 6080国产精品一区二区| 国产欧美一区二区三区在线看蜜臀| 亚洲色图欧美激情| 理论片日本一区| 91尤物视频在线观看| 91精品国产色综合久久不卡电影 | 精品一区二区三区在线观看国产| 成人av网址在线| 欧美一区国产二区| 国产精品理伦片| 日本午夜精品视频在线观看| 国产91精品一区二区| 91.com视频| 亚洲欧美在线观看| 久久99精品久久久久久国产越南 | eeuss鲁一区二区三区| 在线播放中文一区| 国产精品第四页| 久久精品免费看| 色猫猫国产区一区二在线视频| 久久综合99re88久久爱| 亚洲国产欧美在线| 成人毛片视频在线观看|