1,303 views
0 votes
0 votes
A swapping system eliminates holes by compaction. Assuming a random distribution of many holes and many data segments and a time to read or write a $32-bit$ memory word of $4\:nsec$, about how long does it take to compact $4\: GB?$ For simplicity, assume that word $0$ is part of a hole and that the highest word in memory contains valid data.

2 Answers

0 votes
0 votes

Answer:

Total memory addresses$=4\times 2^{30}/4 = 2^{30} \; \text {memory address}$

Compaction time $=\text{(read + write)} \times \text{Number of memory access} \\= 2 \times 4\times 10^{-9}\times 2^{25}  \\= 8 \times 0.033554432 = 0.268435456 = 263.4 \;\text{ms}$

0 votes
0 votes
This is what I think the logic should be.

For compaction, we need to read and write every addressable unit once. How?

First consideration: Since it says random distribution and says ‘many’ holes and ‘many’ data. I am assuming equal number of holes and data segments.

So we can maintain 2 pointers, the first pointer will point to the hole from LHS and the second pointer will search for data from RHS to be swapped with this newly found hole. So by the time, we have found both the hole and data, we would have completed 2 READ operations. Similarly, we need swap to data and hole content, hence 2 writes. And this will happen for each memory address.

And hence we can say compaction time=(read time+write time) * number of addressable memory units

= (4+4) * $2^{30}$ ns

Please comment down if you think the solution is wrong.

Related questions

1 votes
1 votes
0 answers
2
admin asked Oct 26, 2019
596 views
Using the page table of Fig. $3-9,$ give the physical address corresponding to each of the following virtual addresses:$20$$4100$$8300$
0 votes
0 votes
0 answers
3
admin asked Oct 26, 2019
349 views
For each of the following decimal virtual addresses, compute the virtual page number and offset for a $4-KB$ page and for an $8 KB$ page$:20000, 32768, 60000.$
1 votes
1 votes
1 answer
4