CSE 506: Opera.ng Systems
The Art and Science of Memory Alloca4on
Don Porter
1
The Art and Science of Memory Alloca4on Don Porter 1 CSE 506: - - PowerPoint PPT Presentation
CSE 506: Opera.ng Systems The Art and Science of Memory Alloca4on Don Porter 1 CSE 506: Opera.ng Systems Logical Diagram Binary Memory Threads Formats Allocators User System Calls Kernel Todays Lecture RCU File System Networking
1
2
3
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
5
6
7
8
9
small to be useful
10
11
next next next next next next Free next
12
13
next next next next next next Free next
14
15
16
17
behavior
18
19
20
– LIFO list of free blocks
21
22
Free List: Order: 2 Free List: 3 Free List: 4 Free List: 5 Free List: 11 . . .
23
24
25
26
27
CPU 0 Cache ldw 0x1008 CPU loads
(4 bytes) Memory Bus Cache Miss 0x1000 RAM Cache operates at line granularity (64 bytes)
28
CPU 0 Cache Memory Bus 0x1000 RAM CPU 1 Cache ldw 0x1010
29
CPU 0 Cache Memory Bus 0x1000 RAM CPU 1 Cache ldw 0x1010
stw 0x1000 Copies of line evicted 0x1000
30
31
Object foo (CPU 0 writes) Object bar (CPU 1 writes)
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47