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

📄 vm2_umalloc.c

📁 小型操作系统,以VC为开发环境,需要boachs调试
💻 C
字号:
/***************************************************************************
**     File name   : vm2_umalloc.c
**     Author      : x.cheng
**     Create date :
**
**	   Comment:
**        Virtual Memory Allocator for the User Space. 
**
**     Revisions:
**     $Log: vm2_umalloc.c,v $
**     Revision 1.1.1.1  2005/07/27 06:53:16  x.cheng
**     add into repositories
**
**
***************************************************************************/
#include "const.h"
#include "type.h"
#include "stdarg.h"
#include "stdlib.h"

#include "..\..\Inc\i386\map.h"		//kernel\inc\i386
#include "..\..\Inc\i386\system.h"		
#include "..\..\Inc\i386\page.h"
#include "..\..\Inc\mts.h"
#include "..\..\Inc\task.h"
#include "..\..\Inc\debug.h"

#define __VMM_SRC__
#include "..\inc\def_vmm.h"			//kernel\vmm\inc


/* debug preprocessor instrument
	#ifdef _DEBUG__
	#ifdef _DEBUG_VMM__
				
	#endif
	#endif	
***************************/

/************************************************************
*************************************************************
**      Function Name:			vVm2UeMallocInit
**      Author:                 x.cheng
**
**      Comment:
**			用户空间堆内存分配初始化
**		注意:不要在线程初始化函数中调用这个函数
**       
**
**      List of parameters:
**			 ulHeapStart - The start of the user heap.
**			 ulHeapSize	- The size of the user heap.
**
**      Return value:   
**			  no
**
**      Revisions:
**			
*************************************************************
*************************************************************/
void vVm2UeMallocInit(ts_Task *pstTask, unsigned long ulHeapStart, unsigned long ulHeapSize)
{
	ts_MCB *pstMcb;

	if ( NULL == pstTask )	return;

	#ifdef _DEBUG__
	#ifdef _DEBUG_VMM__
		kprintf("pstTask= %p, ulHeapStart= %x, ulHeapSize= %x\n", pstTask, ulHeapStart, ulHeapSize);
	#endif
	#endif	

	if ( TASK_TYPE_THREAD == pstTask->stFlags.Type ) {
	#ifdef _DEBUG__
	#ifdef _DEBUG_VMM__
		kprintf("%s(): threads share the father's heap.h\n", __FUNCTION__);	
	#endif
	#endif	
		return;
	}
	
	//setup the heap in the task structure.
	pstTask->ulHeapStart = ulHeapStart;
	pstTask->ulHeapSize = ulHeapSize;
	InitMutex( &(pstTask->stHeapSemaphore) );

	vDbgDummy();
	//create only one hudge block;
	pstMcb = (ts_MCB * )ulHeapStart;
	pstMcb->ulMagic = UMB_MAGIC;
	pstMcb->ulFlags = MB_FREE;
	pstMcb->ulSize = ulHeapSize - sizeof(ts_MCB);
	pstMcb->ulOwnerPtr = NULL;

}

⌨️ 快捷键说明

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