Implement a simple dynamic memory management, which operates on the principle shown in the following sketch.
This will enable memory management, memory to allocate in any order and re-release. See also Dynamic memory management
Write contains a module
heap for memory management itself, which has the following functions (exported): -
halloc void * (size_t size);size to request memory size -
hfree void (void * p);to release the memory pointed to by the pointers p.
Create spends another version of the module
heap that each call to halloc (hfree) or () the entire memory in readable form on stderr, so that the allocating of can see blocks of memory (the size of the heap should be given more be small !). Write your a module which tests your memory management by requesting memory, and discover evidence of the allocated memory and then free the memory in different versions.
do this, create a list of test cases and describe the results of the tests (which dumps you get with the above version of the module).
examples of test cases:
n. review: allocate a string of length
HEAPSIZE - sizeof (heap_t) fill the string with a loud 'A' and output of the string. OK n +1. review: Releasing the memory test from n . is OK
For each test Indicate whether the test was successful. If a test was not successful, then determine why and if necessary to resolve the error. If you change something in the program, they must all tests are done again!
Write a suitable Makefile , which allows you to create an alternative version of the normal heap
and the test version of heap! Organize in small groups and try to draw together the various functions and to program. What help facilities such as the need
halloc () ? Expand the storage management to a "Garbage Collection", the free memory areas, the succession are summarized.
Create a suitable directory structure and use
CVS . Replace the module with other groups (that would be easy, since the interfaces are always the same (see above)
levy.
Name the project
5AD- name -heap or 5BD - name -heap and you'll check it further answer the following questions (the answers must be in the file
heap.txt be stored): - What happens when a string of length n . allocated and a string of length n stores?
- What happens when a string of length n allocated and a string of length n + 1 stores ?
- you allocate a string of length 11 and save
0123456789and type the string again. Then you allocate a string of length 20 and give out the string. What happened? (The memory requirements and the release must take place immediately after the other). - What storage requirements require more memory - 10 strings of length 100 or 100 strings of length 10? Explain your answer.
- How could you in the module
heapEnsure that for a call tohfree (p); actuallyp parameter points to awithhalloc ()allocated memory area?
heap.txt must also contain the list of test cases with their results. Type an expression of the prepared questions from!
0 comments:
Post a Comment