git: 9front

Download patch

ref: 54cbf2feba92191798d5d2a3c2f996726eddd049
parent: 686db0feaa2afbe6602bb2813a715493767cb911
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Sun May 26 21:04:53 EDT 2013

kernel: image reclaim pauses

get a bit more verbose about process image exhaustion and make
imagreclaim() try to get at least one image on the freelist.

use rsrcwait() to notify the state, and call freebroken() in
case imagereclaim() couldnt free any images.

--- a/sys/src/9/port/segment.c
+++ b/sys/src/9/port/segment.c
@@ -264,7 +264,10 @@
 	while(!(i = imagealloc.free)) {
 		unlock(&imagealloc);
 		imagereclaim();
-		sched();
+		if(!imagealloc.free){
+			freebroken();		/* can use the memory */
+			resrcwait("no image after reclaim");
+		}
 		lock(&imagealloc);
 	}
 
@@ -328,7 +331,7 @@
 	 * end of the list (see putpage) so start there and work
 	 * backward.
 	 */
-	for(p = palloc.tail; p && p->image && n<1000; p = p->prev) {
+	for(p = palloc.tail; p && p->image && (n<1000 || !imagealloc.free); p = p->prev) {
 		if(p->ref == 0 && canlock(p)) {
 			if(p->ref == 0) {
 				n++;
--