⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zquerymem.c

📁 zilog的实时操作系统RZK,可以移植到多种处理器上
💻 C
字号:
/*
* File			:	ZQueryMem.c
*
* Description	:
* This funciton returns the size of the largest memory block that
* may be allocated by calling getmem.  Note that if a context switch/
* interrupt occurs between calling this function and allocating the
* memory block, then it's possible another process could make an 
* allocation that reduces the size of the largest free block.
*
* Copyright 2004 ZiLOG Inc.  ALL RIGHTS RESERVED.
*
* This file contains unpublished confidential and proprietary information
* of ZiLOG, Inc.
* NO PART OF THIS WORK MAY BE DUPLICATED, STORED, PUBLISHED OR DISCLOSED 
* IN ANY FORM WITHOUT THE PRIOR WRITTEN CONSENT OF ZiLOG, INC.
* This is not a license and no use of any kind of this work is authorized
* in the absence of a written license granted by ZiLOG, Inc. in ZiLOG's 
* sole discretion 
*/


#include "ZSysgen.h"
#include "ZTypes.h"
#include "ZThread.h"
#include "ZQueue.h"
#include "ZRegion.h"
#include "ZScheduler.h"
#include "ZInterrupt.h"

extern RZK_REGIONHANDLE_t hGlobalRegion ;
RZK_LENGTH_t RZKQueryMem(RZK_REGIONHANDLE_t hRegion)
{
	RZK_STATE_t uState;
	RZK_LENGTH_t nMaxLen;	// IAR port - changed from COUNT_t to RZK_LENGTH_t
	struct SEGMENT_t *l_Free_List;

	uState = RZKDisablePreemption();

	l_Free_List = ((RZK_REGION_t *)hRegion)->Free_List;

	/*Assign len member of free list structure to a local variable.*/
	nMaxLen = l_Free_List->len;

	l_Free_List = l_Free_List->next;
	/*As free list is a linked list browse through the next pointers of the list till NULL
	 is found.*/
	while(l_Free_List != NULL)
	{
	/* Compare the len member in each structure of the list with the stored variable.*/
	/* If the list member is greater than local variable overwrite local variable with 
	that value else continue searching for next member of the list.*/
		if(l_Free_List->len >= nMaxLen)
			nMaxLen = l_Free_List->len;

		l_Free_List = l_Free_List->next;
	}
	RZKRestorePreemption(uState);

	/*This local variable contains length of the largest chunk of memory 
	that can be allocated by getmem.*/
	return nMaxLen;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -