Assignment 11, due July 23

Machine Prolbem 5, due July 28

Part of the homework for 22C:50, Summer 2004
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Machine Problem 5, due July 28

A Heap Manager

You are to write a heap manager supporting the following interface:

called to initialize your heap data structures; your heap should be a static array of 10,000 void* pointers (call them words for convenience).

void * myalloc(int s);
returns a newly allocated a block of s consecutive bytes. If the heap is full, it should return a null pointer.

myfree(void * p, int s);
called to deallocate the block of s consecutive bytes pointed to by p.

A main program to test your heap manager is provided in:

If you change the name myalloc to malloc and you change the name myfree to free in this test program and eliminate the second parameter to myfree, you can test the test program using the built-in heap manager.

Your storage manager should use the buddy system (see figures 14.3 and 14.4 in the notes). Since this much code is already given, the real assignment is as follows:

Assignment 11, due July 23

  1. Do problem 6, from chapter 14 of the notes.

  2. Consider this little bit of code:
       int fibonacci(int i);
          int f1,f2;
          if (i < 2) return i;
          f1 = fibonacci(i-1);
          f2 = fibonacci(i-2);
          return f1 + f2;

    Describe the contents and structure of the activation record for fibonacci() taking into account everything you know about assembly language programming. State any assumptions you made; for example, you will get a different result if you assume f1 and f2 are stored in RAM or are temporarily assigned to registers.