Operating Systems Lab:     Assignment  6                      (Marks 10)
 

         Date of assignment out: 12.10.2006                                      Last date of report:  26.10.2006


                         struct mMemoryArea {
                               void *firstFree ;                    // Address of the first free area
                               unsigned totA ;                    // Total area
                               unsigned freeA;                   // Free area
                               unsigned  largestFreeA ;     // Size of the largest free area
                               unsigned numFreeA;           // Number of free areas
                     }
                     void strategy(unsigned fit, unsigned list) ;
                     void *mMalloc(unsigned n);
                     void  mFree(void *p); 
                     void  mArea(struct mMemoryArea *p) ;
   
If the size of a selected block is more than 16 bytes of the requested size, it is split  and the remaining portion of  the block is inserted  in the free block list with proper initialization and following the selected strategy. The first 4 bytes of a free block holds its size, the remaining portion of a free block (4 bytes aligned to 8 byte boundary) is used to store the address of the next free block in the list. If there are two adjacent free blocks, they are to be merged to form a larger free block. The head of the free block list will be in a global variable in the library.
                                     $ gcc -Wall -c mmalloc.c
                              $ ar -qv libmmalloc.a mmalloc.o
                              $ gcc -Wall testMyMalloc.c -L. -lmmalloc