Review


Know the Concepts

  • Describe the layout of memory when a Linux program starts.

  • What is the heap?

  • What is the current break?

  • Which direction does the stack grow in?

  • Which direction does the heap grow in?

  • What happens when you access unmapped memory?

  • How does the operating system prevent processes from writing over each other's memory?

  • Describe the process that occurs if a piece of memory you are using is currently residing on disk?

  • Why do you need an allocator?

Use the Concepts

  • Modify the memory manager so that it calls allocate_init automatically if it hasn't been initialized.

  • Modify the memory manager so that if the requested size of memory is smaller than the region chosen, it will break up the region into multiple parts. Be sure to take into account the size of the new header record when you do this.

  • Modify one of your programs that uses buffers to use the memory manager to get buffer memory rather than using the .bss.

Going Further

  • Research garbage collection. What advantages and disadvantages does this have over the style of memory management used here?

  • Research reference counting. What advantages and disadvantages does this have over the style of memory management used here?

  • Change the name of the functions to malloc and free, and build them into a shared library. Use LD_PRELOAD to force them to be used as your memory manager instead of the default one. Add some write system calls to STDOUT to verify that your memory manager is being used instead of the default one.




Programming from the Ground Up
Programming from the Ground Up
ISBN: 0975283847
EAN: 2147483647
Year: 2006
Pages: 137

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net