Advertisement
Guest User

Untitled

a guest
Jan 31st, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #include "mtmm.h"
  2. #include <math.h>
  3. #define FIRST 0
  4. #define BASE 2
  5. #define NUMPROCESSORS 2
  6. #define FAILURE 0
  7. #define SUCCESS 1
  8. #define ZERO 0
  9. #define HEADERADDRESS -1
  10. #define NOTCALLED 0
  11. #define CALLED 1
  12. #define SYSTEMCALLERROR -1
  13. #define NUMOFEQUALDIGITSINTHREADS 12
  14. #define NUMSIZECLASSES (int)(ceil(log2(SUPERBLOCK_SIZE)))
  15. #define CURRENTSIZECLASS(x) ceil(log2(NUMSIZECLASSES))
  16. #define POWER(x) pow(BASE, x)
  17. #define K 0
  18. #define f 0.25
  19. int MALLOCCALLED=NOTCALLED;
  20. typedef struct statistics
  21. {
  22. int all;
  23. int used;
  24. }Statistics;
  25.  
  26. typedef struct block
  27. {
  28. struct superblock * superblock;
  29. int size;
  30. struct block * prev;
  31. struct block * next;
  32. }Block;
  33.  
  34. typedef struct superblockheader
  35. {
  36. Statistics statistics;
  37. struct superblock * prev;
  38. struct superblock * next;
  39. struct superblock * first;
  40. pthread_t * superblockmutex;
  41. struct heapinfo * heap;
  42. }SuperBlockHeader;
  43.  
  44. typedef struct superblock
  45. {
  46. SuperBlockHeader * superblockheader;
  47. struct block * blocks;
  48. }SuperBlock;
  49.  
  50. typedef struct sizeclass
  51. {
  52. int size;
  53. SuperBlock * superblocks;
  54. }SizeClass;
  55.  
  56. typedef struct heapinfo
  57. {
  58. pthread_t *heapmutex;
  59. Statistics statistics;
  60. SizeClass sizeclass[16];
  61. }Heap;
  62.  
  63. typedef struct HoardAllocator
  64. {
  65. Heap processorheap [NUMPROCESSORS];
  66. Heap globalheap;
  67. }Hoard;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement