Discussion :: Operating Systems Concepts - Section 1 (Q.No.16)
|Venu said: (Jun 8, 2012)|
|Compaction attacks the problem of fragmentation by moving all the allocated blocks to one end of memory, thus combining all the holes. Aside from the obvious cost of all that copying, there is an important limitation to compaction: Any pointers to a block need to be updated when the block is moved. Unless it is possible to find all such pointers, compaction is not possible. Pointers can stored in the allocated blocks themselves as well as other places in the client of the memory manager. In some situations, pointers can point not only to the start of blocks but also into their bodies. For example, if a block contains executable code, a branch instruction might be a pointer to another location in the same block. Compaction is performed in three phases. First, the new location of each block is calculated to determine the distance the block will be moved. Then each pointer is updated by adding to it the amount that the block it is pointing (in)to will be moved. Finally, the data is actually moved. There are various clever tricks possible to combine these operations.|
|Nishad Magdum said: (Jul 4, 2013)|
|Can anyone tell me what is exactly compaction and fragmentation?|
|Naresh Purohit said: (May 19, 2014)|
|Can We call Compaction as Garbage Collection?
Is it true?
|Urvashi said: (Aug 23, 2014)|
|How can compaction be termed as garbage collection?|
|Farheen Gulzar said: (Nov 25, 2014)|
|Compaction : It means moving the "in-use" memory areas to eliminate holes caused by terminated processes. Suppose we have five processes A, B, C, D, E, allocated as |A|B|C|D|E| in memory. After sometime process B and D are terminated. Now we have memory layout as |A| |C| |E|.
After applying compaction we will have |A|C|E| | | i.e. instead of two one-block memory unit we have one two-block memory unit.
Defragmentation :- It means storing complete file in smallest number of contiguous regions. That is, it tries to store file as one complete unit if that size of contiguous memory is available.
Suppose process A has fragments A1, A2, A3, process B has fragments B1, B2. Now, suppose memory layout is |A1|B1|A2|A3|B2|, after defragmentation we have |A1|A2|A3|B1|B2|.
|Mohammed Ramzan said: (Nov 22, 2016)|
|Nice explanation, Thank you all.|
|Prateek said: (Jun 25, 2017)|
|Compaction involves reallocation and is also known as Garbage Collection.|
|Karishma said: (Aug 23, 2017)|
|Thank you all.|
|Shiva said: (Jun 6, 2020)|
|Thank you for explaining.|
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.