TAOCP 2.5 Exercise 5

No.

Section 2.5: Dynamic Storage Allocation

Exercise 5. [**] [18] Suppose it is known that N is always 100 or more in Algorithm A. Would it be a good idea to set $c=100$ in the modified step A4'?

Verified: yes
Solve time: 2m26s


No. In the modified step A4', the parameter $c$ determines the threshold below which a block is not split. Setting $c=100$ means that whenever the remainder after allocation is less than $100$ words, the entire block is given to the requester.

Since $N\ge100$, every request is large, but this fact does not justify wasting as much as $99$ words on a single allocation. The purpose of $c$ is to avoid creating unusably small fragments; it should therefore be chosen according to the minimum useful block size, not according to the minimum request size. A value as large as $100$ would increase internal fragmentation substantially, because many blocks would be enlarged by amounts ranging from $1$ to $99$ words. The saving in list-management overhead would generally not compensate for this loss of storage.

Therefore setting $c=100$ is generally not a good idea. A much smaller value of $c$, related to the smallest practical free-block size, is preferable.