COMP 790: OS Implementation
The Art and Science of Memory Allocation
Don Porter
1
The Art and Science of Memory Allocation Don Porter 1 COMP 790: - - PowerPoint PPT Presentation
COMP 790: OS Implementation The Art and Science of Memory Allocation Don Porter 1 COMP 790: OS Implementation Logical Diagram Binary Memory Threads Formats Allocators User System Calls Kernel Todays Lecture RCU File System
COMP 790: OS Implementation
1
COMP 790: OS Implementation
2
COMP 790: OS Implementation
3
COMP 790: OS Implementation
int main () { struct foo *x = malloc(sizeof(struct foo)); ... void * malloc (ssize_t n) { if (heap empty) mmap(); // add pages to heap find a free block of size n; }
4
COMP 790: OS Implementation
5
COMP 790: OS Implementation
6
COMP 790: OS Implementation
7
COMP 790: OS Implementation
8
COMP 790: OS Implementation
9
COMP 790: OS Implementation
small to be useful
10
COMP 790: OS Implementation
11
COMP 790: OS Implementation
next next next next next next Free next
12
COMP 790: OS Implementation
13
COMP 790: OS Implementation
next next next next next next Free next
14
COMP 790: OS Implementation
15
COMP 790: OS Implementation
16
COMP 790: OS Implementation
17
COMP 790: OS Implementation
behavior
18
COMP 790: OS Implementation
19
COMP 790: OS Implementation
20
COMP 790: OS Implementation
– LIFO list of free blocks
21
COMP 790: OS Implementation
22
Free List: Order: 2 Free List: 3 Free List: 4 Free List: 5 Free List: 11 . . .
COMP 790: OS Implementation
23
COMP 790: OS Implementation
24
COMP 790: OS Implementation
25
COMP 790: OS Implementation
26
COMP 790: OS Implementation
27
COMP 790: OS Implementation
CPU 0 Cache ldw 0x1008 CPU loads
(4 bytes) Memory Bus Cache Miss 0x1000 RAM Cache operates at line granularity (64 bytes)
28
COMP 790: OS Implementation
CPU 0 Cache Memory Bus 0x1000 RAM CPU 1 Cache ldw 0x1010
29
COMP 790: OS Implementation
CPU 0 Cache Memory Bus 0x1000 RAM CPU 1 Cache ldw 0x1010
stw 0x1000 Copies of line evicted 0x1000
30
COMP 790: OS Implementation
31
COMP 790: OS Implementation
Object foo (CPU 0 writes) Object bar (CPU 1 writes)
32
COMP 790: OS Implementation
33
COMP 790: OS Implementation
34
COMP 790: OS Implementation
35
COMP 790: OS Implementation
36
COMP 790: OS Implementation
37
COMP 790: OS Implementation
38
COMP 790: OS Implementation
39
COMP 790: OS Implementation
40
COMP 790: OS Implementation
41
COMP 790: OS Implementation
42
COMP 790: OS Implementation
43
COMP 790: OS Implementation
44
COMP 790: OS Implementation
45
COMP 790: OS Implementation
46
COMP 790: OS Implementation
47