-
Chapter 10: Virtual Memoryos 2020. 11. 28. 18:49
Background
에러코드, 잘 사용되지 않는 프로그램, 큰 데이터 구조는 잘 사용하지 않는다.
-> 처음부터 동시에 그 프로그램들이 메모리 상에 올라갈 필요가 없다.
-> 동적으로 Load가 된다.
-> 이러면서 응답시간이 빨라진다
-> I/O 적게 할 수 있다
Virtual memory
-> logical memory과 physical memory 구분해 준다
-> logical memory이 physical memory 보다 클 수 있다.
-> I/O작업을 적게 하기위해 스와핑이 필요하다.
Virtual address space
프로세스의 관점에서 본 메모리에 저장된 있는 것을 공간이다
0부터 얼마만큼 떨어져 있는가
등등
Demand Paging
Swap in
Swap out
Page is needed-> 그것을 reference
잘못된 reference -> 중단
Not-in-memory -> 메모리에서 가져온다
Reference(참조한다)
그 페이지를 참조한다
Lazy swapper
Page에서 필요하지 않으면, page를 메모리로 바꾸지 않는다
Valid-Invalid Bit
페이지 테이블을 봤을 때,
page fault: 프로그램이 주소 공간에는 있지만, 메모리에는 없는 현상
-> 자주 발생하면 안좋다
Page Fault
발생 할 때,
OS가 보는 것
테이블을 본다
-> 메모리에 있다 정지
-> 메모리에 없다
빈 공간 찾는다
- Swap page into frame via scheduled disk operation
- Reset tables to indicate page now in memory
Set validation bit = v - Restart the instruction that caused the page fault
Aspects of Demand Paging
locality of reference
Locality(지역성)
Reference(어떠한 페이지를 찾는 것)
-> 참조하는 것에 대해서 지역성을 띤다, 일정한 지역을 계속 참조하게 된다
-> 빠르다
-> 그래서 가상 메모리를 만들 수 있다.
Performance of Demand Paging
Demand Paging 단계 -> 페이지를 요청하는 것
1. OS로 넘어간다
2. 현제 실행되는 프로세스의 정보를 정자
3. 어떤 인터럽이 걸렸는지 판다
4. 필요한 페이지를 디스크에서 찾는다
5. 있으면, 디스크에서 필요한 페이지를 찾는다. 3단계가 있다
6. While waiting, allocate the CPU to some other user
7. Receive an interrupt from the disk I/O subsystem (I/O completed)
8. Save the registers and process state for the other user
9. Determine that the interrupt was from the disk
10. Correct the page table and other tables to show page is now in memory
11. Wait for the CPU to be allocated to this process again
12. Restore the user registers, process state, and new page table, and then resume the interrupted instruction
Demand Paging 걸리는 시간
Effective Access Time (EAT)
EAT = (1 – p) x memory access\
p (page fault overhead -> page fault를 처리하는 시간
swap page out
swap page in)
Page Fault Rate(걸릴 확률)
What Happens if There is no Free Frame?
No free frame이면
-> 스와핑이 필요하다
I/O작업이 필요하다
Page replacement
메모리에서 page를 찾아서, 그것이 사용되지 않는 것이면, page out한다
-> 알고리즘이 필요하다
-> page 결함을 최소한으로 발생시키길 원한다.
Page Replacement
modify (dirty) bit
그 페이지가 데이터 값 or 코드 값이 어떻게 바꿔졌는지 나타내는 것이다
-> 시간을 줄여 주기 위해서
코드값이 안바꿔 졌으면, 필요한 페이지를 디스크에서 스와인 만 해주면 된다.
Basic Page Replacement
과정 다시 보기
If there is no free frame, use a page replacement algorithm to select a victim frame(희생양)
Page Replacement
Page and Frame Replacement Algorithms
참조 열
7,0,1,2,0,3,0,4,2,3,0,3,0,3,2,1,2,0,1,7,0,1
-> 페이지 번호를 나타낸다
Graph of Page Faults Versus The Number of Frames
'os' 카테고리의 다른 글
Chapter 9: Main Memory (0) 2020.11.04 Chapter 8: Deadlocks (0) 2020.10.26 Chapter 6: Synchronization Tools (0) 2020.10.16 Chapter 2: Operating-System Structures (0) 2020.10.11 Chapter 5: CPU Scheduling (0) 2020.09.28