From 8b805d179d0bd022182491d91584280a83eb451d Mon Sep 17 00:00:00 2001 From: Godmar Back Date: Fri, 7 Nov 2008 23:48:13 -0500 Subject: [PATCH 1/1] added note regarding console lock --- doc/threads.texi | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/threads.texi b/doc/threads.texi index 8dad172..b13b545 100644 --- a/doc/threads.texi +++ b/doc/threads.texi @@ -787,11 +787,19 @@ What is happening is that output from two threads is being interleaved. That is, one thread is printing @code{"(alarm-priority) Thread priority 29 woke up.\n"} and another thread is printing @code{"(alarm-priority) Thread priority 30 woke up.\n"}, but the first -thread is being interrupted by the second in the middle of its output. +thread is being preempted by the second in the middle of its output. This problem indicates a bug in your priority scheduler. After all, a thread with priority 29 should not be able to run while a thread with priority 30 has work to do. + +Normally, the implementation of the @code{printf()} function in the +Pintos kernel attempts to prevent such interleaved output by acquiring +a console lock during the duration of the @code{printf} call and +releasing it afterwards. However, the output of the test name, +e.g., @code{(alarm-priority)}, and the message following it is output +using two calls to @code{printf}, resulting in the console lock being +acquired and released twice. @end table @node Advanced Scheduler FAQ -- 2.30.2