-
Notifications
You must be signed in to change notification settings - Fork 1
/
definitions.h
64 lines (52 loc) · 1.98 KB
/
definitions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
INSTRUCTIONS:
All enum, structs and functions to be declared here.
If a definition is already declared, do not change it.
You may add extra definitions as required.
*/
#ifndef __DEF_H__
#define __DEF_H__
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <time.h>
#include <math.h>
#include "fort.h" // Header file for library for printing the formated table
#include <string.h>
//----------------------------------------------------------------
//----------------------------------------------------------------
/* ALL ENUMERATORS HERE */
// LOOP - Workload type for Loop
// RANDOM - Workload type for RANDOM
// LOCAL - 80-20 workload type
typedef enum enum_workloads{LOOP, RANDOM, LOCAL}WorkloadsT;
//----------------------------------------------------------------
//----------------------------------------------------------------
/* ALL STRUCTS HERE */
struct workload
{
// Defines type of workload
WorkloadsT type;
// The number of pages in workload
int pages;
// The total size of the workload
int size;
// The final work to run the policy
int * work; // https://www.geeksforgeeks.org/pointer-array-array-pointer/
};
//----------------------------------------------------------------
//----------------------------------------------------------------
/* ALL FUNCTION DEFINITIONS HERE */
struct workload * generate_workload(WorkloadsT type, int pages, int size);
struct workload * generate_random(struct workload * w);
struct workload * generate_loop(struct workload * w);
struct workload * generate_local(struct workload * w);
float policy_FIFO(struct workload * w, int cache_size);
float policy_LRU(struct workload * w, int cache_size);
float policy_RANDOM(struct workload * w, int cache_size);
float policy_LRUapprox(struct workload * w, int cache_size);
void loop_csv(struct workload* work_load, int cache_size);
void random_csv(struct workload* work_load, int cache_size);
void local_csv(struct workload* work_load, int cache_size);
#endif /* __DEF_H__ */