forked from ClydeProjects/EagleTree
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathevent.cpp
More file actions
143 lines (132 loc) · 3.98 KB
/
Copy pathevent.cpp
File metadata and controls
143 lines (132 loc) · 3.98 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include <assert.h>
#include <stdio.h>
#include "ssd.h"
using namespace ssd;
uint Event::id_generator = 0;
uint Event::application_io_id_generator = 0;
/* see "enum event_type" in ssd.h for details on event types */
Event::Event(enum event_type type, ulong logical_address, uint size, double start_time):
start_time(start_time),
execution_time(0.0),
bus_wait_time(0.0),
os_wait_time(0.0),
type(type),
logical_address(logical_address),
size(size),
payload(NULL),
//next(NULL),
noop(false),
id(id_generator++),
application_io_id(application_io_id_generator++),
garbage_collection_op(false),
wear_leveling_op(false),
mapping_op(false),
original_application_io(false),
age_class(0),
tag(-1),
accumulated_wait_time(0),
thread_id(UNDEFINED),
pure_ssd_wait_time(0),
copyback(false),
cached_write(false),
num_iterations_in_scheduler(0)
{
assert(start_time >= 0.0);
if (logical_address > NUMBER_OF_ADDRESSABLE_BLOCKS() * BLOCK_SIZE) {
printf("invalid logical address, too big %d %d\n", logical_address, NUMBER_OF_ADDRESSABLE_BLOCKS() * BLOCK_SIZE);
assert(false);
}
}
Event::Event(Event& event) :
start_time(event.start_time),
execution_time(event.execution_time),
bus_wait_time(event.bus_wait_time),
os_wait_time(0.0),
type(event.type),
logical_address(event.logical_address),
size(event.size),
payload(NULL),
//next(NULL),
noop(event.noop),
id(id_generator++),
application_io_id(event.application_io_id),
garbage_collection_op(event.garbage_collection_op),
wear_leveling_op(event.wear_leveling_op),
mapping_op(event.mapping_op),
original_application_io(event.original_application_io),
age_class(event.age_class),
tag(event.tag),
accumulated_wait_time(0),
thread_id(event.thread_id),
pure_ssd_wait_time(event.pure_ssd_wait_time),
copyback(event.copyback),
cached_write(event.cached_write),
num_iterations_in_scheduler(0)
{}
bool Event::is_flexible_read() {
return dynamic_cast<Flexible_Read_Event*>(this) != NULL;
}
Event::Event() : type(NOT_VALID) {}
void Event::print(FILE *stream) const
{
if (type == NOT_VALID)
fprintf(stream, "<NOT VALID> ");
else if(type == READ)
fprintf(stream, "R ");
else if(type == READ_COMMAND)
fprintf(stream, "C ");
else if(type == READ_TRANSFER)
fprintf(stream, "T ");
else if(type == WRITE)
fprintf(stream, "W ");
else if(type == ERASE)
fprintf(stream, "E ");
else if(type == MERGE)
fprintf(stream, "M ");
else if (type == TRIM)
fprintf(stream, "D ");
else if (type == GARBAGE_COLLECTION)
fprintf(stream, "GC ");
else if (type == COPY_BACK)
fprintf(stream, "CB ");
else
fprintf(stream, "Unknown event type: ");
fprintf(stream, "%d\t", logical_address);
if (type != TRIM) {
address.print(stream);
} else {
replace_address.print(stream);
}
//if(type == MERGE)
//merge_address.print(stream);
//if(type == WRITE || type == TRIM || type == COPY_BACK)
//replace_address.print(stream);
//fprintf(stream, " Time[%f, %f, %f, %f, %f, %f]", start_time, os_wait_time, accumulated_wait_time, bus_wait_time, execution_time, get_current_time());
fprintf(stream, " Time[%d, %d, %d, %d]", (int)start_time, (int)os_wait_time, (int)bus_wait_time, (int)execution_time);
//fprintf(stream, " Time[%d, %d, %d]", (int)start_time, (int)bus_wait_time, (int)get_current_time());
//fprintf(stream, "\tTime[%d, %d, %d, %d]", (int)start_time, (int) (start_time + os_wait_time),(int) bus_wait_time + (int)os_wait_time, (int) get_current_time());
fprintf(stream, " ID: %d ", id);
fprintf(stream, " appID: %d", application_io_id);
if(thread_id != UNDEFINED) {
fprintf(stream, " thread: %d", thread_id);
}
if (garbage_collection_op) {
fprintf(stream, " GC");
} else if (mapping_op) {
fprintf(stream, " MAPPING");
}
if (wear_leveling_op) {
fprintf(stream, " WL");
}
if (original_application_io) {
fprintf(stream, " APP");
}
if (type == GARBAGE_COLLECTION) {
fprintf(stream, " age class: %d", age_class);
}
fprintf(stream, "\n");
}
void Event::reset_id_generators() {
Event::id_generator = 0;
Event::application_io_id_generator = 0;
}