1 / 5

Memory Blocks in a Buddy System - Buddy Systems (2)

Memory Blocks in a Buddy System - Buddy Systems (2). In a buddy system, memory blocks are available of size 2 k , L <= K <= U, where: 2 L = smallest block that is allocated. 2 U = largest size block that is allocated.

Download Presentation

Memory Blocks in a Buddy System - Buddy Systems (2)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Memory Blocks in a Buddy System- Buddy Systems (2) • In a buddy system, memory blocks are available of size 2k, L <= K <= U, where: 2L = smallest block that is allocated. 2U = largest size block that is allocated. • Generally, 2U is the size of the entire memory available for allocation.

  2. Allocation Method - Buddy Systems (3) • To begin, the entire space available for allocation is treated as a single block of size 2U. If a request of size that 2 U-1 < s <= 2U is made, then the entire block is allocated. • Otherwise, the block is split into two equal buddies of size 2 U-1. If 2 U-2 < s<= 2U-1, then the request is allocated to one of the two buddies. • Otherwise, one of the buddies is split in half again. • This process continues until the smallest block greater than or equal to s is generated and allocated to the request.

  3. Remove Unallocated Blocks - Buddy Systems (4) • At any time, the buddy system maintains a list of holes (unallocated blocks) of each size 2 i. • A hole may be removed from the (i + 1) list by splitting it in half to create two buddies of size 2i in the i list. • Whenever a pair of buddies on the i list both become unallocated, they are removed from that list and coalesced into a single block on the • (i + 1) list.

  4. Example of Buddy System- Buddy Systems (5) 1 Megabyte Block 1M Request 100K (A) A=128K 128K 256K 512K Request 240K (B) A=128K 128K B=256K 512K Request 256K (D) A=128K 128K B=256KD=256K 256K Release B A=128K 128K 256K D=256K 256K Release A 512K D=256K 256K Request 75K (E) E=128K 128K 256K D=256K 256K Release E 512K D=256K 256K Release D 1M

  5. Tree Representation of Buddy System- Buddy Systems (6) 1M 512K 256K 128K A=128K 128K B=256KD=256K 256K

More Related