[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bios Polling



I have hacked the following into my kernel.  Its not the best possible
solution (nasty goto's are used for speed - everything else was slower).
Maybe someone can clean it up, or instead of just changing priorities, maybe
cause polling processes to select() on all the file handles they are
polling on?

Anyway .. it helps .. a little ...

--- bios.c.mh3	Tue Jan  1 00:00:00 1980
+++ bios.c	Tue Jan  1 00:00:00 1980
@@ -399,6 +399,10 @@
  * the "real" device and calls bconstat.
  */
 
+#ifndef SLICES
+#define SLICES(pri)	(((pri) >= 0) ?  0 : -(pri))
+#endif
+
 /*
  * WARNING: syscall.spp assumes that ubconstat never blocks.
  */
@@ -408,10 +412,27 @@
 {
 	if (dev < MAX_BHANDLE) {
 		FILEPTR *f = curproc->handle[binput[dev]];
-		return file_instat(f) ? -1 : 0;
+		if (file_instat(f))
+			goto reset;
+		else	goto punish;
+	} else {
+		if (bconstat(dev)) {
+
+	/* Data is coming - quick! We need some CPU! */
+reset:
+			curproc->slices = SLICES(curproc->curpri);
+			curproc->curpri = curproc->pri;
+			return -1;
+
+		} else {
+
+	/* Process is polling like mad - punish it! */
+punish:
+			if (curproc->curpri > MIN_NICE)
+				curproc->curpri -= 1;
+			return 0;
+		}
 	}
-	else
-		return bconstat(dev);
 }
 
 long



------------------------------------------------------------------
Comments?