git: drawterm

Download patch

ref: d13582b16550a18a1078dbfd2b2b501f579d4a66
parent: 19f9f65cede04b19db1c5bc861119a613f8b91b8
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Nov 16 19:29:21 EST 2025

kernel: don't spin with osyield() on panic()

When screenputs is set and up != nil,
wait using sleep() instead of of spinning
with osyield() - which burned a cpu core.

This is just to not disappear the gui so
one can read the panic message.

--- a/kern/devcons.c
+++ b/kern/devcons.c
@@ -182,6 +182,14 @@
 	return n;
 }
 
+static void
+hang(void)
+{
+	Rendez z = {0};
+	while(up == nil) osyield();
+	for(;;) sleep(&z, return0, 0);
+}
+
 void
 panic(char *fmt, ...)
 {
@@ -191,8 +199,7 @@
 
 	kprintoq = nil;	/* don't try to write to /dev/kprint */
 
-	if(panicking++)
-		for(;;) osyield();
+	if(panicking++) hang();
 	splhi();
 	strcpy(buf, "panic: ");
 	va_start(arg, fmt);
@@ -201,8 +208,7 @@
 	buf[n] = '\n';
 	spllo();
 	putstrn(buf, n+1);
-	while(screenputs != 0)
-		osyield();
+	if(screenputs) hang();
 	setterm(0);
 	exit(1);
 }
--