From b2f3c5f4e799126b7ea1f74c4c9c26668dbdf6d8 Mon Sep 17 00:00:00 2001 From: James Foster Date: Fri, 8 May 2020 19:38:39 -0700 Subject: [PATCH] Use spinlock for logging to avoid interleaving output. --- k-hardware.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/k-hardware.cc b/k-hardware.cc index 92e7f1c..71b77f2 100644 --- a/k-hardware.cc +++ b/k-hardware.cc @@ -171,7 +171,11 @@ struct log_printer : public printer { }; } +// things get ugly when multiple processes output at the same time! +static spinlock printLock; + void log_vprintf(const char* format, va_list val) { + spinlock_guard guard(printLock); log_printer p; p.vprintf(0, format, val); }