You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.3 KiB

  1. #####################################################################
  2. # CS:APP Malloc Lab
  3. # Traces
  4. #
  5. # Copyright (c) 2002, R. Bryant and D. O'Hallaron, All rights reserved.
  6. # May not be used, modified, or copied without permission.
  7. #
  8. ######################################################################
  9. This directory contains traces of allocate and free requests that are
  10. used by the test harness to evaluate the student malloc packages.
  11. *********
  12. 1. Files
  13. *********
  14. *.rep Original traces
  15. *-bal.rep Balanced versions of the original traces
  16. gen_XXX.pl Perl script that generates *.rep
  17. checktrace.pl Checks trace for consistency and outputs a balanced version
  18. Makefile Generates traces
  19. Note: A "balanced" trace has a matching free request for each allocate
  20. request.
  21. **********************
  22. 2. Building the traces
  23. **********************
  24. To rebuild the traces from scratch, type
  25. unix> make
  26. ********************
  27. 3. Trace file format
  28. ********************
  29. A trace file is an ASCII file. It begins with a 4-line header:
  30. <sugg_heapsize> /* suggested heap size (unused) */
  31. <num_ids> /* number of request id's */
  32. <num_ops> /* number of requests (operations) */
  33. <weight> /* weight for this trace (unused) */
  34. The header is followed by num_ops text lines. Each line denotes either
  35. an allocate [a], reallocate [r], or free [f] request. The <alloc_id>
  36. is an integer that uniquely identifies an allocate or reallocate
  37. request.
  38. a <id> <bytes> /* ptr_<id> = malloc(<bytes>) */
  39. r <id> <bytes> /* realloc(ptr_<id>, <bytes>) */
  40. f <id> /* free(ptr_<id>) */
  41. For example, the following trace file:
  42. <beginning of file>
  43. 20000
  44. 3
  45. 8
  46. 1
  47. a 0 512
  48. a 1 128
  49. r 0 640
  50. a 2 128
  51. f 1
  52. r 0 768
  53. f 0
  54. f 2
  55. <end of file>
  56. is balanced. It has a recommended heap size of 20000 bytes (ignored),
  57. three distinct request ids (0, 1, and 2), eight different requests
  58. (one per line), and a weight of 1 (ignored).
  59. ************************
  60. 4. Description of traces
  61. ************************
  62. * short{1,2}-bal.rep
  63. Tiny synthetic tracefiles for debugging
  64. * {amptjp,cccp,cp-decl,expr}-bal.rep
  65. Traces generated from real programs.
  66. * {binary,binary2}-bal.rep
  67. The allocation pattern is to alternatively allocate a small-sized
  68. chunk of memory and a large-sized chunk. The small-sized chunks
  69. (either 16 or 64 ) are deliberately set to be power of 2 while the
  70. large-size chunks (either 112 or 448) are not a power of 2. Defeats
  71. buddy algorithms. However, a simple-minded algorithm might prevail in
  72. this scenario because a first-fit scheme will be good enough.
  73. * coalescing-bal.rep
  74. Repeatedly allocate two equal-sized chunks (4095 in size) and release
  75. them, and then immediately allocate and free a chunk twice as big
  76. (8190). This tests if the students' algorithm ever really releases
  77. memory and does coalescing. The size is chosen to give advantage to
  78. tree-based or segrated fits algorithms where there is no header or
  79. footer overhead.
  80. * {random,random2}-bal.rep
  81. Random allocate and free requesets that simply test the correctness
  82. and robustness of the algorithm.
  83. * {realloc,realloc2}-bal.rep
  84. Reallocate previously allocated blocks interleaved by other allocation
  85. request. The purpose is to test whether a certain amount of internal
  86. fragments are allocated or not. Naive realloc implementations that
  87. always realloc a brand new block will suffer.