
Pintos Project 3 한국어 설명서 (design report) - Virtual Memory, Frame table
본 내용은
"
Pintos Project 3 한국어 설명서 (design report) - Virtual Memory, Frame table
"
의 원문 자료에서 일부 인용된 것입니다.
2024.06.15
문서 내 토픽
-
1. Virtual MemoryVirtual memory는 process마다 독립적으로 가지는 주소 공간으로, 필요한 데이터는 virtual memory에서 physical memory로 load해오고 필요없는 데이터는 virtual memory (예: 디스크)에 저장함으로써 physical memory 공간을 확보합니다. 각 process는 virtual address와 physical address를 mapping하는 table을 가지고 있어 virtual address로 physical address를 찾아갈 수 있습니다. virtual address는 page의 형태로 디스크에 저장되어 있으며, 필요할 때마다 physical memory로 swap in되어 사용됩니다.
-
2. Frame TableFrame table은 physical memory에 할당된 frame들로 구성된 table로, 각 table entry는 page로의 포인터, 즉 해당 frame의 소유주를 가리킵니다. frame을 allocate, deallocate하는 과정에서 Frame Table이 사용되며, frame이 부족할 때 제거할 page를 결정합니다. kernel virtual memory는 physical memory에 1대1 mapping되어 있으므로 physical memory는 virtual memory를 통해 접근할 수 있습니다.
-
3. Page Faultpage fault는 kernel virtual memory에 접근하려는 경우 발생하고 process가 종료됩니다. user virtual memory는 user virtual memory에만 접근이 가능하기 때문입니다. 또한 kernel virtual memory가 mapping되지 않은 user virtual address에 접근하려는 경우에도 page fault가 발생하고 process가 종료됩니다.
-
4. Memory AllocationPintos는 page allocator와 block allocator 두 종류의 memory allocator를 가집니다. page allocator는 page 단위로 memory를 할당하며, block allocator는 임의 크기의 block 단위로 memory를 할당합니다. page allocator는 kernel pool과 user pool로 구분되어 관리됩니다.
-
5. Hash Table기존의 Pintos에 존재하는 page table은 virtual memory와 physical memory간 mapping을 관리하는 역할을 합니다. 이때 hash table data structure의 위치는 lib/kernel/hash.c에 있습니다.
-
6. Pagingpaging은 virtual memory의 page를 physical memory의 frame으로 mapping하는 방법입니다. VPN(Virtual Page Number)를 PFN(Physical Frame Number)로 mapping하는 과정에서 page table이 사용됩니다. 각 process는 자신만의 page table을 독립적으로 가지고 있으며, 각 process의 page table이 저장되어 있는 주소를 page table base register가 저장하고 있습니다.
-
7. Lazy Loadinglazy loading은 필요한 데이터를 메모리에 로드하는 것을 미루는 기법으로, 실행에 필요한 데이터를 모두 메모리에 로드하지 않고 최소한의 정보만 넣어둔 뒤 page fault가 발생하면 그때 로드를 수행합니다.
-
8. File Memory Mappingfile memory mapping은 기존의 file 입출력 시스템 호출을 사용하지 않고 process의 virtual memory 주소 공간에 file을 mapping한 후 이에 접근하여 file을 사용하는 기법입니다. 이를 통해 buffer를 사용하여 데이터를 복사할 필요가 없어 file 입출력 시스템 호출마다 발생하는 overhead를 줄일 수 있습니다.
-
9. Swap Tableswap table은 swap disk의 사용 현황을 관리하는 자료구조로, 사용되지 않고 있는 swap slot을 찾아 page를 swap out하고 swap in하는 데 사용됩니다.
-
10. Process Terminationprocess가 종료될 때 할당했던 모든 자원들을 해제해야 합니다. 이때 supplemental page table, frame table, swap table 내의 모든 내용들 및 table을 해제하고 열린 모든 파일들을 닫아야 합니다.
-
1. Virtual MemoryVirtual memory is a fundamental concept in computer operating systems that allows programs to access more memory than is physically available on the system. It provides the illusion of a large, contiguous address space by mapping it to the available physical memory. This abstraction allows programs to run without being constrained by the physical memory limitations, improving overall system efficiency and utilization. Virtual memory enables features like demand paging, where pages are loaded into memory only when needed, and allows for the implementation of memory protection mechanisms to isolate processes and prevent unauthorized access. The efficient management of virtual memory is crucial for the performance and stability of modern computer systems, as it enables the execution of complex applications and the sharing of resources among multiple processes.
-
2. Frame TableThe frame table is a critical data structure used in virtual memory management systems. It is responsible for keeping track of the mapping between virtual memory pages and their corresponding physical memory frames. The frame table stores information such as the physical frame number, the status of the frame (e.g., free, allocated, or shared), and any additional metadata required for page management. This table allows the operating system to quickly translate virtual addresses to their physical counterparts, enabling efficient memory access and page replacement strategies. The frame table is essential for implementing features like demand paging, page swapping, and memory protection, which are fundamental to the effective utilization of virtual memory. The design and optimization of the frame table can have a significant impact on the overall performance and scalability of a virtual memory system, making it a crucial component in the architecture of modern operating systems.
-
3. Page FaultA page fault is a critical event that occurs in a virtual memory system when a program attempts to access a virtual memory page that is not currently present in physical memory. When a page fault occurs, the operating system must handle the situation by bringing the required page into memory from secondary storage, such as a hard disk or solid-state drive. This process can be time-consuming and can significantly impact the performance of the system. Page faults can occur for various reasons, such as when a program accesses a page that has been swapped out to disk, or when a program attempts to access a page that has not yet been allocated. The efficient handling of page faults is crucial for the overall performance and responsiveness of a virtual memory system. Operating systems employ various strategies, such as page replacement algorithms and memory management techniques, to minimize the occurrence of page faults and optimize the handling of these events when they do occur. Understanding and optimizing the management of page faults is a key aspect of virtual memory system design and implementation.
-
4. Memory AllocationMemory allocation is a fundamental aspect of virtual memory management in computer systems. It involves the process of assigning physical memory frames to the virtual memory pages requested by running processes. Effective memory allocation strategies are crucial for ensuring efficient utilization of available physical memory and providing a seamless execution environment for applications. Operating systems employ various memory allocation techniques, such as fixed-size partitioning, variable-size partitioning, and dynamic memory allocation, to manage the allocation and deallocation of memory blocks. These techniques aim to balance factors like memory fragmentation, memory utilization, and performance. Memory allocation is closely tied to other virtual memory concepts, such as paging, swapping, and memory protection, as the operating system must coordinate these mechanisms to provide a coherent and efficient memory management system. Optimizing memory allocation strategies is an ongoing challenge in operating system design, as it directly impacts the overall system performance, responsiveness, and the ability to support a diverse range of applications and workloads.
-
5. Hash TableHash tables are a fundamental data structure used in virtual memory management systems, particularly in the context of page table implementation. In a virtual memory system, the page table is responsible for mapping virtual memory addresses to their corresponding physical memory locations. Hash tables provide an efficient way to implement and manage these mappings, allowing for fast lookup and retrieval of page table entries. By using a hash function to index into the table, the operating system can quickly locate the appropriate physical frame number for a given virtual address, reducing the time required for address translation. Hash tables also enable efficient handling of page faults, as the operating system can quickly determine if a virtual page is present in memory or needs to be fetched from secondary storage. Additionally, hash tables can help mitigate the problem of memory fragmentation by allowing for dynamic resizing and rehashing of the table as the memory usage patterns change. The effective design and implementation of hash tables in the context of virtual memory management is crucial for achieving high performance and scalability in modern computer systems.
-
6. PagingPaging is a fundamental concept in virtual memory management that allows the operating system to efficiently utilize physical memory by dividing it into fixed-size units called pages. This approach enables the mapping of a large, contiguous virtual address space to the available physical memory, which may be fragmented or smaller than the virtual address space. Paging provides several key benefits, such as demand-based loading of pages, efficient memory utilization, and the ability to implement memory protection mechanisms. When a process attempts to access a virtual memory page that is not currently in physical memory, the operating system triggers a page fault, which allows it to fetch the required page from secondary storage (e.g., disk) and load it into a physical memory frame. Paging also enables the use of page replacement algorithms, such as Least Recently Used (LRU), to efficiently manage the limited physical memory resources and minimize the occurrence of page faults. The effective implementation and optimization of paging mechanisms are crucial for the overall performance and scalability of virtual memory systems in modern computer architectures.
-
7. Lazy LoadingLazy loading is a virtual memory management technique that optimizes the utilization of physical memory by deferring the loading of memory pages until they are actually needed by a running process. In a traditional virtual memory system, the operating system would eagerly load all the pages required by a process at the time of execution, even if some of those pages may not be accessed immediately. Lazy loading, on the other hand, only loads the pages that are actively being used, reducing the initial memory footprint and improving overall system performance. This approach is particularly beneficial for applications that have a large virtual address space but only use a subset of it at any given time. By delaying the loading of unused pages, lazy loading reduces the number of page faults and the associated overhead of fetching pages from secondary storage. This technique can lead to significant performance improvements, especially in memory-constrained environments or for applications with irregular memory access patterns. Implementing and optimizing lazy loading is an important aspect of virtual memory management in modern operating systems.
-
8. File Memory MappingFile memory mapping is a virtual memory management technique that allows a process to directly access the contents of a file as if it were part of the process's own virtual address space. This is achieved by mapping the file's contents to a region of the process's virtual memory, enabling efficient data access and reducing the overhead of traditional file I/O operations. File memory mapping provides several benefits, such as improved performance, reduced memory usage, and simplified programming models. By eliminating the need for explicit file read and write operations, file memory mapping can significantly enhance the responsiveness and efficiency of applications that work with large files or databases. Additionally, file memory mapping can enable the sharing of file contents among multiple processes, further optimizing memory utilization. The operating system's virtual memory management subsystem plays a crucial role in implementing and managing file memory mapping, ensuring that the mapping is transparent to the application and that the necessary page fault handling and memory protection mechanisms are in place. Effective file memory mapping is an important aspect of virtual memory management, contributing to the overall performance and scalability of modern computer systems.
-
9. Swap TableThe swap table is a critical data structure used in virtual memory management systems to keep track of pages that have been swapped out to secondary storage, such as a hard disk or solid-state drive. When the physical memory available on a system is insufficient to accommodate all the pages required by running processes, the operating system must swap out some pages to make room for others. The swap table maintains information about the location of these swapped-out pages, including the physical memory frame number, the corresponding virtual page number, and the location on the secondary storage device where the page is stored. This information is essential for the efficient handling of page faults, as the operating system can quickly retrieve the required page from the swap area and load it back into physical memory. The design and optimization of the swap table, including the selection of appropriate page replacement algorithms and the management of the swap space, can have a significant impact on the overall performance and responsiveness of a virtual memory system. Effective swap table management is a crucial aspect of virtual memory management in modern operating systems.
-
10. Process TerminationProcess termination is an important aspect of virtual memory management, as it involves the cleanup and release of the resources associated with a running process, including its virtual memory allocations. When a process is terminated, the operating system must ensure that all the virtual memory pages allocated to the process are properly deallocated and their associated physical memory frames are freed for use by other processes. This includes the removal of the process's page table entries, the release of any shared memory regions, and the cleanup of any swap space occupied by the process's pages. The efficient handling of process termination is crucial for maintaining the overall stability and performance of the virtual memory system, as it prevents memory leaks and ensures that physical memory resources are promptly reclaimed and made available for other processes. Additionally, the termination process may involve the execution of cleanup routines or the invocation of specific exit handlers, which can further impact the virtual memory management subsystem. Proper process termination is a fundamental requirement for the effective and reliable operation of virtual memory systems in modern operating systems.
-
11. Lazy LoadingLazy loading is a virtual memory management technique that optimizes the utilization of physical memory by deferring the loading of memory pages until they are actually needed by a running process. In a traditional virtual memory system, the operating system would eagerly load all the pages required by a process at the time of execution, even if some of those pages may not be accessed immediately. Lazy loading, on the other hand, only loads the pages that are actively being used, reducing the initial memory footprint and improving overall system performance. This approach is particularly beneficial for applications that have a large virtual address space but only use a subset of it at any given time. By delaying the loading of unused pages, lazy loading reduces the number of page faults and the associated overhead of fetching pages from secondary storage. This technique can lead to significant performance improvements, especially in memory-constrained environments or for applications with irregular memory access patterns. Implementing and optimizing lazy loading is an important aspect of virtual memory management in modern operating systems.