-/* $OpenBSD: kern_synch.c,v 1.19 2000/03/03 11:46:09 art Exp $ */
+/* $OpenBSD: kern_synch.c,v 1.20 2000/03/03 16:49:25 art Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*-
u_char curpriority; /* usrpri of curproc */
int lbolt; /* once a second sleep address */
+/*
+ * We need to keep track on how many times we call roundrobin before we
+ * actually attempt a switch (that is when we call mi_switch()).
+ * This is done so that some slow kernel subsystems can yield instead of
+ * blocking the scheduling.
+ */
+int roundrobin_attempts;
+
void roundrobin __P((void *));
void schedcpu __P((void *));
void updatepri __P((struct proc *));
{
need_resched();
+ roundrobin_attempts++;
timeout(roundrobin, NULL, hz / 10);
}
#endif
cpu_switch(p);
microtime(&runtime);
+
+ /*
+ * We reset roundrobin_attempts at exit, because cpu_switch could
+ * have looped in the idle loop and the attempts would increase
+ * leading to unjust punishment of an innocent process.
+ */
+ roundrobin_attempts = 0;
}
/*
-/* $OpenBSD: kernel.h,v 1.5 1996/08/11 20:39:07 niklas Exp $ */
+/* $OpenBSD: kernel.h,v 1.6 2000/03/03 16:49:24 art Exp $ */
/* $NetBSD: kernel.h,v 1.11 1995/03/03 01:24:16 cgd Exp $ */
/*-
extern int lbolt; /* once a second sleep address */
extern int tickdelta;
extern long timedelta;
-
+extern int roundrobin_attempts; /* number switch attempts before switch */