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

1991/0706/port/segment.c (diff list | history)

1991/0705/sys/src/9/port/segment.c:11,161991/0706/sys/src/9/port/segment.c:11,17 (short | long | prev | next)
1991/0705    
Page *lkpage(ulong addr); 
Page *snewpage(ulong addr); 
void lkpgfree(Page*); 
1991/0706    
void imagereclaim(void); 
1991/0705    
 
/* System specific segattach devices */ 
#include "segment.h" 
1991/0705/sys/src/9/port/segment.c:30,351991/0706/sys/src/9/port/segment.c:31,38
1991/0705    
	Segment *free; 
}segalloc; 
 
1991/0706    
static QLock ireclaim; 
 
1991/0705    
void 
initseg(void) 
{ 
1991/0705/sys/src/9/port/segment.c:75,801991/0706/sys/src/9/port/segment.c:78,84
1991/0705    
			s->flen = 0; 
			s->pgalloc = 0; 
			s->pgfree = 0; 
1991/0706    
			s->flushme = 0; 
1991/0705    
			memset(s->map, 0, sizeof(s->map)); 
 
			return s; 
1991/0705/sys/src/9/port/segment.c:135,1491991/0706/sys/src/9/port/segment.c:139,160
1991/0705    
	int i; 
 
	switch(s->type&SG_TYPE) { 
	case SG_TEXT:		/* new segment shares pte set */ 
1991/0706    
	case SG_TEXT:			/* New segment shares pte set */ 
1991/0705    
	case SG_SHARED: 
	case SG_PHYSICAL: 
		incref(s); 
		return s; 
	case SG_DATA:		/* copy on write both old and new plus demand load info */ 
		lock(s); 
1991/0706    
 
	case SG_BSS:			/* Just copy on write */ 
	case SG_STACK: 
		qlock(&s->lk); 
1991/0705    
		n = newseg(s->type, s->base, s->size); 
1991/0706    
		goto copypte; 
1991/0705    
 
1991/0706    
	case SG_DATA:			/* Copy on write plus demand load info */ 
		qlock(&s->lk); 
		n = newseg(s->type, s->base, s->size); 
 
1991/0705    
		incref(s->image); 
		n->image = s->image; 
		n->fstart = s->fstart; 
1991/0705/sys/src/9/port/segment.c:152,1641991/0706/sys/src/9/port/segment.c:163,172
1991/0705    
		for(i = 0; i < SEGMAPSIZE; i++) 
			if(pte = s->map[i]) 
				n->map[i] = ptecpy(pte); 
		unlock(s); 
1991/0706    
 
		n->flushme = s->flushme; 
		qunlock(&s->lk); 
1991/0705    
		return n;	 
	case SG_BSS:		/* Just copy on write */ 
	case SG_STACK: 
		lock(s); 
		n = newseg(s->type, s->base, s->size); 
		goto copypte; 
	} 
 
	panic("dupseg"); 
1991/0705/sys/src/9/port/segment.c:188,1931991/0706/sys/src/9/port/segment.c:196,202
1991/0705    
 
	lock(&imagealloc); 
 
1991/0706    
	/* Search the image cache for remains of the text from a previous incarnation */ 
1991/0705    
	for(i = ihash(c->qid.path); i; i = i->hash) { 
		if(c->qid.path == i->qid.path) { 
			lock(i); 
1991/0705/sys/src/9/port/segment.c:204,2091991/0706/sys/src/9/port/segment.c:213,219
1991/0705    
	 
	while(!(i = imagealloc.free)) { 
		unlock(&imagealloc); 
1991/0706    
		imagereclaim(); 
1991/0705    
		resrcwait("no images"); 
		lock(&imagealloc); 
	} 
1991/0705/sys/src/9/port/segment.c:236,2411991/0706/sys/src/9/port/segment.c:246,277
1991/0705    
} 
 
void 
1991/0706    
imagereclaim(void) 
{ 
	Page *p; 
 
	if(!canqlock(&ireclaim))	/* Somebody is already cleaning the page cache */ 
		return; 
 
	lock(&palloc); 
	for(p = palloc.head; p; p = p->next) { 
		if(p->image == 0) 
			continue; 
 
		unlock(&palloc); 
		lockpage(p); 
		if(p->ref == 0 && p->image != &swapimage) 
			uncachepage(p); 
		unlockpage(p); 
		lock(&palloc); 
	} 
 
	unlock(&palloc); 
 
	qunlock(&ireclaim); 
} 
 
void 
1991/0705    
putimage(Image *i) 
{ 
	Image *f, **l; 
1991/0705/sys/src/9/port/segment.c:271,2771991/0706/sys/src/9/port/segment.c:307,313
1991/0705    
} 
 
long 
ibrk(ulong addr, int seg)		/* Called with a locked segment */ 
1991/0706    
ibrk(ulong addr, int seg) 
1991/0705    
{ 
	Segment *s, *ns; 
	ulong newtop, newsize; 
1991/0705/sys/src/9/port/segment.c:427,4321991/0706/sys/src/9/port/segment.c:463,470
1991/0705    
	s = seg(u->p, arg[0], 1); 
	if(s == 0) 
		errors("bad segment address"); 
1991/0706    
 
	s->flushme = 1; 
1991/0705    
 
	soff = arg[0]-s->base; 
	j = (soff&(PTEMAPMEM-1))/BY2PG; 


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