plan 9 kernel history: overview | file list | diff list

1992/0625/port/segment.c (diff list | history)

1992/0621/sys/src/9/port/segment.c:15,291992/0625/sys/src/9/port/segment.c:15,28 (short | long | prev | next)
1991/0705    
 
#define IHASHSIZE	64 
#define ihash(s)	imagealloc.hash[s%IHASHSIZE] 
struct Imagealloc 
1992/0625    
struct 
1991/0705    
{ 
	Lock; 
	Image	*free; 
	Image	*hash[IHASHSIZE]; 
1992/0625    
	QLock	ireclaim; 
1991/0705    
}imagealloc; 
 
1991/0706    
static QLock ireclaim; 
                 
1991/0705    
void 
initseg(void) 
{ 
1992/0621/sys/src/9/port/segment.c:254,2821992/0625/sys/src/9/port/segment.c:253,280
1991/0706    
{ 
	Page *p; 
 
	if(!canqlock(&ireclaim))	/* Somebody is already cleaning the page cache */ 
1992/0625    
	/* Somebody is already cleaning the page cache */ 
	if(!canqlock(&imagealloc.ireclaim)) 
1991/0706    
		return; 
 
1992/0404    
	lock(&palloc); 
	for(p = palloc.head; p; p = p->next) { 
		if(p->image) 
		if(p->ref == 0) 
		if(p->image != &swapimage) { 
			lockpage(p); 
1992/0625    
		if(p->image && p->ref == 0 && p->image != &swapimage) { 
			lock(p); 
1992/0225    
			if(p->ref == 0) 
1992/0404    
				uncachepage(p); 
			unlockpage(p); 
1992/0625    
			unlock(p); 
1992/0314    
		} 
1991/0706    
	} 
1992/0404    
	unlock(&palloc); 
1991/0706    
	qunlock(&ireclaim); 
1992/0625    
	qunlock(&imagealloc.ireclaim); 
1991/0706    
} 
 
void 
1991/0705    
putimage(Image *i) 
{ 
	Image *f, **l; 
	Chan *c; 
1992/0625    
	Image *f, **l; 
1991/0705    
 
	if(i == &swapimage) 
		return; 
1992/0621/sys/src/9/port/segment.c:301,3071992/0625/sys/src/9/port/segment.c:299,305
1991/0705    
		imagealloc.free = i; 
		unlock(&imagealloc); 
 
		close(c);		/* Delay close because we could error */ 
1992/0625    
		close(c); 
1991/0705    
		return; 
	} 
	unlock(i); 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)