changelog shortlog tags branches changeset file revisions annotate raw help

Mercurial > hg > plan9front / sys/src/9/port/swap.c

revision 4349: b36183064b7a
parent 3768: b5d8ba40f91b
child 4590: f59bee1b3aee
     1.1--- a/sys/src/9/port/swap.c
     1.2+++ b/sys/src/9/port/swap.c
     1.3@@ -7,7 +7,6 @@
     1.4 
     1.5 static int	canflush(Proc*, Segment*);
     1.6 static void	executeio(void);
     1.7-static int	needpages(void*);
     1.8 static void	pageout(Proc*, Segment*);
     1.9 static void	pagepte(int, Page**);
    1.10 static void	pager(void*);
    1.11@@ -166,24 +165,21 @@ pager(void*)
    1.12 		}
    1.13 
    1.14 		if(swapimage.c == nil || swapalloc.free == 0){
    1.15+		Killbig:
    1.16 			killbig("out of memory");
    1.17 			freebroken();		/* can use the memory */
    1.18 			sched();
    1.19 			continue;
    1.20 		}
    1.21 
    1.22-		p++;
    1.23-		if(p >= ep){
    1.24-			p = proctab(0);
    1.25-			ageclock++;
    1.26-		}
    1.27-
    1.28-		if(p->state == Dead || p->noswap)
    1.29-			continue;
    1.30-
    1.31-		if(!canqlock(&p->seglock))
    1.32-			continue;		/* process changing its segments */
    1.33-
    1.34+		i = ageclock;
    1.35+		do {
    1.36+			if(++p >= ep){
    1.37+				if(++ageclock == i)
    1.38+					goto Killbig;
    1.39+				p = proctab(0);
    1.40+			}
    1.41+		} while(p->state == Dead || p->noswap || !canqlock(&p->seglock));
    1.42 		up->psstate = "Pageout";
    1.43 		for(i = 0; i < NSEG; i++) {
    1.44 			if((s = p->seg[i]) != nil) {
    1.45@@ -239,9 +235,9 @@ pageout(Proc *p, Segment *s)
    1.46 	size = s->mapsize;
    1.47 	for(i = 0; i < size; i++) {
    1.48 		l = s->map[i];
    1.49-		if(l == 0)
    1.50+		if(l == nil)
    1.51 			continue;
    1.52-		for(pg = l->first; pg < l->last; pg++) {
    1.53+		for(pg = l->first; pg <= l->last; pg++) {
    1.54 			entry = *pg;
    1.55 			if(pagedout(entry))
    1.56 				continue;
    1.57@@ -389,7 +385,7 @@ executeio(void)
    1.58 	ioptr = 0;
    1.59 }
    1.60 
    1.61-static int
    1.62+int
    1.63 needpages(void*)
    1.64 {
    1.65 	return palloc.freecount < swapalloc.headroom;