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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? heap_2.c

?? MCS-51的一個(gè)Free小型操作系統(tǒng),在KeilC中下編譯工作
?? C
字號:
/*
	FreeRTOS.org V4.1.3 - Copyright (C) 2003-2006 Richard Barry.

	This file is part of the FreeRTOS.org distribution.

	FreeRTOS.org is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	FreeRTOS.org is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with FreeRTOS.org; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

	A special exception to the GPL can be applied should you wish to distribute
	a combined work that includes FreeRTOS.org, without being obliged to provide
	the source code for any proprietary components.  See the licensing section
	of http://www.FreeRTOS.org for full details of how and when the exception
	can be applied.

	***************************************************************************
	See http://www.FreeRTOS.org for documentation, latest information, license
	and contact details.  Please ensure to read the configuration and relevant
	port sections of the online documentation.
	***************************************************************************
*/

/*
 * A sample implementation of pvPortMalloc() and vPortFree() that permits
 * allocated blocks to be freed, but does not combine adjacent free blocks
 * into a single larger block.
 *
 * See heap_1.c and heap_3.c for alternative implementations, and the memory
 * management pages of http://www.FreeRTOS.org for more information.
 */
#include <stdlib.h>

#include "FreeRTOS.h"
#include "task.h"

/* Setup the correct byte alignment mask for the defined byte alignment. */
#if portBYTE_ALIGNMENT == 4
	#define heapBYTE_ALIGNMENT_MASK	( ( size_t ) 0x0003 )
#endif

#if portBYTE_ALIGNMENT == 2
	#define heapBYTE_ALIGNMENT_MASK	( ( size_t ) 0x0001 )
#endif

#if portBYTE_ALIGNMENT == 1
	#define heapBYTE_ALIGNMENT_MASK	( ( size_t ) 0x0000 )
#endif

#ifndef heapBYTE_ALIGNMENT_MASK
	#error "Invalid portBYTE_ALIGNMENT definition"
#endif

/* Allocate the memory for the heap.  The struct is used to force byte
alignment without using any non-portable code. */
static struct xRTOS_HEAP
{
	unsigned portLONG ulDummy;
	unsigned portCHAR ucHeap[ configTOTAL_HEAP_SIZE ];
} xHeap;

/* Define the linked list structure.  This is used to link free blocks in order
of their size. */
typedef struct A_BLOCK_LINK
{
	struct A_BLOCK_LINK *pxNextFreeBlock;	/*<< The next free block in the list. */
	size_t xBlockSize;						/*<< The size of the free block. */
} xBlockLink;


static const unsigned portSHORT  heapSTRUCT_SIZE	= ( sizeof( xBlockLink ) + ( sizeof( xBlockLink ) % portBYTE_ALIGNMENT ) );
#define heapMINIMUM_BLOCK_SIZE	( ( size_t ) ( heapSTRUCT_SIZE * 2 ) )

/* Create a couple of list links to mark the start and end of the list. */
static xBlockLink xStart, xEnd;

/* STATIC FUNCTIONS ARE DEFINED AS MACROS TO MINIMIZE THE FUNCTION CALL DEPTH. */

/*
 * Insert a block into the list of free blocks - which is ordered by size of
 * the block.  Small blocks at the start of the list and large blocks at the end
 * of the list.
 */
#define prvInsertBlockIntoFreeList( pxBlockToInsert )								\
{																					\
xBlockLink *pxIterator;																\
size_t xBlockSize;																	\
																					\
	xBlockSize = pxBlockToInsert->xBlockSize;										\
																					\
	/* Iterate through the list until a block is found that has a larger size */	\
	/* than the block we are inserting. */											\
	for( pxIterator = &xStart; pxIterator->pxNextFreeBlock->xBlockSize < xBlockSize; pxIterator = pxIterator->pxNextFreeBlock )	\
	{																				\
		/* There is nothing to do here - just iterate to the correct position. */	\
	}																				\
																					\
	/* Update the list to include the block being inserted in the correct */		\
	/* position. */																	\
	pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock;					\
	pxIterator->pxNextFreeBlock = pxBlockToInsert;									\
}
/*-----------------------------------------------------------*/

#define prvHeapInit()																\
{																					\
xBlockLink *pxFirstFreeBlock;														\
																					\
	/* xStart is used to hold a pointer to the first item in the list of free */	\
	/* blocks.  The void cast is used to prevent compiler warnings. */				\
	xStart.pxNextFreeBlock = ( void * ) xHeap.ucHeap;								\
	xStart.xBlockSize = ( size_t ) 0;												\
																					\
	/* xEnd is used to mark the end of the list of free blocks. */					\
	xEnd.xBlockSize = configTOTAL_HEAP_SIZE;										\
	xEnd.pxNextFreeBlock = NULL;													\
																					\
	/* To start with there is a single free block that is sized to take up the		\
	entire heap space. */															\
	pxFirstFreeBlock = ( void * ) xHeap.ucHeap;										\
	pxFirstFreeBlock->xBlockSize = configTOTAL_HEAP_SIZE;							\
	pxFirstFreeBlock->pxNextFreeBlock = &xEnd;										\
}
/*-----------------------------------------------------------*/

void *pvPortMalloc( size_t xWantedSize )
{
xBlockLink *pxBlock, *pxPreviousBlock, *pxNewBlockLink;
static portBASE_TYPE xHeapHasBeenInitialised = pdFALSE;
void *pvReturn = NULL;

	vTaskSuspendAll();
	{
		/* If this is the first call to malloc then the heap will require
		initialisation to setup the list of free blocks. */
		if( xHeapHasBeenInitialised == pdFALSE )
		{
			prvHeapInit();
			xHeapHasBeenInitialised = pdTRUE;
		}

		/* The wanted size is increased so it can contain a xBlockLink
		structure in addition to the requested amount of bytes. */
		if( xWantedSize > 0 )
		{
			xWantedSize += heapSTRUCT_SIZE;

			/* Ensure that blocks are always aligned to the required number of bytes. */
			if( xWantedSize & heapBYTE_ALIGNMENT_MASK )
			{
				/* Byte alignment required. */
				xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & heapBYTE_ALIGNMENT_MASK ) );
			}
		}

		if( ( xWantedSize > 0 ) && ( xWantedSize < configTOTAL_HEAP_SIZE ) )
		{
			/* Blocks are stored in byte order - traverse the list from the start
			(smallest) block until one of adequate size is found. */
			pxPreviousBlock = &xStart;
			pxBlock = xStart.pxNextFreeBlock;
			while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock ) )
			{
				pxPreviousBlock = pxBlock;
				pxBlock = pxBlock->pxNextFreeBlock;
			}

			/* If we found the end marker then a block of adequate size was not found. */
			if( pxBlock != &xEnd )
			{
				/* Return the memory space - jumping over the xBlockLink structure
				at its start. */
				pvReturn = ( void * ) ( ( ( unsigned portCHAR * ) pxPreviousBlock->pxNextFreeBlock ) + heapSTRUCT_SIZE );

				/* This block is being returned for use so must be taken our of the
				list of free blocks. */
				pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock;

				/* If the block is larger than required it can be split into two. */
				if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE )
				{
					/* This block is to be split into two.  Create a new block
					following the number of bytes requested. The void cast is
					used to prevent byte alignment warnings from the compiler. */
					pxNewBlockLink = ( void * ) ( ( ( unsigned portCHAR * ) pxBlock ) + xWantedSize );
					
					/* Calculate the sizes of two blocks split from the single
					block. */
					pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize;	
					pxBlock->xBlockSize = xWantedSize;			
					
					/* Insert the new block into the list of free blocks. */
					prvInsertBlockIntoFreeList( ( pxNewBlockLink ) );
				}
			}
		}
	}
	xTaskResumeAll();

	return pvReturn;
}
/*-----------------------------------------------------------*/

void vPortFree( void *pv )
{
unsigned portCHAR *puc = ( unsigned portCHAR * ) pv;
xBlockLink *pxLink;

	if( pv )
	{
		/* The memory being freed will have an xBlockLink structure immediately
		before it. */
		puc -= heapSTRUCT_SIZE;

		/* This casting is to keep the compiler from issuing warnings. */
		pxLink = ( void * ) puc;

		vTaskSuspendAll();
		{				
			/* Add this block to the list of free blocks. */
			prvInsertBlockIntoFreeList( ( ( xBlockLink * ) pxLink ) );
		}
		xTaskResumeAll();
	}
}
/*-----------------------------------------------------------*/

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩三级av在线播放| 亚洲欧美欧美一区二区三区| 精品国免费一区二区三区| 亚洲一二三专区| 欧美色综合影院| 亚洲女人的天堂| 国产网站一区二区| 国产在线不卡一卡二卡三卡四卡| 欧美日韩一区二区三区四区| 亚洲午夜电影在线| 欧美精品在线观看播放| 日韩精品欧美成人高清一区二区| 欧美日韩精品一区二区三区蜜桃| 亚洲一二三区视频在线观看| 国产精品卡一卡二卡三| 91色乱码一区二区三区| 亚洲国产经典视频| 色综合久久久久| 青青国产91久久久久久| 日本一区二区动态图| 精品国产乱码久久久久久牛牛 | 日韩欧美在线综合网| 欧洲精品一区二区三区在线观看| 亚洲永久免费av| 亚洲尤物视频在线| 亚洲一区在线视频| 亚洲制服丝袜av| 天堂在线一区二区| 三级不卡在线观看| 久久精品国产99国产精品| 亚洲国产经典视频| |精品福利一区二区三区| 国产69精品久久久久777| 日韩欧美中文字幕一区| 久久久久久99久久久精品网站| 成人免费观看av| 麻豆91在线看| 日韩精品三区四区| 国产成人福利片| 免费看精品久久片| 成人午夜电影久久影院| 色哟哟欧美精品| 日韩女优av电影在线观看| 欧美日韩日本视频| 久久久久久久久99精品| 亚洲品质自拍视频| 久久av老司机精品网站导航| 成人动漫av在线| 91最新地址在线播放| 99精品偷自拍| 欧美成人video| 日韩免费看网站| 亚洲欧美激情视频在线观看一区二区三区| 亚洲一二三四区| 国产尤物一区二区| 欧美日韩一区二区三区不卡| 国产欧美日韩亚州综合| 国产精品婷婷午夜在线观看| 中文字幕人成不卡一区| 日韩av网站免费在线| 国产一区二区免费看| 91精品在线免费| 久久久高清一区二区三区| 亚洲观看高清完整版在线观看| 国产成人精品免费在线| 久久久精品欧美丰满| 蜜桃视频在线一区| 在线播放中文字幕一区| 亚洲影院免费观看| 99国产欧美另类久久久精品| 日韩一区二区免费电影| 中文字幕一区在线| 成人国产精品免费观看| 国产视频一区不卡| 成人在线视频一区| 国产精品每日更新在线播放网址| 国产精品69毛片高清亚洲| bt欧美亚洲午夜电影天堂| 欧美美女一区二区| 日韩av二区在线播放| 久久无码av三级| 一区二区三区精品在线观看| 韩国中文字幕2020精品| 欧美中文一区二区三区| 亚洲国产精品人人做人人爽| 91精品国产麻豆国产自产在线| 国产午夜一区二区三区| 国产成人免费视| 一区二区三区四区av| 337p亚洲精品色噜噜| 国产一区视频在线看| 国产精品久久久久三级| 日本韩国欧美在线| 国产精品免费看片| 欧美日韩在线播放三区| 韩国女主播一区二区三区| 亚洲天天做日日做天天谢日日欢| 国产不卡视频在线观看| 亚洲一级二级在线| 久久精品网站免费观看| 欧洲视频一区二区| 国产999精品久久| 日韩极品在线观看| 亚洲少妇30p| 久久久亚洲精品一区二区三区| 91高清视频免费看| 国产成人精品免费在线| 免费观看一级欧美片| 17c精品麻豆一区二区免费| 欧美一级生活片| 91免费国产在线观看| 午夜视频在线观看一区二区 | 日韩美女久久久| 欧美一二三区在线| 精品视频色一区| 972aa.com艺术欧美| 成人国产精品免费| 国产麻豆视频一区二区| 日韩在线a电影| 午夜精品福利久久久| 亚洲一区二区av电影| 亚洲欧美视频一区| 亚洲免费三区一区二区| 国产亚洲制服色| 国产亚洲欧美日韩在线一区| 欧美不卡在线视频| 欧美精品一区二区三区一线天视频| 欧美日高清视频| www国产成人| 精品国产一区二区三区忘忧草| 欧美成人a视频| 国产调教视频一区| 亚洲欧美福利一区二区| 亚洲蜜桃精久久久久久久| 婷婷国产在线综合| 麻豆精品一区二区三区| 国产精品一级二级三级| 成人免费视频网站在线观看| 色综合久久久久久久久久久| 欧美日韩亚洲综合| 日韩久久久久久| 日本一区二区成人在线| 亚洲最新视频在线观看| 免费精品视频在线| av一本久道久久综合久久鬼色| 91成人在线免费观看| 精品国产免费人成在线观看| 国产精品久久久久久一区二区三区| 一区二区国产视频| 久久99国产精品久久99果冻传媒| 综合av第一页| 日韩av电影天堂| av福利精品导航| 日韩一级在线观看| 亚洲精品欧美在线| 91精品国产综合久久久久久漫画| 在线不卡一区二区| 国产精品伦理一区二区| 国产不卡视频一区| 在线观看欧美黄色| 国产精品午夜久久| 久久精品国产精品亚洲红杏| 欧美视频三区在线播放| 亚洲国产成人私人影院tom| 日本aⅴ亚洲精品中文乱码| 色综合中文字幕国产 | 韩日精品视频一区| 666欧美在线视频| 亚洲成人午夜电影| 久久精品国产久精国产| 3d动漫精品啪啪| 偷拍日韩校园综合在线| 欧美亚洲一区二区在线| 一区二区三区日本| 色综合色狠狠综合色| 亚洲欧美在线观看| 色综合天天狠狠| 亚洲综合激情另类小说区| 91日韩在线专区| 亚洲一区二区偷拍精品| 欧美午夜不卡视频| 免费成人在线视频观看| 日韩一区二区三区电影| 美女视频免费一区| 久久久久99精品国产片| 成人性生交大片免费| 亚洲欧洲综合另类| 欧美日韩高清不卡| 激情文学综合丁香| 国产精品网站在线| 欧美日韩在线播放| 韩国成人福利片在线播放| 国产精品久久久久久久久免费桃花| av网站免费线看精品| 亚洲高清免费一级二级三级| 日韩欧美高清一区| 成人黄色a**站在线观看| 亚洲午夜电影网| 中文字幕二三区不卡| 欧美在线啊v一区|