-
Notifications
You must be signed in to change notification settings - Fork 81
/
SSDSim.cpp
60 lines (46 loc) · 1.32 KB
/
SSDSim.cpp
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
/*
* SSDSim.cpp
*
* Created on: Feb 21, 2011
* Author: silverwolf
*/
#include "SSDSim.h"
#include <stdio.h>
#ifdef __cplusplus
#include "ssd.h"
#include <sys/time.h>
using namespace ssd;
#endif
void SSD_Initialize()
{
load_config();
print_config(NULL);
ssdImpl = new Ssd();
gettimeofday(&ssd_boot_time, NULL);
printf("Booted the SSD Simulator.\n");
}
void SSD_Cleanup()
{
printf("SSD Simulator killed.\n");
delete ssdImpl;
}
void SSD_Write(unsigned long long address, int size, void *buf)
{
gettimeofday(&ssd_request_time, NULL);
double time = ((ssd_request_time.tv_sec - ssd_boot_time.tv_sec) * 1000 + (ssd_request_time.tv_usec - ssd_boot_time.tv_usec) / 1000.0) + 0.5;
for (int i=0;i<size;i += PAGE_SIZE)
{
double result = ssdImpl->event_arrive(WRITE, address, 1, time, NULL);
printf("Write time address %llu (%i): %.20lf at %.3f\n", address, size, result, time);
}
}
void SSD_Read(unsigned long long address, int size, void *buf)
{
gettimeofday(&ssd_request_time, NULL);
double time = ((ssd_request_time.tv_sec - ssd_boot_time.tv_sec) * 1000 + (ssd_request_time.tv_usec - ssd_boot_time.tv_usec) / 1000.0) + 0.5;
for (int i=0;i<size;i += PAGE_SIZE)
{
double result = ssdImpl->event_arrive(READ, address, 1, time, NULL);
printf("Read time %llu (%i): %.20lf at %.3f\n", address, size, result, time);
}
}