Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "mtmm.h"
- #include <math.h>
- #define FIRST 0
- #define BASE 2
- #define NUMPROCESSORS 2
- #define FAILURE 0
- #define SUCCESS 1
- #define ZERO 0
- #define HEADERADDRESS -1
- #define NOTCALLED 0
- #define CALLED 1
- #define SYSTEMCALLERROR -1
- #define NUMOFEQUALDIGITSINTHREADS 12
- #define NUMSIZECLASSES (int)(ceil(log2(SUPERBLOCK_SIZE)))
- #define CURRENTSIZECLASS(x) ceil(log2(NUMSIZECLASSES))
- #define POWER(x) pow(BASE, x)
- #define K 0
- #define f 0.25
- int MALLOCCALLED=NOTCALLED;
- typedef struct statistics
- {
- int all;
- int used;
- }Statistics;
- typedef struct block
- {
- struct superblock * superblock;
- int size;
- struct block * prev;
- struct block * next;
- }Block;
- typedef struct superblockheader
- {
- Statistics statistics;
- struct superblock * prev;
- struct superblock * next;
- struct superblock * first;
- pthread_t * superblockmutex;
- struct heapinfo * heap;
- }SuperBlockHeader;
- typedef struct superblock
- {
- SuperBlockHeader * superblockheader;
- struct block * blocks;
- }SuperBlock;
- typedef struct sizeclass
- {
- int size;
- SuperBlock * superblocks;
- }SizeClass;
- typedef struct heapinfo
- {
- pthread_t *heapmutex;
- Statistics statistics;
- SizeClass sizeclass[16];
- }Heap;
- typedef struct HoardAllocator
- {
- Heap processorheap [NUMPROCESSORS];
- Heap globalheap;
- }Hoard;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement