Sorted-List Technique Boundary-Tag Technique

J.E.D.I reserved block reserved block free block free block B freed block B free block B free block B free block C reserved block C free block C reserved block C free block a b c d Figure 1.130 Possible Cases in Liberation Figure 1.131 Figure 1.132 In the figure, block B is freed. a shows two reserved adjacent blocks, b and c show one free adjacent block and d shows two free adjacent blocks. To liberate, the freed block must be merged with a free adjacent block, if there is any. There are two collapsing methods at liberation: sorted-list technique and boundary- tag technique.

7.6.3.1 Sorted-List Technique

In sorted-list technique, the avail list is contributed as a singly-linked list and assumed to be sorted on increasing memory addresses. When a block is freed, collapsing is needed in the following cases: • The newly freed block comes before a free block; • The newly freed block comes after a free block; or • The newly freed block comes before and after free blocks. To know if a freed block is adjacent to any of the free blocks in the avail list, we use the block size. To collapse two blocks, the SIZE field of the lower block, address-wise, is simply updated to contain the sum of the sizes of the combined blocks. For example, Data Structures 147 J.E.D.I Data Structures 148 J.E.D.I Figure 1.133 Examples of Liberation Data Structures 149 J.E.D.I

7.6.3.2 Boundary-Tag Technique

Boundary tag technique uses two control words and double linking. The first and the last words contain control details. The following figure shows the link structure and the two states of a block reserved and free: a free block b reserved block Figure 1.134 Node Strucuture in Boundary-Tag Technique The value of TAG is 0 if the block is free, otherwise it is 1. Two TAG and SIZE fields are present to make merging of free blocks execute in O1 time. The avail list is constituted as a doubly-linked list with a list head. Initially, the avail list consists of just one block, the whole memory pool, bounded below and above by memory blocks not available for DMA. The following figure shows the initial state of the avail list: Data Structures 150 J.E.D.I Figure 1.135 The Initial State of the Memory Pool After using the memory for some time, it will leave discontinuous segments, thus we have this avail list: Figure 1.136 Avail List after Several Allocations and Deallocations Sorted-list technique is in Om, where m is the number of blocks in the avail list. Boundary-tag technique has time complexity O1. Data Structures 151 J.E.D.I

7.6.4 Buddy-System Methods