复旦大学:《计算机原理 Computer System》课程PPT课件_Dynamic Memory Allocation(• Implementation of a simple allocator • Explicit Free List • Segregated Free List)

Dynamic Memory Allocation
1 Dynamic Memory Allocation

Outline Implementation of a simple allocator Explicit Free List Segregated Free List 5 uggested reading:10.9,10.10,.10.110.12, 10.13 Segregate:隔离
2 Outline • Implementation of a simple allocator • Explicit Free List • Segregated Free List • Suggested reading: 10.9, 10.10, 10.11, 10.12, 10.13 Segregate:隔离

ynamic Memory Allocation P731 Explicit Vs. Implicit Memory Allocator Explicit: application allocates and frees space E.g., malloc and free in C Implicit: application allocates, but does not free space E.g. garbage collection in Java, ML or Lisp
3 Dynamic Memory Allocation P731 • Explicit vs. Implicit Memory Allocator – Explicit: application allocates and frees space • E.g., malloc and free in C – Implicit: application allocates, but does not free space • E.g. garbage collection in Java, ML or Lisp

Dynamic Memory Allocation Allocation In both cases the memory allocator provides an abstraction of memory as a set of blocks Doles out free memory blocks to application Doles:发放
4 Dynamic Memory Allocation • Allocation – In both cases the memory allocator provides an abstraction of memory as a set of blocks – Doles out free memory blocks to application Doles: 发放

10.9. 1 The malloc and free Functions
5 10.9.1 The malloc and free Functions

Malloc package P731 ·# include void * malloc(size t size if successful returns a pointer to a memory block of at least size bytes, aligned to 8-byte boundary if size==0. returnS NULL if unsuccessful returnS null void free( void*p returns the block pointed at by p to pool of available memory p must come from a previous call to malloc, calloc or realloc
6 Malloc package P731 • #include • void *malloc(size_t size) – if successful: • returns a pointer to a memory block of at least size bytes, aligned to 8-byte boundary. • if size==0, returns NULL – if unsuccessful: returns NULL • void free(void *p) – returns the block pointed at by p to pool of available memory – p must come from a previous call to malloc,calloc or realloc

sarko Function P732 ·# include void* sbrk(int incr) If successful It returns the old value of brk If unsuccessful · It returns-1 · It sets errno to nomen If incr is zero It returns the current value incr can be a negative number
7 sbrk() Function P732 • #include • void *sbrk(int incr) – If successful • It returns the old value of brk – If unsuccessful • It returns –1 • It sets errno to ENOMEM – If incr is zero • It returns the current value – incr can be a negative number

Assumptions Assumptions made in this lecture memory is word addressed (each word can hold a pointer) Free word Allocated block Free block (4 words) 3 words) Allocated word
8 • Assumptions made in this lecture – memory is word addressed (each word can hold a pointer) Allocated block (4 words) Free block (3 words) Free word Allocated word Assumptions

Allocation examples pl malloc(4) p2 malloc(5) 3=ma11oc(6) free(p2) p4 malloc(2) Figure 10.36 P733
9 p1 = malloc(4) p2 = malloc(5) p3 = malloc(6) free(p2) p4 = malloc(2) Allocation examples Figure 10.36 P733

10.9.2 Why Dynamic Memory Allocation
10 10.9.2 Why Dynamic Memory Allocation
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Virtual Memory(• Multilevel page tables • Different points of view • Pentium/Linux Memory System • Memory Mapping).ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Virtual Memory(• Virtual Space• Address translation • Accelerating translation• Different points of view).ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Cache Memory(• Cache mountain • Matrix multiplication).ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Cache Memory(• General concepts • 3 ways to organize cache memory • Issues with writes • Write cache friendly codes • Cache mountain).ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Memory Hierarchy(• Random-Access Memory(RAM)• Nonvolatile Memory • Disk Storage • Locality • Memory hierarchy).ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Hardware Organization.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_13 Code Optimization(• Optimizing Blockers • Understanding Modern Processor • More Code Optimization techniques • Performance Tuning).ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_12b Code Optimization(• Machine-Independent Optimization – Code motion – Memory optimization • Suggested reading).ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Pipelined Implementation Part II.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Pipelined Implementation Part I.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_09、10 Sequential CPU Implementation.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Processor Architecture.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Heterogeneous Data Structures & Alignment; Putting it Together; Floating Point.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Procedure Call and Array.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Machine-Level Representation of Programs Ⅱ.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Machine-Level Representation of Programs I.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Integer Operations; Floating Points.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Integer Representations.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Introduction to Computer Systems; Information is Bits+Context; Information Storage.ppt
- 复旦大学:《计算机原理 Computer System》课程资源_2006年期中考试题目.doc
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Linking II(• Static linking • Symbols & Symbol Table • Relocation • Executable Object Files • Loading).ppt
- 复旦大学:《计算机原理 Computer System》习题PPT课件_chapter2.pptx
- 复旦大学:《计算机原理 Computer System》习题PPT课件_Chapter 3 Machine-Level Representation of Programs.pptx
- 复旦大学:《计算机原理 Computer System》习题PPT课件_Chapter 3 Machine-Level Representation of Programs.pptx
- 复旦大学:《计算机原理 Computer System》习题PPT课件_Chapter 3 Machine-Level(2)Representation of Programs.ppt
- 复旦大学:《计算机原理 Computer System》习题PPT课件_chapter4 Processor Architecture.pptx
- 复旦大学:《计算机原理 Computer System》习题PPT课件_chapter5 Optimizing Program Performance.pptx
- 复旦大学:《计算机原理 Computer System》习题PPT课件_chapter6 The Memory Hierarchy.ppt
- 复旦大学:《计算机网络与网页制作》课程教学大纲 Computer Network and Webpage Design.pdf
- 《当代教育理论与实践》论文:大学计算机基础教学实践与思考(复旦大学:肖川、张向东).pdf
- 复旦大学:《计算机网络与网页制作》课程PPT教学课件(讲稿)01 计算机网络基础.pptx
- 复旦大学:《计算机网络与网页制作》课程PPT教学课件(讲稿)02 两类基本网络(局域网、无线局域网).pptx
- 复旦大学:《计算机网络与网页制作》课程PPT教学课件(讲稿)03 因特网基础知识.pptx
- 复旦大学:《计算机网络与网页制作》课程PPT教学课件(讲稿)04 传统的Internet服务.pptx
- 复旦大学:《计算机网络与网页制作》课程PPT教学课件(讲稿)05 新型的Internet应用.pptx
- 复旦大学:《计算机网络与网页制作》课程PPT教学课件(讲稿)06 Internet安全.pptx
- 复旦大学:《计算机网络与网页制作》课程PPT教学课件(讲稿)07 Dreamweaver CS5入门.pptx
- 复旦大学:《计算机网络与网页制作》课程PPT教学课件(讲稿)08 创建一个新站点.pptx
- 复旦大学:《计算机网络与网页制作》课程PPT教学课件(讲稿)09 添加文本和图像.pptx
- 复旦大学:《计算机网络与网页制作》课程PPT教学课件(讲稿)10 用CSS设定页面样式.pptx