3i Infotech Placement: Sample Questions 1181 - 1181 of 1245

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 1181

Edit

Describe in Detail

Essay▾

Describe the Buddy system of memory allocation.

Explanation

Buddy System in Image
  • Free memory is maintained linked list, each of equal sized blocks.
  • Blocks on the kth level is of size .
  • When memory is required by a process, the block size of next higher order is divided into two- the two pieces differ in address only in their bit.
  • This technique allocates memory in power of 2, example , where x is an integer.
  • The programmer has to decide on, or to write code to obtain, the upper limit of x.
  • Unfortunately this system results in making it impossible to allocate a single remaining 976k of memory into smaller block.

Working

  • Every memory block in system has an order, where the order is an integer ranging from 0 to a specified upper limit.
  • The size of a block of order n is proportional to .
  • Blocks are exactly twice the size of blocks that are one order lower.
  • When a larger block is split, it is divided into two smaller blocks- every block becoming unique buddy to other.
  • The size of the smallest possible block determines the smallest memory block that can be allocated.
  • Low limit is desirable to minimize average memory waste per allocation.
  • Smallest block size is that of order-0 block.
  • Higher orders are expressed as powers of two.

Developed by: