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

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

ํฌ๋ž˜ํ”„ํ†ค ์ •๊ธ€ WEEK11 DAY 88 - PintOS Project3 - Memory Mapped Files ์™„์„ฑ ๋ณธ๋ฌธ

Krafton jungle

ํฌ๋ž˜ํ”„ํ†ค ์ •๊ธ€ WEEK11 DAY 88 - PintOS Project3 - Memory Mapped Files ์™„์„ฑ

habbn 2024. 4. 3. 21:43
728x90

๐Ÿ“†2024.04.03

 

 

๐Ÿšซ  mmap-exit ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค ๋ฌธ์ œ

 

ํ•ด๋‹น ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋ฅผ ํ†ต๊ณผํ•˜๋ ค๋ฉด process_exit ๋ฅผ ์ˆ˜์ •ํ•ด์•ผ ํ•œ๋‹ค.

void process_exit (void) {
    struct thread *t = thread_current();

    /* TODO: Your code goes here.
     * ์—ฌ๊ธฐ์„œ ํ”„๋กœ์„ธ์Šค ์ž์› ์ •๋ฆฌ๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•œ๋‹ค.
     * ํ”„๋กœ์„ธ์Šค๊ฐ€ ์ข…๋ฃŒ๋˜๋Š” ๊ฒฝ์šฐ ๋ชจ๋“  ํŒŒ์ผ์„ ์•”์‹œ์ ์œผ๋กœ ๋‹ซ๋Š”๋‹ค.
     */

    // ์Šค๋ ˆ๋“œ์˜ ํŒŒ์ผ ๋‹ซ๊ธฐ
    file_close(t->self_file);
    for (int fd = 2; fd < FDT_SIZE; fd++) {
        if (t->fdt[fd] != NULL) {
            close(fd);
        }
    }
    palloc_free_multiple(t->fdt, FDT_PAGES);
    process_cleanup ();
    hash_destroy(&t->spt.hash_table , NULL);
    sema_up(&t->wait_sema);
    sema_down(&t->exit_sema);
}

 

๋ฐ”๋กœ hash_destroy() ๋ฅผ ์ถ”๊ฐ€ํ•ด์•ผ ํ•˜๋Š”๋ฐ ์ˆœ์„œ๊ฐ€ ๊ผญ process_cleanup()์•„๋ž˜์— ์™€์•ผํ•œ๋‹ค.

 

์ด์œ ๋Š” process_cleanup ํ•จ์ˆ˜์—์„œ supplemental_page_table_kill ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜๊ณ  , ์ด ํ•จ์ˆ˜ ์•ˆ์—์„œ hash_clear() ํ•จ์ˆ˜๋กœ ์ธํ•ด spt์˜ ๋ฆฌ์†Œ์Šค๊ฐ€ ํ•ด์ œ๋˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

static void
process_cleanup (void) {
    struct thread *curr = thread_current ();

#ifdef VM
    supplemental_page_table_kill (&curr->spt);
#endif
void supplemental_page_table_kill(struct supplemental_page_table *spt UNUSED)
{
    /* TODO: Destroy all the supplemental_page_table hold by thread and
     * TODO: writeback all the modified contents to the storage. */

    /* ์Šค๋ ˆ๋“œ์— ์˜ํ•ด ๋ณด์œ ๋œ ๋ชจ๋“  ๋ณด์กฐ ํŽ˜์ด์ง€ ํ…Œ์ด๋ธ”์„ ํŒŒ๊ดดํ•˜๊ณ 
     * ๋ณ€๊ฒฝ๋œ ๋ชจ๋“  ๋‚ด์šฉ์„ ์ €์žฅ์†Œ์— ๊ธฐ๋กํ•˜์„ธ์š”. */

    hash_clear(&spt->hash_table, page_destroy);
    // hash_destroy(&spt->hash_table, page_destroy);
}

 

๋˜ํ•œ hash_destory(, NULL)์ธ ์ด์œ ๋Š” hash_clear๋กœ ์ธํ•ด hash๊ฐ€ ๋‹ค ์ง€์›Œ์ ธ ์žˆ์–ด์„œ buckets๋งŒ ์ง€์šฐ๋ฉด ๋˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

void
hash_destroy (struct hash *h, hash_action_func *destructor) {
    if (destructor != NULL)
        hash_clear (h, destructor);
    free (h->buckets);
}

 

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ๋ฌธ์ œ ํ•ด๊ฒฐ~!

 

๐ŸšซFAIL tests/vm/page-merge-par , FAIL tests/vm/page-merge-stk ,FAIL tests/vm/page-merge-mm

 

๋‹ค๋ฅธ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋Š” ๋‹ค ํ†ต๊ณผํ–ˆ๋Š”๋ฐ ์ € 3๊ฐœ์˜ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋งŒ ๊ณ„์† FAIL์ด์—ˆ๋‹ค.

์ด์œ ๋ฅผ ๋ชจ๋ฅด๊ฒ ์–ด์„œ ๊ฒ€์ƒ‰ํ•ด๋ณด๋‹ˆ lock์„ ๊ฑธ์–ด์ค˜์•ผ ๋˜๋Š” ๋ถ€๋ถ„์— lock์„ ์•ˆ ๊ฑธ์–ด์„œ๋ผ๊ณ  ํ•ด๋‹น ํ…Œ์ŠคํŠธ์ผ€์ด์Šค์—์„œ ํ˜ธ์ถœ๋˜๋Š” syscall์—๋Š” ๋‹ค lock์„ ๊ฑธ์œผ๋ผ๊ณ  ํ–ˆ๋‹ค.

์ผ๋‹จ create() ์— lock์„ ๊ฑธ์—ˆ๋”๋‹ˆ ์ฒซ ๋ฒˆ์žฌ page-merge-par ํ…Œ์ŠคํŠธ๊ฐ€ ํ†ต๊ณผ๋˜์—ˆ๋‹ค!

bool create(const char *file, unsigned initial_size) {
	lock_acquire(&filesys_lock);
	check_address(file);
	bool success = filesys_create(file, initial_size); 
	lock_release(&filesys_lock);
	return success;
}

 

๊ทผ๋ฐ ๋ณต๋ถˆ๋ณต์œผ๋กœ ํ†ต๊ณผ๊ฐ€ ๋˜๊ณ  ๋‚˜๋จธ์ง€ 2๊ฐœ๋Š” ์ „ํ˜€ ๋ชจ๋ฅด๊ฒ ๋‹ค ใ… ใ… ใ… ใ… 

 

์ด ํ…Œ์ŠคํŠธ ๊ฒฐ๊ณผ

3 of 141 tests failed

 

 

728x90