[운영 체제 실험lab2] 실험 보고서

515 단어 운영 체제
static void * alloc(u_int n, u_int align, int clear)
{
	extern char end[]; 	
	int i;
	u_long alloced_mem;
	if(freemem==0)
		freemem=(u_long)end;
	freemem = (((u_long)(freemem))+(align)-1)&~((align)-1);
	//Step 1 finished.
	alloced_mem = freemem;
	//Step 2 finished.
	freemem +=(((u_long)(n))+(align)-1)&~((align)-1);
	//Step 3 finished.
	if(clear == 1){
		for(i=alloced_mem;i<alloced_mem+n;i++)
			 *i = 0;
	}
	//Step 4 finished.
	return (void *)alloced_mem;
	//Step 5 finished.
}

좋은 웹페이지 즐겨찾기