๊ด€๋ฆฌ ๋ฉ”๋‰ด

๋ง๊ฐ๋กœ๊ทธ

ํฌ๋ž˜ํ”„ํ†ค ์ •๊ธ€ WEEK08 DAY66 - PintOS Project2 kernel panic error ๋ณธ๋ฌธ

Krafton jungle

ํฌ๋ž˜ํ”„ํ†ค ์ •๊ธ€ WEEK08 DAY66 - PintOS Project2 kernel panic error

habbn 2024. 3. 14. 00:30
728x90
๐Ÿ“†2024.3.13

1.๋ฐฑ์ค€
2. pintos - project2  kernel panic error  ํ•ด๊ฒฐ

 

๋ฐฑ์ค€ 1927 ์ตœ์†Œ ํž™

 

์ฒ˜์Œ์— ๋ญ์•ผ ๋„ˆ๋ฌด ์‰ฝ์ž๋‚˜? ๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉฐ ํ’€์—ˆ์ง€๋งŒ ๊ฒฐ๊ตญ ์‹œ๊ฐ„ ์ดˆ๊ณผ..

๋ฐ”๋ณด๊ฐ™์ด ์ตœ์†Œ ํž™์ธ๋ฐ heapq๋ฅผ ์•ˆ์“ฐ๊ณ  ํ’€๋ ค๊ณ  ํ–ˆ์—ˆ๋‹ด.

heapq ์จ์„œ ์™„๋ฃŒ!

import heapq
import sys
input = sys.stdin.readline

N = int(input())
heap = []
for i in range(N):
    x = int(input())
    if x > 0:
        heapq.heappush(heap, x)       
    if x == 0:
        if len(heap) == 0:
            print(0)
        else:
            print(heapq.heappop(heap))

 

 

PintOS - Project 2 USER PROGRMAS

๐ŸšซKernel panic - thread_yield() ์—๋Ÿฌ....

pintos ๊ฐ€์ƒ ๋จธ์‹ ์— ํŒŒ์ผ์„ ๋„ฃ๊ธฐ ์œ„ํ•ด์„œ ๋‹น์‹ ์€ ๋จผ์ € ํŒŒ์ผ ์‹œ์Šคํ…œ ํŒŒํ‹ฐ์…˜์ด ์žˆ๋Š” ๋ชจ์˜ ๋””์Šคํฌ(simulated disk)๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ์–ด์•ผ ํ•œ๋‹ค.

pintos-mkdisk filesys.dsk 10 
pintos --fs-disk filesys.dsk -p tests/userprog/args-single:args-single -- -q -f run 'args-single onearg'

์œ„์˜ ์ฝ”๋“œ๋Š” ํŒŒ์ผ ์‹œ์Šคํ…œ ํŒŒํ‹ฐ์…˜์œผ๋กœ ์–ด๋–ป๊ฒŒ ๋””์Šคํฌ๋ฅผ ์ƒ์„ฑํ•˜๊ณ , ํŒŒ์ผ ์‹œ์Šคํ…œ์˜ ํ˜•์‹์„ ๋งŒ๋“ค๊ณ , args-single ์ด๋ผ๋Š” ์ด๋ฆ„์˜ ํ”„๋กœ๊ทธ๋žจ(์ด๋ฒˆ ํ”„๋กœ์ ํŠธ์˜ ๋‘๋ฒˆ์งธ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค)๋ฅผ ์–ด๋–ป๊ฒŒ ์ƒˆ ๋””์Šคํฌ์— ๋งŒ๋“ค๊ณ , onearg ๋ผ๋Š” ์ธ์ž๋ฅผ ์ „๋‹ฌํ•ด์„œ ์‹คํ–‰ํ•˜๋Š”์ง€(์ธ์ž๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ๋ถ€๋ถ„์„ ๊ตฌํ˜„ํ•ด์•ผ ์ธ์ž ์ „๋‹ฌ์ด ๊ฐ€๋Šฅํ• ๊ฒ๋‹ˆ๋‹ค) ์— ๋Œ€ํ•œ ์š”์•ฝ ์ฝ”๋“œ์ด๋‹ค.

 

์ด ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•˜๊ฒŒ ๋˜๋ฉด 

Kernel PANIC at ../../threads/vaddr.h:87 in vtop(): assertion 
`is_kernel_vaddr (vaddr)' failed.

 

kernel panic์„ ๋งˆ์ฃผํ•˜๊ฒŒ ๋œ๋‹ค.

 

backtrace

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)

 

์ด ์˜ค๋ฅ˜๋Š” ํ”„๋กœ์ ํŠธ 1์—์„œ priority sheduling์„ ์œ„ํ•ด sema_up ํ•จ์ˆ˜์—์„œ thread_yield ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•œ ๊ฒƒ์ด ๋ฌธ์ œ์˜€๋‹ค.

ํŒŒ์ผ ์‹œ์Šคํ…œ์—์„œ sema_up์„ ํ˜ธ์ถœํ•  ๋•Œ externel interrupt๋ฅผ ๋„์ง€ ์•Š์•„์„œ assert๊ฐ€ ๋ฐœ์ƒํ•œ ๋ฌธ์ œ๋ผ๊ณ  ํ•œ๋‹ค.

 

๊ทธ๋ž˜์„œ 

thread.c ์—์„œ thread_try_yield() ํ•จ์ˆ˜๋ฅผ ์ƒ์„ฑํ•ด์ฃผ๊ณ 

void thread_try_yield(void){
	if(!list_empty(&ready_list) && thread_current() != idle_thread && !(intr_context()))
		thread_yield();
}

 

synch.c sema_up() ๋ถ€๋ถ„๋„ ์ˆ˜์ •ํ•˜๋ฉด ์—๋Ÿฌ ํ•ด๊ฒฐ!

void
sema_up (struct semaphore *sema) {
	enum intr_level old_level;

	ASSERT (sema != NULL);

	old_level = intr_disable ();

	if (!list_empty (&sema->waiters))
	{
		list_sort(&sema->waiters, cmp_priority, NULL);
		//sema->waiters์— ์žˆ๋Š” ๋งจ ์•ž ์“ฐ๋ ˆ๋“œ๋ฅผ ๊นจ์šด๋‹ค.
		thread_unblock (list_entry (list_pop_front (&sema->waiters),
				struct thread, elem));			
	}

	sema->value++;

	intr_set_level (old_level);	
	
	//cpu ์–‘๋ณด
	thread_try_yield();
}

 


 

ํ”„๋กœ์ ํŠธ 2ํ•˜๋ฉด์„œ ..
์–ป์€๊ฒŒ ์—†๋‹ค....

์•„๋ฌด๊ฒƒ๋„ ๋ชจ๋ฅด๊ฒ ๋‹ค....

๋ง‰๋ง‰ํ•˜๋‹ค....

๋‚ด์ผ์€ ๋ฌด์กฐ๊ฑด ํ•˜๋‚˜๋ผ๋„ ํ’€์–ด๋‚ด์•ผ๊ฒ ๋‹ค....

 

 

 

728x90