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

more 1.10 patches...



1. here is a reason for dropped characters on modem1...  the kernel itself
did sometimes run at level 7 for long periods of time!  it was also a
cause for the occasional lockup when you start/stop debug messages on
console, and possibly other things too.  i hope this fix is ok (select
calls check_sigs at int level < 7 now), it seems to work for me...

Index: proc.c
@@ -9,7 +9,7 @@
 #include "mint.h"
 #include "xbra.h"
 
-static void do_wakeup_things P_((void));
+static void do_wakeup_things P_((short sr));
 
 extern short proc_clock;
 
@@ -419,7 +419,8 @@
  */
 
 static void
-do_wakeup_things()
+do_wakeup_things(sr)
+short sr;
 {
 /*
  * check for stack underflow, just in case
@@ -429,28 +430,32 @@
 
 	p = curproc;
 
-	if ( p->pid != 0 &&
-	     ((long)&foo) < (long)p->stack + ISTKSIZE + 512 ) {
-		ALERT("stack underflow");
-		handle_sig(SIGBUS);
-	}
+	if ((sr & 0x700) < 0x500) {
+/* skip all this if int level is too high */
+
+		if ( p->pid != 0 &&
+		     ((long)&foo) < (long)p->stack + ISTKSIZE + 512 ) {
+			ALERT("stack underflow");
+			handle_sig(SIGBUS);
+		}
 
 /* see if process' time limit has been exceeded */
 
-	if (p->maxcpu) {
-		if (p->maxcpu <= p->systime + p->usrtime) {
-			DEBUG(("cpu limit exceeded"));
-			raise(SIGXCPU);
+		if (p->maxcpu) {
+			if (p->maxcpu <= p->systime + p->usrtime) {
+				DEBUG(("cpu limit exceeded"));
+				raise(SIGXCPU);
+			}
 		}
-	}
 
 /*
  * check for alarms and similar time out stuff (see timeout.c)
  */
 
-	checkalarms();
-	if (p->sigpending)
-		check_sigs();		/* check for signals */
+		checkalarms();
+		if (p->sigpending)
+			check_sigs();		/* check for signals */
+	}
 
 	proc_clock = TIME_SLICE;	/* get a fresh time slice */
 	p->slices = SLICES(p->curpri);
@@ -481,19 +486,22 @@
  * special keys like CTRL-ALT-Fx
  */
 
-	if (kintr) {
+	sr = spl7();
+	if (kintr && (sr & 0x700) < 0x500) {
+/* can't call checkkeys if sleep was called with interrupts off  -nox */
+		spl(sr);
 		(void)checkkeys();
+		sr = spl7();
 		kintr = 0;
 	}
 
 	if (que == READY_Q && !sys_q[READY_Q]) {
 /* we're just going to wake up again right away! */
-		do_wakeup_things();
+		spl(sr);
+		do_wakeup_things(sr);
 		return (onsigs != curproc->nsigs);
 	}
 
-	sr = spl7();
-
 	add_q(que, curproc);
 	curproc->wait_cond = cond;
 
@@ -558,7 +565,7 @@
 #endif
 			*((void **)0x44eL) = curproc->logbase;
 #endif
-		do_wakeup_things();
+		do_wakeup_things(sr);
 		return (onsigs != curproc->nsigs);
 	}
 /*
Index: dosfile.c
@@ -1053,12 +1053,21 @@
 			t = 0;
 		}
 
+		TRACE(("sleeping in Fselect"));
 		sr = spl7();
 
 	/* curproc->wait_cond changes when data arrives or the timeout happens */
 		while (curproc->wait_cond == (long)wakeselect) {
+#if 0
+/* better not call BIOS with interrupts off, especially not Bconin... :) */
 			TRACE(("sleeping in Fselect"));
+#endif
 			sleep(SELECT_Q, (long)wakeselect);
+			if (curproc->sigpending) {
+				spl(sr);	/* check for signals */
+				check_sigs();
+				sr = spl7();
+			}
 		}
 		spl(sr);
 
2. a new try a reducing those Pexec/Mshrink/Malloc failed races,
give new processes 3 slices and make run_next use its 2nd arg.
(hi Eero, does this help? :)

Index: dosmem.c
@@ -641,9 +641,9 @@
 			}
 
 		/* OK, let's run our new code */
-		/* we guarantee ourselves at least 2 timeslices to do an Mshrink */
+		/* we guarantee ourselves at least 3 timeslices to do an Mshrink */
 			assert(curproc->magic == CTXT_MAGIC);
-			fresh_slices(2);
+			fresh_slices(3);
 			leave_kernel();
 			change_context(&(curproc->ctxt[CURRENT]));
 		}
@@ -652,7 +652,7 @@
 	/* so we temporarily give it high priority and put it first on the
 	 * run queue
 	 */
-			run_next(p, 2);
+			run_next(p, 3);
 		}
 	}
 
@@ -697,6 +697,8 @@
 		yield();	/* let the new process run */
 		return newpid;
 	} else {
+		/* guarantee ourselves at least 3 timeslices to do an Mshrink */
+		fresh_slices(3);
 		TRACE(("leaving Pexec with basepage address %lx", base->loc));
 		return base->loc;
 	}
Index: proc.c
@@ -290,8 +290,10 @@
 	PROC *p;
 
 	for (p = proclist; p; p = p->gl_next) {
-		p->curpri = p->pri;
-		p->slices = SLICES(p->curpri);
+		if (p->slices >= 0) {
+			p->curpri = p->pri;
+			p->slices = SLICES(p->curpri);
+		}
 	}
 }
 
@@ -307,11 +309,9 @@
 void
 run_next(p, slices)
 	PROC *p;
-	int slices;	/* BUG: currently ignored */
+	int slices;
 {
-	UNUSED(slices);
-
-	p->slices = 0;
+	p->slices = -slices;
 	p->curpri = MAX_NICE;
 	p->wait_q = READY_Q;
 	p->q_next = sys_q[READY_Q];
@@ -352,7 +352,7 @@
 	}
 	*lastq = proc;
 	proc->wait_q = que;
-	if (que != READY_Q) {
+	if (que != READY_Q && proc->slices >= 0) {
 		proc->curpri = proc->pri;	/* reward the process */
 		proc->slices = SLICES(proc->curpri);
 	}
@@ -457,7 +457,12 @@
 			check_sigs();		/* check for signals */
 	}
 
-	proc_clock = TIME_SLICE;	/* get a fresh time slice */
+	if (p->slices >= 0) {
+		proc_clock = TIME_SLICE;	/* get a fresh time slice */
+	} else {
+		proc_clock = -p->slices;	/* slices set by run_next */
+		p->curpri = p->pri;
+	}
 	p->slices = SLICES(p->curpri);
 }
 
3. remove zombie when the real parent of a traced process woke up first

Index: dosmem.c
@@ -1157,7 +1157,8 @@
 		/* deliver the signal to the tracing process first */
 			TRACE(("Pwaitpid(ptracer): returning status to tracing process"));
 			p->ptracer = NULL;
-			return r;
+			if (p->ppid != -1)
+				return r;
 		}
 		else {
 		/* Hmmm, the real parent got here first */

 cheers
	Juergen
-- 
J"urgen Lock / nox@jelal.north.de / UUCP: ..!uunet!unido!uniol!jelal!nox
								...ohne Gewehr
PGP public key fingerprint =  8A 18 58 54 03 7B FC 12  1F 8B 63 C7 19 27 CF DA