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

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

?? heap_2.c

?? freertosV4.40 是一種small的嵌入式系統(tǒng)。利于嵌入式開好者入門學(xué)習(xí)嵌入式操作系統(tǒng)。通過對(duì)于源碼的學(xué)習(xí)可以很好的掌握freertos的運(yùn)行機(jī)制。
?? C
字號(hào):
/*
	FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 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.

	Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
	with commercial development and support options.
	***************************************************************************
*/

/*
 * 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 == 8
	#define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0007 )
#endif

#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
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
蜜臀av性久久久久蜜臀aⅴ| 2014亚洲片线观看视频免费| 五月天网站亚洲| 久久精品免视看| 在线观看欧美黄色| 国产精品一区二区不卡| 日韩理论片中文av| 日韩欧美国产一区二区三区| 美女视频免费一区| 国产精品第13页| 日韩一级片网站| 色综合天天综合网国产成人综合天| 国产欧美视频一区二区| 欧美喷潮久久久xxxxx| 免费日本视频一区| 亚洲一区二区精品3399| 久久久国产精品不卡| 欧美日韩国产高清一区二区| 同产精品九九九| 国产亚洲精品中文字幕| 欧美视频一区二区三区四区 | 94色蜜桃网一区二区三区| 久久蜜桃av一区二区天堂| 久久99久久99精品免视看婷婷| 精品国产一区二区三区四区四| 91国产免费观看| 99久久精品久久久久久清纯| 成人一区在线观看| 国产麻豆视频一区| 久久国产精品区| 热久久国产精品| 日韩精品一级中文字幕精品视频免费观看| 国产精品日产欧美久久久久| 欧美大片免费久久精品三p| 91.com在线观看| 日韩午夜激情视频| 精品国产乱码久久久久久浪潮 | 激情综合色播激情啊| 秋霞午夜av一区二区三区| 麻豆成人久久精品二区三区红 | 国产精品色噜噜| 9191成人精品久久| 久久久久久免费毛片精品| 久久久国际精品| 亚洲午夜免费电影| 国内精品国产成人| 欧美日免费三级在线| 精品久久人人做人人爽| 亚洲精品免费在线观看| 狠狠色丁香九九婷婷综合五月| 色综合网站在线| 国产日韩欧美精品综合| 午夜亚洲国产au精品一区二区| 国产美女精品一区二区三区| 91久久国产最好的精华液| 久久品道一品道久久精品| 亚洲影视在线观看| 99久久伊人精品| 久久久久综合网| 久久99热国产| 911精品国产一区二区在线| 亚洲人妖av一区二区| 国产精品中文字幕日韩精品| 在线成人免费观看| 亚洲福中文字幕伊人影院| 97精品视频在线观看自产线路二| 精品国产乱子伦一区| 美女精品自拍一二三四| 成人爽a毛片一区二区免费| 国产日产欧美一区二区三区| 波多野结衣精品在线| 亚洲一本大道在线| 国产色91在线| 欧美高清视频一二三区 | 欧美精品xxxxbbbb| 成人免费在线视频观看| av高清不卡在线| 亚洲女与黑人做爰| 91免费观看视频在线| 亚洲美女一区二区三区| 欧美在线观看视频在线| 亚洲精品久久7777| 在线不卡的av| 国产酒店精品激情| 亚洲柠檬福利资源导航| 51精品秘密在线观看| 国产乱人伦精品一区二区在线观看| 国产午夜精品一区二区三区四区| 成人国产精品免费观看动漫| 一区二区在线观看免费视频播放| 日韩视频国产视频| 99久久99精品久久久久久| 亚洲成人黄色影院| 国产精品久久久久久久久搜平片| 欧美在线影院一区二区| 另类调教123区| 亚洲一区二区三区不卡国产欧美| 欧美成人女星排名| 欧美色视频在线| 99精品欧美一区| 九色porny丨国产精品| 亚洲日本丝袜连裤袜办公室| 国产精品成人网| 在线91免费看| 麻豆国产精品官网| 日韩一区二区三区免费观看| 国产伦精品一区二区三区视频青涩 | 午夜精品福利一区二区蜜股av | 国产丝袜在线精品| 亚洲综合999| 国产午夜精品一区二区| 日韩一级片在线播放| 欧美美女直播网站| 色婷婷亚洲婷婷| 91精彩视频在线| 色综合久久久久综合99| 9久草视频在线视频精品| 国产真实乱子伦精品视频| 婷婷亚洲久悠悠色悠在线播放| 亚洲色图20p| 一区二区三区国产豹纹内裤在线| 中文字幕精品一区二区三区精品| 欧美tk—视频vk| 国产日韩欧美麻豆| 中文av一区二区| 亚洲色欲色欲www在线观看| 中文字幕色av一区二区三区| 亚洲三级在线免费| 亚洲图片自拍偷拍| 日本成人在线不卡视频| 日本视频中文字幕一区二区三区| 精品国产一区二区在线观看| 欧美精品一区二区久久婷婷| 久久久久久久久久电影| 国产精品亲子乱子伦xxxx裸| 亚洲欧美激情一区二区| 亚洲国产一区二区在线播放| 蜜桃av一区二区三区电影| 国产一区二区三区高清播放| av福利精品导航| 欧美另类久久久品| 欧美国产一区二区在线观看| 亚洲国产一区二区三区青草影视| 日本在线不卡视频一二三区| 成人一区二区三区视频在线观看| 91麻豆蜜桃一区二区三区| 欧美精品xxxxbbbb| 国产精品伦理在线| 天堂蜜桃91精品| av在线一区二区| 精品成人私密视频| 亚洲图片有声小说| 成人黄色软件下载| 欧美久久婷婷综合色| 国产精品国产a| 激情图片小说一区| 欧美伦理视频网站| 亚洲激情第一区| 成人午夜激情在线| 久久亚洲综合色| 日韩av一级电影| 91久久国产最好的精华液| 国产精品欧美经典| 国产91丝袜在线18| 欧美一级午夜免费电影| 亚洲男女一区二区三区| heyzo一本久久综合| 国产三级欧美三级日产三级99| 午夜激情综合网| 欧美日韩一区二区三区免费看| 国产精品久久久久aaaa| 成人午夜电影小说| 欧美激情一区在线| 成人高清在线视频| 1024亚洲合集| 欧美专区日韩专区| 亚洲午夜久久久久中文字幕久| 91豆麻精品91久久久久久| 亚洲免费伊人电影| 欧美三级视频在线观看| 五月婷婷另类国产| 日韩亚洲国产中文字幕欧美| 老司机精品视频导航| 久久综合色一综合色88| 成人晚上爱看视频| 亚洲精品日产精品乱码不卡| 欧美日韩日日摸| 麻豆国产91在线播放| 国产日韩亚洲欧美综合| 91欧美一区二区| 日本亚洲一区二区| 久久精品夜夜夜夜久久| 色综合天天综合在线视频| 日韩二区在线观看| 欧美激情综合五月色丁香小说| 色94色欧美sute亚洲13| 久热成人在线视频| 亚洲乱码一区二区三区在线观看| 欧美顶级少妇做爰| 丁香六月久久综合狠狠色|