Reputation: 13
Korea's KAIST Revised and Distributed Pintos KAIST Project The same error occurred in all tests in the project 2 user program, so I am asking you this question. As a result of backtrace, an error appears because the return value of the intr_context() function in the thread_yield() function is false, but I don't know the cause and solution of this error. Can you tell me? ㅠㅠ
Kernel panic in run: PANIC at ../../threads/thread.c:338 in thread_yield(): assertion `!intr_context ()' failed.
Call stack: 0x800421874b 0x80042072c0 0x800420a92f 0x8004214d12 0x8004209704 0x8004209b22 0x800420762b
Translation of call stack:
0x000000800421874b: debug_panic (lib/kernel/debug.c:32)
0x00000080042072c0: thread_yield (threads/thread.c:340)
0x000000800420a92f: sema_up (threads/synch.c:124)
0x0000008004214d12: interrupt_handler (devices/disk.c:526)
0x0000008004209704: intr_handler (threads/interrupt.c:353)
0x0000008004209b22: intr_entry (threads/intr-stubs.o:?)
0x000000800420762b: kernel_thread (threads/thread.c:456)
thread_yield()
/* Yields the CPU. The current thread is not put to sleep and
may be scheduled again immediately at the scheduler's whim. */
void
thread_yield (void) {
struct thread *curr = thread_current ();
enum intr_level old_level;
ASSERT (!intr_context ());
old_level = intr_disable ();
if (curr != idle_thread)
// list_push_back (&ready_list, &curr->elem);
list_insert_ordered (&ready_list, &curr->elem, thread_compare_priority, 0);
do_schedule (THREAD_READY);
intr_set_level (old_level);
}
Upvotes: 0
Views: 885
Reputation: 1
I think your code yield thread in sema_up()
function.
when sema_up()
call thread_yield()
function, you make if condition about priority.
Add !intr_context()
in your if condition.
That means when interrupted by externel(not internal), do not call thread_yield()
.
Then your kernel no longer panic.
Upvotes: 0