예제 #1
0
파일: vmem.c 프로젝트: blakemcbride/VMEM
void	VM_end(void)
{
	register int	i, b;
	VMHEAD	HUGE	*v;
	FNAME(VM_end);

	TEST(fun, 0);
	if (DMhandle !=	-1)  {
		if (-1 == close(DMhandle))
			error(fun, "close");
		if (-1 == unlink(DMfile))
			error(fun, "unlink");
	}
	dm_new();
	for (b=0 ; b !=	VMBASESIZ  &&  (v=VMbase[b]) ; ++b)  {
		for (i=b?0:1 ; i != VMLEGSIZ  ;	++i)
			if (v[i].type &	MT_MEMORY)
				rmfree((RMHEAD_PTR) v[i].mem, v[i].size);
		rmfree((RMHEAD_PTR) v, (MAX_SIZ_TYP) (sizeof(VMHEAD) * VMLEGSIZ));
		VMbase[b] = NULL;
	}
	VMfree.i = 0;
	VMmru.i	 = 0;
	VMlru.i	 = 0;
	VMtotal	 = 0L;
	VMlive	 = 0;
	VMdisk	 = 0;
	VMnfreez = 0;
	VMnifrez = 0;
	TEST(fun, 1);
}
예제 #2
0
파일: vmem.c 프로젝트: blakemcbride/VMEM
static	int	morecore(MAX_SIZ_TYP s)
{
	RMHEAD_PTR	p;
	unsigned long	n;
	FNAME(morecore);

	s += RMCHUNK(sizeof(RMHEAD));	/* allow room for system pointer	*/
#if 0
	n = s >	RMasize	? s : RMasize;
	n = RMCHUNK(n);
#else
	n = (((long) s - 1L) / RMasize + 1L) * RMasize;
#endif
	if (RMmax  &&  RMtotal + n > RMmax)
		return(1);
	p = (RMHEAD_PTR) malloc((unsigned) n);
	if (!p)
		return(1);
	RMtotal	 += n;
	p->s.next = RMsmem;
	RMsmem	  = p;
	p->s.size = n;
	rmfree((RMHEAD_PTR) (p+1), (MAX_SIZ_TYP) (n-sizeof(RMHEAD)));
	return(0);
}
예제 #3
0
파일: vmem.c 프로젝트: blakemcbride/VMEM
static	void	dfree_free(void)
{
	DFREE	HUGE	*ca;

	while (DMflist)	 {
		ca = DMflist;
		DMflist	= DMflist->next;
		rmfree((RMHEAD_PTR) ca,	(MAX_SIZ_TYP) sizeof(DFREE));
	}
}
예제 #4
0
void
pcibr_ate_free(pcibr_soft_t pcibr_soft, int index, int count)
/* Who says there's no such thing as a free meal? :-) */
{
    /* note the "+1" since rmalloc handles 1..n but
     * we start counting ATEs at zero.
     */
    rmfree((index < pcibr_soft->bs_int_ate_size)
	   ? pcibr_soft->bs_int_ate_map
	   : pcibr_soft->bs_ext_ate_map,
	   count, index + 1);
}
예제 #5
0
파일: vmem.c 프로젝트: blakemcbride/VMEM
static	void	rest_clean(int lev, int h, int mb, int mi)
{
	register int	b, i;
	VMHEAD HUGE	*v;

	close(h);
	VMfree.i = 0;
	if (lev	<= 1)	return;
	for (b=0 ; b !=	VMBASESIZ  &&  (v=VMbase[b]) ; ++b)  {
		if (lev	== 3  &&  b <= mb)
			for (i=b?0:1 ; i != VMLEGSIZ  ;	++i)
				if (v[i].type &	MT_MEMORY  &&  (b != mb	 ||  i < mi))
					rmfree((RMHEAD_PTR) v[i].mem, v[i].size);
		rmfree((RMHEAD_PTR) v, (MAX_SIZ_TYP) (sizeof(VMHEAD) * VMLEGSIZ));
		VMbase[b] = NULL;
	}
	if (lev	== 3)  {
		VMtotal	= 0L;
		VMlive	= 0;
	}
}
예제 #6
0
파일: vmem.c 프로젝트: blakemcbride/VMEM
void	VM_free(VMPTR_TYPE i)
{
	VMPTR	p;
	VMHEAD	HUGE *h, HUGE *t;
	FNAME(VM_free);

	TEST(fun, 0);
	p.i = i;
	if (!i	||  p.p.b >= VMBASESIZ	||  p.p.l >= VMLEGSIZ  ||  !VMbase[p.p.b])
		return;
	h = (VMHEAD HUGE *) &VMbase[p.p.b][p.p.l];
	if (h->type == MT_NOTUSED)
		return;
	if (h->type & MT_IMEDIATE)  {
		if (h->type & MT_FREEZE)  {
			VMnfreez--;
			VMnifrez--;
		}
		vmfree_head(i);
		VMlive--;
		TEST(fun, 1);
		return;
	}
	VMtotal	-= h->size;
	free_disk(h->size, h->diskadd, 0);

	/* this	must be	redone because free_disk calls dfree_new, rmalloc, compact so the address may change  */

	h = (VMHEAD HUGE *) &VMbase[p.p.b][p.p.l];

	if (h->type & MT_FREEZE)
		VMnfreez--;
	if (h->type & MT_DISK) {
		vmfree_head(i);
		VMdisk--;
		TEST(fun, 2);
		return;
	}
	if (!(h->type &	MT_FREEZE))
		vm_unlink(h);
	rmfree((RMHEAD_PTR) h->mem, h->size);
	vmfree_head(i);
	VMlive--;
	TEST(fun, 3);
}
예제 #7
0
파일: vmem.c 프로젝트: blakemcbride/VMEM
static	void	page_out(VMHEAD	HUGE *h)
{
	FNAME(page_out);

	if (!(h->type &	MT_MEMORY))
		error(fun, "not MT_MEMORY");
	if (h->type & MT_FREEZE)
		error(fun, "can't page out frozen memory");
	if (h->type & MT_DIRTY)	 {
		if (h->diskadd == -1L)
			h->diskadd = disk_next((long) h->size, h->mem);
		else  {
			if (-1L	== lseek(DMhandle, h->diskadd, SEEK_SET))
				error(fun, "lseek");
			if (h->size != longwrite(DMhandle, h->mem, (long) h->size))
				error(fun, "write");
		}
	}
	rmfree((RMHEAD_PTR) h->mem, h->size);
	h->type	= MT_DISK;
	VMlive--;
	VMdisk++;
	VM_newadd = 1;
}