+1 vote
156 views
in Compilers & Operating Systems by

1 Answer

+1 vote
by
selected by (user.guest)
 
Best answer

Explicit Allocation of Fixed Sized Blocks: In this approach, blocks are drawn from contiguous area of storage, and an area of each block is used as pointer to the next block 

  •  The pointer available points to the first block
  • Allocation means removing a block from the available list
  •  De-allocation means putting the block in the available list
  •  Compiler routines need not know the type of objects to be held in the blocks
  •  Each block is treated as a variant record

Suppose that blocks are to be drawn from a contiguous area of storage. Initialization of the area is done by using a portion of each block for a link to the next block. A pointer available points to the first block. Generally a list of free nodes and a list of allocated nodes is maintained, and whenever a new block has to be allocated, the block at the head of the free list is taken off and allocated (added to the list of allocated nodes). When a node has to be de-allocated, it is removed from the list of allocated nodes by changing the pointer to it in the list to point to the block previously pointed to by it, and then the removed block is added to the head of the list of free blocks. The compiler routines that manage blocks do not need to know the type of object that will be held in the block by the user program. These blocks can contain any type of data (i.e., they are used as generic memory locations by the compiler). We can treat each block as a variant record, with the compiler routines viewing the block as consisting of some other type.  

Thus, there is no space overhead because the user program can use the entire block for its own purposes. When the block is returned, then the compiler routines use some of the space from the block itself to link it into the list of available blocks, as shown in the figure in the last slide.

Limitations of Fixed sized block allocation:

In explicit allocation of fixed size blocks, internal fragmentation can occur, that is, the heap may consist of alternate blocks that are free and in use.

The situation shown can occur if a program allocates five blocks and then de-allocates the second and the fourth, for example. 

Fragmentation is of no consequence if blocks are of fixed size, but if they are of variable size, a situation like this is a problem, because we could not allocate a block larger than any one of the free blocks, even though the space is available in principle. So, if variable- sized blocks are allocated, then internal fragmentation can be avoided, as we only allocate as much space as we need in a block. But this creates the problem of external fragmentation, where enough space is available in total for our requirements, but not enough


Related questions

+1 vote
1 answer 1.5k views
+2 votes
1 answer 157 views
asked Oct 9, 2021 in Computer Aided Design by anonymous
+1 vote
1 answer 408 views
+1 vote
1 answer 683 views
+1 vote
1 answer 127 views
+1 vote
1 answer 47 views
+1 vote
1 answer 520 views
+1 vote
0 answers 88 views
+1 vote
1 answer 16 views
+1 vote
1 answer 17 views
+1 vote
1 answer 33 views
+1 vote
1 answer 35 views
+1 vote
1 answer 34 views
+1 vote
1 answer 58 views
+1 vote
1 answer 76 views
+1 vote
1 answer 105 views
+1 vote
1 answer 192 views
+1 vote
1 answer 3.2k views
+1 vote
1 answer 280 views
+2 votes
1 answer 402 views
+1 vote
1 answer 1.5k views
+3 votes
1 answer 4.6k views
+2 votes
1 answer 2.1k views
+1 vote
1 answer 3.7k views
+2 votes
1 answer 7.0k views
+1 vote
1 answer 1.0k views
+1 vote
1 answer 91 views
+1 vote
1 answer 202 views
+1 vote
1 answer 477 views
+1 vote
0 answers 68 views
+1 vote
1 answer 75 views
Welcome to CPENTalk.com
Solution-oriented students of computer engineering on one platform to get you that

ONE SOLUTION

...