Skip to content

[HJ] feat: Swap_in + Swap_out #37

@Kimhyeog

Description

@Kimhyeog
  1. vm/vm.h & vm/vm.c (Frame Table 기본 구조)
  • struct frame 구조체 수정: list_elem 필드 추가
  • struct frame 구조체 수정: owner (페이지 포인터) 필드 추가
  • vm.c 전역 변수 선언: frame_table (리스트)
  • vm.c 전역 변수 선언: clock_elem (또는 start_elem 포인터)
  • vm.c 전역 변수 선언: lock (동기화 용)
  • vm_init(): 리스트 및 락 초기화 구현
  • vm_get_frame(): palloc_get_page 성공 시 frame_table에 list_push_back 구현
  1. vm/anon.c (Anonymous Page & Swap Disk)
  • vm_anon_init(): 스왑 디스크(disk_get) 가져오기
  • vm_anon_init(): 스왑 비트맵(bitmap_create) 생성
  • anon_swap_out(): 비트맵에서 빈 슬롯(false) 탐색 (bitmap_scan_and_flip)
  • anon_swap_out(): 디스크의 해당 섹터에 페이지 내용 쓰기 (disk_write)
  • anon_swap_out(): page->anon.swap_index에 슬롯 인덱스 저장
  • anon_swap_in(): page->anon.swap_index 확인
  • anon_swap_in(): 디스크 해당 섹터에서 데이터 읽어오기 (disk_read)
  • anon_swap_in(): 작업 완료 후 비트맵 해당 슬롯 비우기 (bitmap_set false)
  1. vm/vm.c (Eviction Policy - Clock Algorithm)
  • vm_get_victim(): frame_table을 순회하는 Clock 알고리즘 루프 구현
  • vm_get_victim(): pml4_is_accessed로 접근 비트 확인
  • vm_get_victim(): 접근 비트가 1이면 0으로 내리고 다음(next)으로 이동
  • vm_get_victim(): 접근 비트가 0인 페이지를 찾아 희생자(victim)로 선정
  • vm_evict_frame(): vm_get_victim 호출하여 페이지 선정
  • vm_evict_frame(): 선정된 페이지에 대해 swap_out 호출
  • vm_evict_frame(): 해당 프레임을 비우고(memset 등) 포인터 리턴

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions