search_algorithms.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright 2011 Institute of Communication and Computer Systems (ICCS)
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. /**
  18. * \file search_algorithms.h
  19. * \author Ioannis Koutras (joko@microlab.ntua.gr)
  20. * \date September, 2011
  21. *
  22. * \brief Various search algorithms for linked list structures used on DMMLib.
  23. */
  24. #ifndef LINKED_LISTS_SEARCH_ALGORITHMS_H
  25. #define LINKED_LISTS_SEARCH_ALGORITHMS_H
  26. #include <dmmlib/heap.h>
  27. #include <dmm_config.h>
  28. #ifdef WITH_FIXED_LISTS
  29. /**
  30. * Perform an exact-fit search on fixed lists for a block of a certain size
  31. *
  32. * \param heap The heap whose fixed lists should be accessed.
  33. * \param requested_size The desired size of the block.
  34. *
  35. * \return The pointer of the data part of the matched memory block.
  36. * \retval NULL No block was found.
  37. */
  38. void * search_on_fixed(heap_t * heap, size_t requested_size);
  39. #endif /* WITH_FIXED_LISTS */
  40. /**
  41. * Perform a best-fit search on free lists for a block of a certain size
  42. *
  43. * \param heap The heap whose fixed lists should be accessed.
  44. * \param requested_size The desired size of the block.
  45. *
  46. * \return The pointer of the data part of the matched memory block.
  47. * \retval NULL No block was found.
  48. */
  49. void * best_fit_on_freelist(heap_t *heap, size_t requested_size);
  50. /**
  51. * Perform a good-fit search on the free list
  52. *
  53. * \param heap The heap whose free list should be accessed.
  54. * \param requested_size The desired size of the block.
  55. * \param fit_percentage The lowest acceptable percentage of the block space to be filled.
  56. *
  57. * \return The pointer to the data part of the matched memory block.
  58. * \retval NULL No block was found.
  59. */
  60. void * good_fit_on_freelist(heap_t *heap, size_t requested_size, float fit_percentage);
  61. /**
  62. * Perform an exact-fit search on free lists for a block of a certain size
  63. *
  64. * \param heap The heap whose fixed lists should be accessed.
  65. * \param requested_size The desired size of the block.
  66. *
  67. * \return The pointer of the data part of the matched memory block.
  68. * \retval NULL No block was found.
  69. */
  70. void * exact_fit_on_freelist(heap_t *heap, size_t requested_size);
  71. /**
  72. * Perform a first-fit search on free lists for a block of a certain size
  73. *
  74. * \param heap The heap whose fixed lists should be accessed.
  75. * \param requested_size The desired size of the block.
  76. *
  77. * \return The pointer of the data part of the matched memory block.
  78. * \retval NULL No block was found.
  79. */
  80. void * first_fit_on_freelist(heap_t *heap, size_t requested_size);
  81. #endif /* LINKED_LISTS_SEARCH_ALGORITHMS_H */