140 likes | 167 Vues
Explore the evolution of memory management in operating systems from early systems to address spaces, virtual memory, and protection mechanisms. Learn about the goals, efficiency, and transparency of memory virtualization.
E N D
The AbstractionAddress Spaces Sung Gon Kim (skim@dcslab.snu.ac.kr) Yeong Ouk Kim (kim331@snu.ac.kr) Hwa Jung Kim (hkim@dcslab.snu.ac.kr) School of Computer Science and Engineering Seoul National University
Table of Contents • Motivation • Early System and Multiprogramming • Time Sharing • Address Spaces • Causation • Definition • Virtual Memory • Goal • Summary
Motivation • Early System • No abstraction • One process occupies entire memory at a time Expensive machines, BUT low utilization 0 KB Operating System - code, data, etc. - 64 KB Current Program - code, data, etc. - max Physical Memory
Motivation Long program-debug cycles 0 KB Operating System - code, data, etc. - 64 KB Process A Process B I/O Operation! Process A Process B max Disk Physical Memory • Multiprogramming • Switching multi processes between I/O operations • Improve utilization of the CPU Efficient!
Motivation Saving state is Too Slow 0 KB Operating System - code, data, etc. - 64 KB Process A Process B Time’s UP! Process A Process B max Disk Physical Memory • Time Sharing Approach #1 • Granting time-slice for each process
Motivation Protection between multiple states 0 KB Operating System - code, data, etc. - 64 KB free 128 KB Process C - code, data, etc. - 192 KB Process B - code, data, etc. - 256 KB free 320 KB Process B - code, data, etc. - 384 KB free 448 KB free 512 KB Physical Memory • Time Sharing Approach #2 • Granting time-slice for each process • Leaving state of multiple processes in physical memory
Address Spaces 0 KB Program Code 1 KB Heap 2 KB free 63 KB Stack 64 KB Address Space • Protection from read and write from other processes • Address Space: Abstraction of physical memory provided by OS • Address Space of a process • Code: Code of the program • Stack: Track function call, parameters, return values • Heap: Dynamically-allocated, user-managed memory • But… • In reality, a process does NOT occupy entire memory • Hence the abstraction is required for OS to virtualize memory
Address Spaces in C #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { printf("location of code: %p\n", (void *)main); printf("location of head: %p\n", (void *)malloc(1)); int x = 3; printf("location of stack: %p\n", (void *)&x); return x; } 0x40057d Program Code 0x1548010 Heap location of code: 0x40057d location of code: 0x1548010 location of code: 0x7ffdc614670c free Stack 0x7ffdc614670c Address Space 64-bit Linux Machine
Virtual Memory Operating System …… …… Process A’s Address Space Physical Memory Process B’s Address Space Disk • Hide all physical aspects of memory from users • Memory is logically unbounded • Only portions of virtual address space are in physical memory at any one time
Goal • Transparency • The program is NOT aware that the memory is virtualized • Efficiency • Time: Does not affect the performance negatively • Space: Occupy minimal space for virtualization • For such efficiency, OS need hardware support • E.g., TLB for time efficiency • Protection • Protect a process from another process or even from the OS • Resulting in isolation among processes
Summary • Motivation • From early system to time sharing • Address Spaces • An abstraction of physical memory from the OS • To provide protection • Memory Virtualization • With the abstraction, OS can virtualize the memory • Goal • Transparency: Virtualization itself is invisible • Efficiency: Time and Space • Protection: From other processes and OS
Looking Forward • Mechanisms needed to virtualize memory • Address Translation • Segmentation • Paging • Policies about how to manage memory space • Free Space Management
Discussions in the Class • Motivation: From Multiprogramming to Time Sharing • Long program-debug cycle • Lack of Interaction • Although the book mentioned “long program-debug cycle” as the main issue, we believe that “lack of interaction” cannot be overlooked • Space efficiency issue to virtualize memory • Similar to TLB which was presented as hardware support for time efficiency, Multi-Level Page Table is one example of hardware support for space efficiency