Virtualization and the UNIX API
|
|
- Chrystal Parsons
- 6 years ago
- Views:
Transcription
1 Virtualization and the UNIX API Science Computer Science CS 450: Operating Systems Sean Wallace
2 Agenda The Process UNIX process management API Virtual Memory Dynamic memory allocation & related APIs 2
3 The Process 3
4 Definition & OS Responsibilities 4
5 Process = a program in execution 5
6 { code (program), global data, local data (stack), dynamic data (heap), PC & other registers } 6
7 Programs describe what we want done, Processes realize what we want done 7
8 and the operating system runs processes 8
9 Execution = running a process Scheduling = running many processes Peripherals = I/O devices 9
10 To do this, the OS is constantly running in the background, keeping track of a large amount of process/system metadata. 10
11 { code (program), global data, local data (stack), dynamic data (heap), PC & other registers, + OS-level metadata } 11
12 { code (program), global data, local data (stack), dynamic data (heap), PC & other registers, + (e.g., pid, owner, memory/cpu usage) } 12
13 Logical Control Flow Process A Process B Process C Time 13
14 Physical Flow (1 CPU) Process A Process B Process C Time 14
15 Context Switches Time Process A Process B read Disk interrupt Return from read User Code Kernel Code User Code Kernel Code User Code } Context switch } Context switch 15
16 Context switches are external to a process s logical control flow (dictated by user program) part of key OS virtualization: exceptional control flow 16
17 Exceptional Control Flow 17
18 Logical c.f. Exception! int main() { while (1) { printf("hello World!\n"); } return 0; }? 18
19 Two classes of exceptions: I. Synchronous II. Asynchronous 19
20 I. Synchronous exceptions are caused by the currently executing instruction 20
21 3 subclasses of synchronous exceptions: 1. Traps 2. Faults 3. Aborts 21
22 1. Traps Traps are intentionally triggered by a process E.g., to invoke a system call 22
23 char *str = "Hello World" int len = strlen(str) write(1, str, len); mov edx, len mov ecx, str mov ebx, 1 mov eax, 4 ; syscall #4 int 0x80 ; trap to OS 23
24 Return from trap (if it happens) resumes execution at the next logical instruction 24
25 1. Faults Faults are usually unintentional, and may be recoverable or irrecoverable E.g., segmentation fault, protection fault, page fault, divide-by-zero 25
26 Often, return from fault will result in retrying the faulting instruction Esp. if the handler fixes the problem 26
27 1. Aborts Aborts are unintentional and irrecoverable I.e., abort = program/os termination E.g., memory ECC error 27
28 I. Asynchronous exceptions are caused by events external to the current instruction 28
29 int main() { while (1) { printf("hello World!\n"); } return 0; } Hello World! Hello World! Hello World! Hello World! ^C $ 29
30 Hardware initiated asynchronous exceptions are known as interrupts 30
31 E.g., ctrl-c, ctrl-alt-del, power switch 31
32 Interrupts are associated with specific processor (hardware) pins Checked after every CPU cycle Associated with interrupt handlers 32
33 (system) memory int. handler 0 code int # interrupt vector 33
34 (Typical) interrupt procedure Save context (e.g., user process) Load OS context Execute handler Load context (for?) Return 34
35 Important: after switching context to the OS (for exception handling), there is no guarantee if/when a process will be switched back in! 35
36 Switching context to the kernel is potentially very expensive But it s the only way to the OS API! 36
37 UNIX API 37
38 Process Management 38
39 Creating Processes 39
40 #include <unistd.h> pid_t fork(); 40
41 fork traps to OS to create a new process which is (mostly) a duplicate of the calling process! 41
42 E.g., the new (child) process runs the same program as the creating (parent) process And starts with the same PC, The same SP, FP, regs, The same open files, etc., etc. 42
43 Pparent int main() { fork(); foo(); } OS 43
44 Pparent int main() { fork(); foo(); } Pchild int main() { fork(); foo(); } OS creates 44
45 Pparent int main() { fork(); foo(); } Pchild int main() { fork(); foo(); } OS 45
46 fork, when called, returns twice (to each the next instruction) 46
47 typedef int pid_t; pid_t fork(); System-wide unique process identifier Child s pid (> 0) is returned in the parent Sentinel value 0 is returned in the child 47
48 void fork0() { int pid = fork(); if (pid == 0) { printf("hello from Child!\n"); } else { printf("hello from Parent!\n"); } } main() { fork0(); } Hello from Child! Hello from Parent! (or) Hello from Parent! Hello from Child! 48
49 That is, order of execution is nondeterministic Parent & child run concurrently! 49
50 void fork1() { int x = 1; } if (fork() == 0) { printf("child has x = %d\n", ++x); } else { printf("parent has x = %d\n", --x); } Parent has x = 0 Child has x = 2 50
51 Important: post-fork, parent & child are identical, but separate! OS allocates and maintains separate data/state Control flow can diverge 51
52 All terminating processes turn into zombies 52
53 Dead but still tracked by OS PID remains in use Exit status can be queried 53
54 All processes are responsible for reaping their own (immediate) children 54
55 pid_t wait(int *stat_loc); 55
56 pid_t wait(int *stat_loc); When called by a process with 1 children: Waits (if needed) for a child to terminate Reaps a zombie child (if 1 zombified children, arbitrarily pick one) Returns reaped child s PID and exit status info via pointer (if non-null) 56
57 wait allows us to synchronize one process with events (e.g., termination) in another 57
58 void fork10() { int i, stat; pid_t pid[5]; for (i = 0; i < 5; i++) { if ((pid[i] = fork()) == 0) { sleep(1); exit(100 + i); } } for (i = 0; i < 5; i++) { pid_t cpid = wait(&stat); if (WIFEXITED(stat)) { printf("child %d terminated with status %d\n", cpid, WEXITSTATUS(stat)); } } } Child 9051 terminated with status 100 Child 9055 terminated with status 104 Child 9054 terminated with status 103 Child 9053 terminated with status 102 Child 9052 terminated with status
59 /* explicit waiting -- i.e., for a specific child */ pid_t waitpid(pid_t pid, int *stat_loc, int options); /** Wait options **/ /* return 0 immediately if no terminated children */ #define WNOHANG 0x /* also report info about stopped children (and others) */ #define WUNTRACED 0x
60 void fork11() { int i, stat; pid_t pid[5]; for (i = 0; i < 5; i++) { if ((pid[i] = fork()) == 0) { sleep(1); exit(100 + i); } } for (i = 0; i < 5; i++) { pid_t cpid = waitpid(pid[i], &stat, 0); if (WIFEXITED(stat)) { printf("child %d terminated with status %d\n", cpid, WEXITSTATUS(stat)); } } } Child 9085 terminated with status 100 Child 9086 terminated with status 101 Child 9087 terminated with status 102 Child 9088 terminated with status 103 Child 9089 terminated with status
61 int main(int argc, const char * argv[]) { int stat; pid_t cpid; } if (fork() == 0) { printf("child pid = %d\n", getpid()); sleep(3); exit(1); } else { /* use with -1 to wait on any child (with options) */ while ((cpid = waitpid(-1, &stat, WNOHANG)) == 0) { sleep(1); printf("no terminated children!\n"); } printf("reaped %d with exit status %d\n", cpid, WEXITSTATUS(stat)); } Child pid = 9108 No terminated children! No terminated children! No terminated children! Reaped 9108 with exit status 1 61
62 Recap: fork: create new (duplicate) process wait: reap terminated (zombie) process 62
63 Running new programs (within processes) 63
64 /* the "exec family" of syscalls */ int execl(const char *path, const char *arg,...); int execlp(const char *file, const char *arg,...); int execv(const char *path, char *const argv[]); int execvp(const char *file, char *const argv[]); 64
65 Execute a new program within the current process context 65
66 Complements fork (1 call 2 returns): When called, exec (if successful) never returns! Starts execution of new program 66
67 int main(int argc, const char * argv[]) { execl("/bin/echo", "bin/echo", "hello", "world", (void *)0); printf("done exec-ing...\n"); return 0; } $./a.out hello world 67
68 int main(int argc, const char * argv[]) { printf("about to exec!\n"); sleep(1); execl("./execer", "./execer", (void *)0); printf("done exec-ing...\n"); return 0; } $ gcc execer.c -o execer $./execer About to exec! About to exec! About to exec! About to exec!... 68
69 int main(int argc, const char * argv[]) { if (fork() == 0) { execl("/bin/ls", "/bin/ls", "-l", (void *)0); exit(0); /* in case exec fails */ } wait(null); printf("command completed\n"); return 0; } $./a.out -rwxr-xr-x 1 sean staff 9500 Oct 7 00:15 a.out Command completed 69
70 Interesting question: Why are fork & exec separate syscalls? /* i.e., why not: */ fork_and_exec("/bin/ls",...) 70
71 A1: we might really want to just create duplicates of the current process (e.g.?) 71
72 A2: we might want to replace the current program without creating a new process 72
73 A3 (more subtle): we might want to tweak a process before running a program in it 73
74 The Unix Family Tree 74
75 BIOS bootloader kernel handcrafted process 75
76 kernel fork & exec /etc/inittab init 76
77 kernel fork & exec init fork & exec Daemons e.g., sshd, http getty 77
78 kernel init login exec 78
79 kernel init shell (e.g., sh) exec 79
80 kernel init (a fork-ing party!) shell (e.g., sh) user process user process user process user process 80
81 kernel (or, for the GUI-inclined) init display manager (e.g., xdm) X Server (e.g., XFree86) window manager (e.g., twm) 81
82 window manager (e.g., twm) terminal emulator (e.g., xterm) shell (e.g., sh) user process user process user process user process 82
83 The Shell (aka the CLI) 83
84 The original operating system user interface 84
85 Essential function: let the user issue requests to the operating system e.g., fork/exec a program, manage processes (list/stop/term), browse/manipulate the file system 85
86 (a read-eval-print-loop (REPL) for the OS) 86
87 pid_t pid; char buf[80], *argv[10]; while (1) { /* print prompt */ printf("$ "); buf argv l s \0 - l \0 \0 /* read command and build argv */ fgets(buf, 80, stdin); for (i = 0, argv[0] = strtok(buf, " \n"); argv[i]; argv[++i] = strtok(null, " \n")); /* fork and run command in child */ if ((pid = fork()) == 0) { if (execvp(argv[0], argv) < 0) { printf("command not found\n"); exit(0); } } } 87
88 The process management API (fork, wait, exec, etc.) let us tap into CPU virtualization i.e., create, manipulate, clean up concurrently running programs 88
89 Next key component in the Von Neumann machine: memory To be accessed by all of our processes Simultaneously With a simple, consistent API Withint trampling on each other! 89
90 Virtual Memory 90
91 Motivation 91
92 CPU instr data results Memory I/O Again, recall the Von Neumann architecture a stored-program computer with programs and data stored in the same memory 92
93 CPU instr data results Memory I/O Memory is an idealized storage device that hold our programs (instructions) and data (operands) 93
94 CPU instr data results Memory I/O Colloquially: RAM, random access memory ~ big array of byte-accessible data 94
95 execlp("/bin/echo", "/bin/echo", "hello", NULL); but our code & data clearly reside on the hard drive (to start)! 95
96 register file instr data results Memory hard disk in reality, memory is a combination of storage systems with very different access characteristics 96
97 common types of memory : SRAM, DRAM, NVRAM, HDD 97
98 Relative Speeds Type Size Access latency Unit Registers 8-32 words 0-1 cycles (ns) On-board SRAM KB 1-3 cycles (ns) Off-board SRAM 256 KB - 16 MB 10 cycles (ns) DRAM 128 MB - 64 GB 100 cycles (ns) SSD 1 TB ~10,000 cycles (µs) HDD 4 TB 10,000,000 cycles (ms) 98
99 Numbers Every Programmer Should Know 99
100 would like: 1. a lot of memory 2. fast access to memory 3. to not spend $$$ on memory 100
101 CPU registers cache (SRAM) smaller, faster costlier main memory (DRAM) local hard disk drive (HDD) larger, slower, cheaper remote storage (networked drive / cloud) an exercise in compromise: the memory hierarchy 101
102 idea: use the fast but scarce kind as much as possible; fall back on the slow but plentiful kind when necessary 102
103 registers cache (SRAM) main memory (DRAM) local hard disk drive (HDD/SSD) remote storage (networked drive / cloud) focus on DRAM HDD, SSD, etc. i.e., memory as a cache for disk 103
104 main goals: 1. maximize memory throughput 2. maximize memory utilization 3. provide address space consistency & memory protection to processes 104
105 throughput = # bytes per second - depends on access latencies (DRAM, HDD) and hit rate - improve by minimizing disk accesses 105
106 utilization = fraction of allocated memory that contains user data (aka payload) - reduced by storing metadata in memory - affected by alignment, block size, etc. 106
107 address space consistency provide a uniform view of memory to each process 107
108 0xffffffff 0xc Kernel virtual memory (code, data, heap, stack) User stack (created at runtime) Memory invisible to user code %esp (stack pointer) 0x Memory mapped region for shared libraries 0x Run-time heap (created by malloc) Read/write segment (.data,.bss) Read-only segment (.init,.text,.rodata) Unused brk Loaded from the executable file address space consistency provide a uniform view of memory to each process 108
109 memory protection prevent processes from directly accessing each other s address space 109
110 0xffffffff 0xc Kernel virtual memory (code, data, heap, stack) User stack (created at runtime) Memory invisible to user code %esp (stack pointer) 0xffffffff 0xc Kernel virtual memory (code, data, heap, stack) User stack (created at runtime) Memory invisible to user code %esp (stack pointer) 0xffffffff 0xc Kernel virtual memory (code, data, heap, stack) User stack (created at runtime) Memory invisible to user code %esp (stack pointer) 0x Memory mapped region for shared libraries 0x Memory mapped region for shared libraries 0x Memory mapped region for shared libraries Run-time heap (created by malloc) brk Run-time heap (created by malloc) brk Run-time heap (created by malloc) brk 0x Read/write segment (.data,.bss) Read-only segment (.init,.text,.rodata) Unused Loaded from the executable file 0x Read/write segment (.data,.bss) Read-only segment (.init,.text,.rodata) Unused Loaded from the executable file 0x Read/write segment (.data,.bss) Read-only segment (.init,.text,.rodata) Unused Loaded from the executable file P0 P1 P2 memory protection prevent processes from directly accessing each other s address space 110
111 i.e., every process should be provided with a managed, virtualized address space 111
112 memory addresses : what are they, really? 112
113 Main Memory CPU (note: cache not shown) N address: N data physical address: (byte) index into DRAM 113
114 int glob = 0xDEADBEEE; main() { fork(); glob += 1; } (gdb) set detach-on-fork off (gdb) break main Breakpoint 1 at 0x400508: file memtest.c, line 7. (gdb) run Breakpoint 1, main () at memtest.c:7 7 fork(); (gdb) next [New process 7450] 8 glob += 1; (gdb) print &glob $1 = (int *) 0x6008d4 (gdb) next 9 } (gdb) print /x glob $2 = 0xdeadbeef (gdb) inferior 2 [Switching to inferior 2 [process 7450] #0 0x acac49d in libc_fork () 131 pid = ARCH_FORK (); (gdb) finish Run till exit from #0 in libc_fork () 8 glob += 1; (gdb) print /x glob $4 = 0xdeadbeee (gdb) print &glob $5 = (int *) 0x6008d4 parent child 114
115 Main Memory N CPU address: N data instructions executed by the CPU do not refer directly to physical addresses! 115
116 processes reference virtual addresses, the CPU relays virtual address requests to the memory management unit (MMU), which are translated to physical addresses 116
117 Main Memory MMU physical address CPU virtual address address translation unit disk address (note: cache not shown) swap space 117
118 the size of virtual memory is determined by the virtual address width the physical address width is determined by the amount of installed physical memory 118
119 e.g., given 48-bit virtual address, 8GB installed DRAM - 48-bits 256TB virtual space - 8GB 33-bit physical address 119
120 P0 2 n -1 virtual address space n virtual address P1 2 n -1 virtual address space 2 m -1 (global) physical address space n m P2 2 n -1 virtual address virtual address space physical address n virtual address 120
121 essential problem: map request for a virtual address physical address and this must be FAST! (happens on every memory access) 121
122 both hardware/software are involved: - MMU (hw) handles simple and fast operations (e.g., table lookups) - Kernel (sw) handles complex tasks (e.g., eviction policy) 122
123 Virtual Memory Implementation 123
124 keep in mind goals: 1. maximize memory throughput 2. maximize memory utilization 3. provide address space consistency & memory protection to processes 124
125 1. simple relocation Main Memory CPU MMU relocation reg. N B VA: N B PA: N+B data - per-process relocation address is loaded by kernel on every context switch 125
126 1. simple relocation Main Memory CPU MMU limit reg. L relocation reg. N B+L B process sandbox VA: N B PA: N+B assert (0 N L) data - incorporate a limit register to provide memory protection 126
127 pros: - simple & fast! - provides protection 127
128 stack heap Virtual Memory Main Memory Main Memory stack stack data data heap heap vs. code code B data data code code B but: available memory for mapping depends on value of base address i.e., address spaces are not consistent! 128
129 virtual address space Main Memory L stack stack possibly unused!! code code B also: all of a process below the address limit must be loaded in memory i.e., memory may be vastly under-utilized 129
130 2. segmentation - partition virtual address space into multiple logical segments - individually map them onto physical memory with relocation registers 130
131 Segmented Virtual Address Space Main Memory B2+L2! Seg #$: Stack MMU Segment Table B2! Seg ##: Heap Base Limit! B0 L0 " B1 L1 # B2 L2 $ B3 L3 B3+L3 B3 B0+L0! Seg #": Data B0! Seg #!: Code B1+L1 B1 virtual address has form seg#:offset 131
132 MMU Segment Table Base Limit! B0 L0 " B1 L1 # B2 L2 $ B3 L3 Main Memory B2+L2 B2 B3+L3 CPU VA: seg#:o set PA: o set + B2 B3 B0+L0 B0 assert (o set L2) B1+L1 B1 data 132
133 Segment Table Base Limit! B0 L0 " B1 L1 # B2 L2 $ B3 L3 - implemented as MMU registers - part of kernel-maintained, per-process metadata (aka process control block ) - re-populated on each context switch 133
134 pros: - still very fast - translation = register access & addition - memory protection via limits - segmented addresses improve consistency 134
135 what about utilization? 135
136 virtual address space Main Memory simple relocation: L stack stack possibly unused!! code code B virtual address space Main Memory segmentation:! stack stack better!! code code 136
137 virtual address space Main Memory x virtual address space 2 stack! stack x stack! code code!! code x - variable segment sizes memory fragmentation - fragmentation potentially lowers utilization - can fix through compaction, but expensive! 137
138 3. paging - partition virtual and physical address spaces into uniformly sized pages - only map pages onto physical memory that contain required data 138
139 stack physical memory heap data code - pages boundaries are not aligned to segments! - instead, aligned to multiples of page size 139
140 stack physical memory heap data code - minimum mapping granularity = page - not all of a given segment need be mapped 140
141 new mapping problem: - given virtual address, decompose into virtual page number & virtual page offset - map VPN physical page number 141
142 Given page size = 2 p bytes VA: PA: virtual page number physical page number p virtual page offset p physical page offset 142
143 VA: virtual page number virtual page offset address translation PA: physical page number physical page offset 143
144 VA: n virtual page number virtual page offset translation structure: page table valid PPN index 2 n entries if invalid, page is not mapped PA: physical page number physical page offset 144
145 page table entries (PTEs) typically contain additional metadata, e.g.: - dirty (modified) bit - access bits (shared or kernel-owned pages may be read-only or inaccessible) 145
146 e.g., 32-bit virtual address, 4KB (2 12 ) pages, 4-byte PTEs; - size of page table? 146
147 e.g., 32-bit virtual address, 4KB (2 12 ) pages, 4-byte PTEs; - # pages = 2 (32-12) = 2 20 =1M - page table size = 1M 4 bytes = 4MB 147
148 4MB is much too large to fit in the MMU insufficient registers and SRAM! Page table resides in main memory 148
149 The translation process (aka page table walk) is performed by hardware (MMU). The kernel must initially populate, then continue to manage a process s page table The kernel also populates a page table base register on context switches 149
150 translation: hit CPU VA: N Address Translator (part of MMU) page table walk Main Memory Page Table PA: N' data 150
151 translation: miss transfer control to kernel CPU VA: N VA: N (retry) page fault Address Translator (part of MMU) page table walk PA: N' Main Memory Page Table PTE update kernel Disk (swap space) data transfer data 151
152 kernel decides where to place page, and what to evict (if memory is full) - e.g., using LRU replacement policy 152
153 this system enables on-demand paging i.e., an active process need only be partly in memory (load rest from swap dynamically) 153
154 but if working set (of active processes) exceeds available memory, we may have swap thrashing 154
155 integration with caches? 155
156 Q: Do caches use physical or virtual address for lookups? 156
157 Virtual Address Based Cache Process A CPU Process B Virtual Address Space Cache Address Data L X M Y N Z Ambiguous! Virtual Address Space Z N Synonym problem M M L X
158 Physical Address Based Cache Process A CPU Process B Virtual Address Space Cache Address Data S X Q Y R Z Virtual Address Space Z N M Physical Memory Y M L 0 X X Z Y S R Q 0 158
159 Q: Do caches use physical or virtual address for lookups? A: Caches typically use physical addresses 159
160 Main Memory page table walk process page table CPU MMU Cache VA (address translation unit) PA (miss) data (hit) (update) 160
161 Saved by hardware: The Translation Lookaside Buffer (TLB) a cache used solely for VPN PPN lookups 161
162 Main Memory page table walk process page table CPU MMU Cache VA (address translation unit) PA (miss) data (hit) (update) 162
163 MMU Main Memory only if TLB miss! address translation unit page table walk process page table CPU TLB Cache VA (VPN PPN cache) PA (miss) data (hit) (update) TLB + Page Table (exercise for you: revise earlier translation diagrams!) 163
164 virtual address n-1 p p-1 0 virtual page number (VPN) page offset valid tag physical page number (PPN) TLB = TLB Hit physical address valid tag data byte offset Cache Cache Hit = Data 164
165 Not so fast! TLB mappings are process specific requires flush & reload on context switch - Some architectures store PID (aka virtual space ID) in TLB 165
166 Another problem: TLB caches a few thousand mappings vs. millions of virtual pages per process! 166
167 We can improve TLB hit rate by reducing the number of pages by increasing the size of each page. 167
168 Compute # of pages for 32-bit memory for: 1KB, 512KB, 4MB pages = 2 22 = 4M pages = 2 13 = 8K pages = 2 10 = 1K pages (not bad!) 168
169 Process A Virtual Memory Lots of wasted space! Physical Memory Process B Virtual Memory 169
170 Process A Virtual Memory Process B Virtual Memory Physical Memory 170
171 Increasing page size results in increased internal fragmentation and lower utilization 171
172 That is, TLB effectiveness needs to be balanced against memory utilization! 172
173 So, what about 64-bit systems? 2 64 = 16 ExbiByte address space 4 billion 4GB 173
174 Most modern implementations support a max of 2 48 (256TB) addressable space. 174
175 Page table size? # pages = = 2 36 PTE size = 8 bytes (64 bits) PT size = = 2 39 bytes = 512GB 175
176 512GB (just for the virtual memory mapping structure) (and we need one per process) 176
177 (We re not going to be able to fit these into memory) 177
178 Instead, use multi-level page tables: Split an address translation into two (or more) separate table lookups Unused parts of the table don t need to be in memory! 178
179 Toy memory system - 8 bit addresses - 32-byte pages VPN page offset Page Table 7 (unmapped) 6 PPN 5 (unmapped) 4 PPN 3 (unmapped) 2 (unmapped) 1 (unmapped) 0 (unmapped) All 8 PTEs must be in memory at all times 179
180 Toy memory system - 8 bit addresses - 32-byte pages page offset 3 (unmapped) 2 PPN (unmapped) 0 PPN page directory all unmapped; don t need in memory! (unmapped) 2 (unmapped) 1 (unmapped) 0 (unmapped)
181 Toy memory system - 8 bit addresses - 32-byte pages page offset (unmapped) 2 PPN 1 (unmapped) 0 PPN 181
182 Intel Architecture Memory Management manuals/ (Software Developer s Manual Volume 3A) 182
183 Logical Address (or Far Pointer) Segment Selector Offset Linear Address Space Global Descriptor Table (GDT) Linear Address Dir Table Offset Physical Address Space Segment Descriptor Segment Lin. Addr. Page Directory Page Table Entry Page Phy. Addr. Entry Segment Base Address Page Segmentation Paging 183
184 Segment Registers CS SS DS ES FS GS Segment Descriptors Access Limit Base Address Access Limit Base Address Access Limit Base Address Access Limit Base Address Access Limit Base Address Access Limit Base Address Access Limit Base Address Access Limit Base Address Access Limit Base Address Access Limit Base Address Linear Address Space (or Physical Memory) Stack Code Data Data Data Data Segment Descriptors 184
185 Segment Registers CS SS Code- and Data-Segment Descriptors Linear Address Space (or Physical Memory) Code Not Present FFFFFFFFH DS ES Access Limit Base Address Data and Stack 0 FS GS Flat Model 185
186 Paging Modes 186
187 Linear Address Directory Table Offset KByte Page 10 Page Directory 10 Page Table Physical Address PDE with PS=0 20 PTE CR3 32-Bit Paging (4KB Pages) 187
188 32-Bit Paging (4MB Pages) 188
189 IA-32e Paging (4KB Pages) 189
190 IA-32e Paging (1GB Pages) 190
191 Dynamic Memory Allocation 191
192 registers From: cache (SRAM) main memory (DRAM) local hard disk drive (HDD/SSD) remote storage (networked drive / cloud) The Memory Hierarchy 192
193 We now have: Virtual Memory 193
194 Now what? 194
195 - code, global variables, jump tables, etc. - Allocated at fork/exec - Lifetime: permanent Static Data 195
196 The Stack - Function activation records - Local vars, arguments, return values - Lifetime: LIFO Pages allocated as needed (up to preset stack limit) 196
197 Explicitly requested from the kernel - For dynamic allocation - Lifetime: arbitrary! The Heap 197
198 - Starts out empty - brk pointer marks top of the heap brk The Heap 198
199 Heap mgmt syscall: void *sbrk(int inc); /* resizes heap by inc, returns old brk value */ The Heap brk 199
200 void *hp = sbrk(n); N brk hp The Heap 200
201 Can use sbrk to allocate structures: int **make_jagged_arr(int nrows, const int *dims) { int i, j; int **jar = sbrk(sizeof(int *) * nrows); for (i = 0; i < nrows; i++) { jarr[i] = sbrk(sizeof(int) * dims[i]); } } return jarr; 201
202 But, we can t free this memory! int **make_jagged_arr(int nrows, const int *dims) { int i, j; int **jar = sbrk(sizeof(int *) * nrows); for (i = 0; i < nrows; i++) { jarr[i] = sbrk(sizeof(int) * dims[i]); } } return jarr; void free_jagged_arr(int **jar, int nrows) { int i; for (i = 0; i < nrows; i++) { free(jarr[i]); } free(jarr); } 202
203 After the kernel allocates heap space for a process, it is up to the process to manage it! 203
204 Manage = tracking memory in use, tracking memory not in use, reusing unused memory 204
205 Job of the dynamic memory allocator Typically included as a user-level library and/or language runtime feature 205
206 User Process application program malloc dynamic memory allocator Heap sbrk OS Kernel RAM Disk 206
207 User Process application program free(p) dynamic memory allocator Heap OS Kernel RAM Disk 207
208 User Process application program free(p) dynamic memory allocator Heap OS Kernel RAM Disk (heap space may not be returned to the kernel!) 208
209 The DMA constructs a user-level abstraction (re-usable blocks of memory) on top of a kernel-level one (virtual memory) 209
210 The user-level implementation must make good use of the underlying infrastructure (the memory hierarchy) 210
Virtual Memory. CS 351: Systems Programming Michael Saelee
Virtual Memory CS 351: Systems Programming Michael Saelee registers cache (SRAM) main memory (DRAM) local hard disk drive (HDD/SSD) remote storage (networked drive / cloud) previously: SRAM
More informationDynamic Memory Allocation. CS 351: Systems Programming Michael Saelee
Dynamic Memory Allocation CS 351: Systems Programming Michael Saelee 1 from: registers cache (SRAM) main memory (DRAM) local hard disk drive (HDD/SSD) remote storage (networked drive / cloud)
More informationExceptional Control Flow Part I Oct. 17, 2002
15-213 The course that gives CMU its Zip! Exceptional Control Flow Part I Oct. 17, 2002 Topics Exceptions Process context switches Creating and destroying processes class16.ppt Control Flow Computers do
More informationControl Flow. Systemprogrammering 2007 Föreläsning 2 Exceptional Control Flow Part I. Exceptional Control Flow. Altering the Control Flow
Systemprogrammering 2007 Föreläsning 2 Exceptional Control Flow Part I Topics Exceptions Process context switches Creating and destroying processes Control Flow Computers do Only One Thing From startup
More informationGiving credit where credit is due
CSCE 230J Computer Organization Exceptional Control Flow Part I Dr. Steve Goddard goddard@cse.unl.edu http://cse.unl.edu/~goddard/courses/csce230j Giving credit where credit is due Most of slides for this
More informationExceptional Control Flow Part I September 22, 2008
15-213 Exceptional Control Flow Part I September 22, 2008 Topics Exceptions Process context switches Creating and destroying processes class11.ppt Control Flow Computers do only one thing: From startup
More informationExceptional Control Flow Part I
Exceptional Control Flow Part I Today Exceptions Process context switches Creating and destroying processes Next time Signals, non-local jumps, Chris Riesbeck, Fall 2011 Original: Fabian Bustamante Control
More informationExceptional Control Flow Part I Oct. 28, 2009"
Exceptional Control Flow Part I Oct. 28, 2009" Control Flow" Time" Physical control flow" " inst 1 " inst 2 " inst 3 " " inst n " " 2! 3! Altering the Control Flow" Exceptional Control
More informationCS 201. Processes. Gerson Robboy Portland State University
CS 201 Processes Gerson Robboy Portland State University Review Definition: A process is an instance of a running program. One of the most fundamental concepts in computer science. Not the same as program
More informationProcesses, Exceptional
CIS330, Week 9 Processes, Exceptional Control Flow CSAPPe2, Chapter 8 Control Flow Computers do Only One Thing o From startup to shutdown, a CPU simply reads and executes (interprets) a sequence of instructions,
More informationCSE 153 Design of Operating Systems
CSE 53 Design of Operating Systems Winter 28 Lecture 6: Paging/Virtual Memory () Some slides modified from originals by Dave O hallaron Today Address spaces VM as a tool for caching VM as a tool for memory
More informationOperating System. Chapter 3. Process. Lynn Choi School of Electrical Engineering
Operating System Chapter 3. Process Lynn Choi School of Electrical Engineering Process Def: A process is an instance of a program in execution. One of the most profound ideas in computer science. Not the
More informationVirtual Memory. Motivations for VM Address translation Accelerating translation with TLBs
Virtual Memory Today Motivations for VM Address translation Accelerating translation with TLBs Fabián Chris E. Bustamante, Riesbeck, Fall Spring 2007 2007 A system with physical memory only Addresses generated
More informationvirtual memory Page 1 CSE 361S Disk Disk
CSE 36S Motivations for Use DRAM a for the Address space of a process can exceed physical memory size Sum of address spaces of multiple processes can exceed physical memory Simplify Management 2 Multiple
More informationVirtual Memory Oct. 29, 2002
5-23 The course that gives CMU its Zip! Virtual Memory Oct. 29, 22 Topics Motivations for VM Address translation Accelerating translation with TLBs class9.ppt Motivations for Virtual Memory Use Physical
More informationvirtual memory. March 23, Levels in Memory Hierarchy. DRAM vs. SRAM as a Cache. Page 1. Motivation #1: DRAM a Cache for Disk
5-23 March 23, 2 Topics Motivations for VM Address translation Accelerating address translation with TLBs Pentium II/III system Motivation #: DRAM a Cache for The full address space is quite large: 32-bit
More information@2010 Badri Computer Architecture Assembly II. Virtual Memory. Topics (Chapter 9) Motivations for VM Address translation
Virtual Memory Topics (Chapter 9) Motivations for VM Address translation 1 Motivations for Virtual Memory Use Physical DRAM as a Cache for the Disk Address space of a process can exceed physical memory
More informationComputer Systems. Virtual Memory. Han, Hwansoo
Computer Systems Virtual Memory Han, Hwansoo A System Using Physical Addressing CPU Physical address (PA) 4 Main memory : : 2: 3: 4: 5: 6: 7: 8:... M-: Data word Used in simple systems like embedded microcontrollers
More informationAltering the Control Flow
Altering the Control Flow Up to Now: two mechanisms for changing control flow: Jumps and branches Call and return using the stack discipline. Both react to changes in program state. Insufficient for a
More informationProcesses. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Processes Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Processes An instance of a program in execution. One of the most profound ideas in computer
More information198:231 Intro to Computer Organization. 198:231 Introduction to Computer Organization Lecture 14
98:23 Intro to Computer Organization Lecture 4 Virtual Memory 98:23 Introduction to Computer Organization Lecture 4 Instructor: Nicole Hynes nicole.hynes@rutgers.edu Credits: Several slides courtesy of
More informationVirtual Memory Nov 9, 2009"
Virtual Memory Nov 9, 2009" Administrivia" 2! 3! Motivations for Virtual Memory" Motivation #1: DRAM a Cache for Disk" SRAM" DRAM" Disk" 4! Levels in Memory Hierarchy" cache! virtual memory! CPU" regs"
More informationMemory Management. Disclaimer: some slides are adopted from book authors slides with permission 1
Memory Management Disclaimer: some slides are adopted from book authors slides with permission 1 CPU management Roadmap Process, thread, synchronization, scheduling Memory management Virtual memory Disk
More informationProcesses and Virtual Memory Concepts
Processes and Virtual Memory Concepts Brad Karp UCL Computer Science CS 37 8 th February 28 (lecture notes derived from material from Phil Gibbons, Dave O Hallaron, and Randy Bryant) Today Processes Virtual
More informationAltering the Control Flow
Altering the Control Flow Up to Now: two mechanisms for changing control flow: Jumps and branches Call and return using the stack discipline. Both react to changes in program state. Insufficient for a
More informationToday. Introduction to Computer Systems /18 243, Fall th Lecture. Control Flow. Altering the Control Flow.
Today Introduction to Computer Systems 15 213/18 243, Fall 2009 11 th Lecture Exceptional Control Flow Processes Instructors: Greg Ganger and Roger Dannenberg Control Flow Processors do only one thing:
More information238P: Operating Systems. Lecture 5: Address translation. Anton Burtsev January, 2018
238P: Operating Systems Lecture 5: Address translation Anton Burtsev January, 2018 Two programs one memory Very much like car sharing What are we aiming for? Illusion of a private address space Identical
More informationOperating System Structure
Operating System Structure CSCI 4061 Introduction to Operating Systems Applications Instructor: Abhishek Chandra Operating System Hardware 2 Questions Operating System Structure How does the OS manage
More informationMotivations for Virtual Memory Virtual Memory Oct. 29, Why VM Works? Motivation #1: DRAM a Cache for Disk
class8.ppt 5-23 The course that gives CMU its Zip! Virtual Oct. 29, 22 Topics Motivations for VM Address translation Accelerating translation with TLBs Motivations for Virtual Use Physical DRAM as a Cache
More informationCarnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition
Carnegie Mellon Virtual Memory: Concepts 5-23: Introduction to Computer Systems 7 th Lecture, October 24, 27 Instructor: Randy Bryant 2 Hmmm, How Does This Work?! Process Process 2 Process n Solution:
More informationCSE 120 Principles of Operating Systems
CSE 120 Principles of Operating Systems Spring 2018 Lecture 10: Paging Geoffrey M. Voelker Lecture Overview Today we ll cover more paging mechanisms: Optimizations Managing page tables (space) Efficient
More informationAre branches/calls the only way we can get the processor to go somewhere in a program? What is a program? A processor? A process?
Processes and control flow Are branches/calls the only way we can get the processor to go somewhere in a program? What is a program? A processor? A process? 1 Control Flow Processors do only one thing:
More informationCPSC 341 OS & Networks. Processes. Dr. Yingwu Zhu
CPSC 341 OS & Networks Processes Dr. Yingwu Zhu Process Concept Process a program in execution What is not a process? -- program on a disk A process is an active object, but a program is just a file It
More informationLecture 19: Virtual Memory: Concepts
CSCI-UA.2-3 Computer Systems Organization Lecture 9: Virtual Memory: Concepts Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Some slides adapted (and slightly modified) from: Clark Barrett
More informationPROCESSES. Jo, Heeseung
PROCESSES Jo, Heeseung TODAY'S TOPICS What is the process? How to implement processes? Inter-Process Communication (IPC) 2 WHAT IS THE PROCESS? Program? vs. Process? vs. Processor? 3 PROCESS CONCEPT (1)
More informationProcesses. Jo, Heeseung
Processes Jo, Heeseung Today's Topics What is the process? How to implement processes? Inter-Process Communication (IPC) 2 What Is The Process? Program? vs. Process? vs. Processor? 3 Process Concept (1)
More informationVirtual Memory. CS61, Lecture 15. Prof. Stephen Chong October 20, 2011
Virtual Memory CS6, Lecture 5 Prof. Stephen Chong October 2, 2 Announcements Midterm review session: Monday Oct 24 5:3pm to 7pm, 6 Oxford St. room 33 Large and small group interaction 2 Wall of Flame Rob
More informationExceptional Control Flow: Exceptions and Processes
Exceptional Control Flow: Exceptions and Processes 15-213 / 18-213: Introduction to Computer Systems 12 th Lecture, June 18, 2013 Instructors: Greg Kesden 1 Today Exceptional Control Flow Processes 2 Control
More informationRandom-Access Memory (RAM) Systemprogrammering 2007 Föreläsning 4 Virtual Memory. Locality. The CPU-Memory Gap. Topics
Systemprogrammering 27 Föreläsning 4 Topics The memory hierarchy Motivations for VM Address translation Accelerating translation with TLBs Random-Access (RAM) Key features RAM is packaged as a chip. Basic
More informationExceptional Control Flow Part I
Exceptional Control Flow Part I Today! Exceptions! Process context switches! Creating and destroying processes Next time! Signals, non-local jumps, Fabián E. Bustamante, 2007 Control flow! Computers do
More information14 May 2012 Virtual Memory. Definition: A process is an instance of a running program
Virtual Memory (VM) Overview and motivation VM as tool for caching VM as tool for memory management VM as tool for memory protection Address translation 4 May 22 Virtual Memory Processes Definition: A
More informationRandom-Access Memory (RAM) Systemprogrammering 2009 Föreläsning 4 Virtual Memory. Locality. The CPU-Memory Gap. Topics! The memory hierarchy
Systemprogrammering 29 Föreläsning 4 Topics! The memory hierarchy! Motivations for VM! Address translation! Accelerating translation with TLBs Random-Access (RAM) Key features! RAM is packaged as a chip.!
More informationCS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 23
CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 205 Lecture 23 LAST TIME: VIRTUAL MEMORY! Began to focus on how to virtualize memory! Instead of directly addressing physical memory, introduce a level of
More informationVirtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. November 15, MIT Fall 2018 L20-1
Virtual Memory Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. L20-1 Reminder: Operating Systems Goals of OS: Protection and privacy: Processes cannot access each other s data Abstraction:
More informationCS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 20
CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 2018 Lecture 20 LAST TIME: UNIX PROCESS MODEL Began covering the UNIX process model and API Information associated with each process: A PID (process ID) to
More informationCarnegie Mellon. 16 th Lecture, Mar. 20, Instructors: Todd C. Mowry & Anthony Rowe
Virtual Memory: Concepts 5 23 / 8 23: Introduction to Computer Systems 6 th Lecture, Mar. 2, 22 Instructors: Todd C. Mowry & Anthony Rowe Today Address spaces VM as a tool lfor caching VM as a tool for
More informationAddress Translation. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University
Address Translation Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics How to reduce the size of page tables? How to reduce the time for
More informationVirtual Memory II CSE 351 Spring
Virtual Memory II CSE 351 Spring 2018 https://xkcd.com/1495/ Virtual Memory (VM) Overview and motivation VM as a tool for caching Address translation VM as a tool for memory management VM as a tool for
More informationToday. Exceptional Control Flow Processes. Exceptions and Processes. Control Flow. Altering the Control Flow
Today Exceptional Control Flow: Exceptions and Processes Exceptional Control Flow Processes 15 213 / 18 213: Introduction to Computer Systems 13 th Lecture, Feb 26, 2013 Instructors: Seth Copen Goldstein,
More informationCSE 560 Computer Systems Architecture
This Unit: CSE 560 Computer Systems Architecture App App App System software Mem I/O The operating system () A super-application Hardware support for an Page tables and address translation s and hierarchy
More informationVirtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. April 12, 2018 L16-1
Virtual Memory Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. L16-1 Reminder: Operating Systems Goals of OS: Protection and privacy: Processes cannot access each other s data Abstraction:
More informationMemory Management. Disclaimer: some slides are adopted from book authors slides with permission 1
Memory Management Disclaimer: some slides are adopted from book authors slides with permission 1 Recap Paged MMU: Two main Issues Translation speed can be slow TLB Table size is big Multi-level page table
More informationVirtual Memory: Systems
Virtual Memory: Systems 5-23: Introduction to Computer Systems 8 th Lecture, March 28, 27 Instructor: Franz Franchetti & Seth Copen Goldstein Recap: Hmmm, How Does This Work?! Process Process 2 Process
More information143A: Principles of Operating Systems. Lecture 6: Address translation. Anton Burtsev January, 2017
143A: Principles of Operating Systems Lecture 6: Address translation Anton Burtsev January, 2017 Address translation Segmentation Descriptor table Descriptor table Base address 0 4 GB Limit
More informationPrinceton University. Computer Science 217: Introduction to Programming Systems. Process Management
Princeton University Computer Science 217: Introduction to Programming Systems Process Management 1 Goals of this Lecture Help you learn about: Creating new processes Waiting for processes to terminate
More informationCISC 360. Virtual Memory Dec. 4, 2008
CISC 36 Virtual Dec. 4, 28 Topics Motivations for VM Address translation Accelerating translation with TLBs Motivations for Virtual Use Physical DRAM as a Cache for the Disk Address space of a process
More informationCSC 1600 Unix Processes. Goals of This Lecture
CSC 1600 Unix Processes q Processes Goals of This Lecture q Process vs. program q Context switching q Creating a new process q fork: process creates a new child process q wait: parent waits for child process
More informationPrinceton University Computer Science 217: Introduction to Programming Systems. Process Management
Princeton University Computer Science 217: Introduction to Programming Systems Process Management 1 Goals of this Lecture Help you learn about: Creating new processes Waiting for processes to terminate
More informationCS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 23
CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 208 Lecture 23 LAST TIME: VIRTUAL MEMORY Began to focus on how to virtualize memory Instead of directly addressing physical memory, introduce a level of indirection
More informationCS 318 Principles of Operating Systems
CS 318 Principles of Operating Systems Fall 2018 Lecture 10: Virtual Memory II Ryan Huang Slides adapted from Geoff Voelker s lectures Administrivia Next Tuesday project hacking day No class My office
More informationMemory Allocation. Copyright : University of Illinois CS 241 Staff 1
Memory Allocation Copyright : University of Illinois CS 241 Staff 1 Recap: Virtual Addresses A virtual address is a memory address that a process uses to access its own memory Virtual address actual physical
More informationCS 355 Operating Systems. Keeping Track of Processes. When are processes created? Process States 1/26/18. Processes, Unix Processes and System Calls
CS 355 Operating Systems Processes, Unix Processes and System Calls Process User types command like run foo at keyboard I/O device driver for keyboard and screen Command is parsed by command shell Executable
More informationECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017
ECE 550D Fundamentals of Computer Systems and Engineering Fall 2017 The Operating System (OS) Prof. John Board Duke University Slides are derived from work by Profs. Tyler Bletsch and Andrew Hilton (Duke)
More informationVIRTUAL MEMORY II. Jo, Heeseung
VIRTUAL MEMORY II Jo, Heeseung TODAY'S TOPICS How to reduce the size of page tables? How to reduce the time for address translation? 2 PAGE TABLES Space overhead of page tables The size of the page table
More informationVirtual Memory. Alan L. Cox Some slides adapted from CMU slides
Alan L. Cox alc@rice.edu Some slides adapted from CMU 5.23 slides Objectives Be able to explain the rationale for VM Be able to explain how VM is implemented Be able to translate virtual addresses to physical
More informationMemory Hierarchy Requirements. Three Advantages of Virtual Memory
CS61C L12 Virtual (1) CS61CL : Machine Structures Lecture #12 Virtual 2009-08-03 Jeremy Huddleston Review!! Cache design choices: "! Size of cache: speed v. capacity "! size (i.e., cache aspect ratio)
More informationAdministrivia. Lab 1 due Friday 12pm. We give will give short extensions to groups that run into trouble. But us:
Administrivia Lab 1 due Friday 12pm. We give will give short extensions to groups that run into trouble. But email us: - How much is done & left? - How much longer do you need? Attend section Friday at
More informationCS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 24
CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 2018 Lecture 24 LAST TIME Extended virtual memory concept to be a cache of memory stored on disk DRAM becomes L4 cache of data stored on L5 disk Extend page
More informationProcesses and Tasks What comprises the state of a running program (a process or task)?
Processes and Tasks What comprises the state of a running program (a process or task)? Microprocessor Address bus Control DRAM OS code and data special caches code/data cache EAXEBP EIP DS EBXESP EFlags
More informationfork System-Level Function
Princeton University Computer Science 217: Introduction to Programming Systems Process Management Goals of this Lecture Help you learn about: Creating new processes Waiting for processes to terminate Executing
More informationCSE 120 Principles of Operating Systems Spring 2017
CSE 120 Principles of Operating Systems Spring 2017 Lecture 12: Paging Lecture Overview Today we ll cover more paging mechanisms: Optimizations Managing page tables (space) Efficient translations (TLBs)
More informationMulti-level Translation. CS 537 Lecture 9 Paging. Example two-level page table. Multi-level Translation Analysis
Multi-level Translation CS 57 Lecture 9 Paging Michael Swift Problem: what if you have a sparse address space e.g. out of GB, you use MB spread out need one PTE per page in virtual address space bit AS
More informationSystems Programming and Computer Architecture ( ) Timothy Roscoe
Systems Group Department of Computer Science ETH Zürich Systems Programming and Computer Architecture (252-6-) Timothy Roscoe Herbstsemester 26 AS 26 Virtual Memory 8: Virtual Memory Computer Architecture
More informationAnother View of the Memory Hierarchy. Lecture #25 Virtual Memory I Memory Hierarchy Requirements. Memory Hierarchy Requirements
CS61C L25 Virtual I (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #25 Virtual I 27-8-7 Scott Beamer, Instructor Another View of the Hierarchy Thus far{ Next: Virtual { Regs Instr.
More informationNew-School Machine Structures. Overarching Theme for Today. Agenda. Review: Memory Management. The Problem 8/1/2011
CS 61C: Great Ideas in Computer Architecture (Machine Structures) Virtual Instructor: Michael Greenbaum 1 New-School Machine Structures Software Parallel Requests Assigned to computer e.g., Search Katz
More informationPrinceton University Computer Science 217: Introduction to Programming Systems. Process Management
Princeton University Computer Science 217: Introduction to Programming Systems Process Management 1 Goals of this Lecture Help you learn about: Creating new processes Waiting for processes to terminate
More informationMove back and forth between memory and disk. Memory Hierarchy. Two Classes. Don t
Memory Management Ch. 3 Memory Hierarchy Cache RAM Disk Compromise between speed and cost. Hardware manages the cache. OS has to manage disk. Memory Manager Memory Hierarchy Cache CPU Main Swap Area Memory
More informationMemory Management Ch. 3
Memory Management Ch. 3 Ë ¾¾ Ì Ï ÒÒØ Å ÔÔ ÓÐÐ 1 Memory Hierarchy Cache RAM Disk Compromise between speed and cost. Hardware manages the cache. OS has to manage disk. Memory Manager Ë ¾¾ Ì Ï ÒÒØ Å ÔÔ ÓÐÐ
More informationProcess Control. Philipp Koehn. 23 April 2018
Process Control Philipp Koehn 23 April 2018 Control Flow 1 The CPU executes one instruction after another Typically, they are next to each other in memory (unless jumps, branches, and returns from subroutine)
More informationCS 61C: Great Ideas in Computer Architecture. Lecture 23: Virtual Memory. Bernhard Boser & Randy Katz
CS 61C: Great Ideas in Computer Architecture Lecture 23: Virtual Memory Bernhard Boser & Randy Katz http://inst.eecs.berkeley.edu/~cs61c Agenda Virtual Memory Paged Physical Memory Swap Space Page Faults
More informationCSE 120. Translation Lookaside Buffer (TLB) Implemented in Hardware. July 18, Day 5 Memory. Instructor: Neil Rhodes. Software TLB Management
CSE 120 July 18, 2006 Day 5 Memory Instructor: Neil Rhodes Translation Lookaside Buffer (TLB) Implemented in Hardware Cache to map virtual page numbers to page frame Associative memory: HW looks up in
More informationUnderstanding the Design of Virtual Memory. Zhiqiang Lin
CS 6V8-05: System Security and Malicious Code Analysis Understanding the Design of Virtual Memory Zhiqiang Lin Department of Computer Science University of Texas at Dallas February 27 th, 202 Outline Basic
More informationMemory Management. Disclaimer: some slides are adopted from book authors slides with permission 1
Memory Management Disclaimer: some slides are adopted from book authors slides with permission 1 Demand paging Concepts to Learn 2 Abstraction Virtual Memory (VM) 4GB linear address space for each process
More informationVirtual Memory I. CSE 351 Winter Instructor: Mark Wyse
http://rebrn.com/re/bad-chrome-6282/ Virtual Memory I CSE 35 Winter 28 Instructor: Mark Wyse Teaching Assistants: Kevin Bi Parker DeWilde Emily Furst Sarah House Waylon Huang Vinny Palaniappan Administrative
More informationCSE 451: Operating Systems Winter Page Table Management, TLBs and Other Pragmatics. Gary Kimura
CSE 451: Operating Systems Winter 2013 Page Table Management, TLBs and Other Pragmatics Gary Kimura Moving now from Hardware to how the OS manages memory Two main areas to discuss Page table management,
More informationCS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 26
CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 2018 Lecture 26 CS24 FINAL EXAM Final exam format: 6 hour overall time limit, multiple sittings Open book/notes/slides/homework/solutions Can use computer
More informationMemory management. Requirements. Relocation: program loading. Terms. Relocation. Protection. Sharing. Logical organization. Physical organization
Requirements Relocation Memory management ability to change process image position Protection ability to avoid unwanted memory accesses Sharing ability to share memory portions among processes Logical
More informationSimple idea 1: load-time linking. Our main questions. Some terminology. Simple idea 2: base + bound register. Protection mechanics.
Our main questions! How is protection enforced?! How are processes relocated?! How is ory partitioned? Simple idea 1: load-time linking! Link as usual, but keep the list of references! At load time, determine
More informationCIS Operating Systems Memory Management Address Translation for Paging. Professor Qiang Zeng Spring 2018
CIS 3207 - Operating Systems Memory Management Address Translation for Paging Professor Qiang Zeng Spring 2018 Previous class What is logical address? Who use it? Describes a location in the logical memory
More informationCS5460: Operating Systems
CS5460: Operating Systems Lecture 2: OS Hardware Interface (Chapter 2) Course web page: http://www.eng.utah.edu/~cs5460/ CADE lab: WEB L224 and L226 http://www.cade.utah.edu/ Projects will be on Linux
More informationAddress spaces and memory management
Address spaces and memory management Review of processes Process = one or more threads in an address space Thread = stream of executing instructions Address space = memory space used by threads Address
More informationPROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo
PROCESS MANAGEMENT Operating Systems 2015 Spring by Euiseong Seo Today s Topics Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication
More informationLearning Outcomes. An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory.
Virtual Memory 1 Learning Outcomes An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory. 2 Memory Management Unit (or TLB) The position and function
More informationCS162 - Operating Systems and Systems Programming. Address Translation => Paging"
CS162 - Operating Systems and Systems Programming Address Translation => Paging" David E. Culler! http://cs162.eecs.berkeley.edu/! Lecture #15! Oct 3, 2014!! Reading: A&D 8.1-2, 8.3.1. 9.7 HW 3 out (due
More informationVirtual Memory. Patterson & Hennessey Chapter 5 ELEC 5200/6200 1
Virtual Memory Patterson & Hennessey Chapter 5 ELEC 5200/6200 1 Virtual Memory Use main memory as a cache for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs
More informationLearning Outcomes. An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory.
Virtual Memory Learning Outcomes An understanding of page-based virtual memory in depth. Including the R000 s support for virtual memory. Memory Management Unit (or TLB) The position and function of the
More informationCS 61C: Great Ideas in Computer Architecture. Lecture 23: Virtual Memory
CS 61C: Great Ideas in Computer Architecture Lecture 23: Virtual Memory Krste Asanović & Randy H. Katz http://inst.eecs.berkeley.edu/~cs61c/fa17 1 Agenda Virtual Memory Paged Physical Memory Swap Space
More informationInterrupts, Fork, I/O Basics
Interrupts, Fork, I/O Basics 12 November 2017 Lecture 4 Slides adapted from John Kubiatowicz (UC Berkeley) 12 Nov 2017 SE 317: Operating Systems 1 Topics for Today Interrupts Native control of Process
More informationMemory System Case Studies Oct. 13, 2008
Topics 15-213 Memory System Case Studies Oct. 13, 2008 P6 address translation x86-64 extensions Linux memory management Linux page fault handling Memory mapping Class15+.ppt Intel P6 (Bob Colwell s Chip,
More informationChangelog. Virtual Memory (2) exercise: 64-bit system. exercise: 64-bit system
Changelog Virtual Memory (2) Changes made in this version not seen in first lecture: 21 November 2017: 1-level example: added final answer of memory value, not just location 21 November 2017: two-level
More information