16 #if STXXL_HAVE_SIMDISK_FILE
25 const double simdisk_geometry::s_average_speed = (15 * 1024 * 1024);
27 void simdisk_geometry::add_zone(
int& first_cyl,
int last_cyl,
28 int sec_per_track,
int& first_sect)
31 nsurfaces * sec_per_track * bytes_per_sector /
32 ((nsurfaces - 1) * head_switch_time +
34 nsurfaces * revolution_time);
36 (last_cyl - first_cyl +
37 1) * nsurfaces * sec_per_track;
38 zones.insert(Zone(first_sect, sectors, rate));
39 first_sect += sectors;
40 first_cyl = last_cyl + 1;
44 double simdisk_geometry::get_delay(file::offset_type offset, file::size_type size)
47 int first_sect = offset / bytes_per_sector;
48 int last_sect = (offset + size) / bytes_per_sector;
49 int sectors = size / bytes_per_sector;
51 cmd_ovh + seek_time + rot_latency +
52 double(bytes_per_sector) /
53 double(interface_speed);
55 std::set<Zone, ZoneCmp>::iterator zone = zones.lower_bound(first_sect);
60 last_sect - ((*zone).first_sector +
62 if (from_this_zone <= 0)
64 delay += sectors * bytes_per_sector /
65 ((*zone).sustained_data_rate);
70 delay += from_this_zone *
72 ((*zone).sustained_data_rate);
74 stxxl_nassert(zone == zones.end());
75 sectors -= from_this_zone;
82 return double(size) / s_average_speed;
86 IC35L080AVVA07::IC35L080AVVA07()
88 std::cout <<
"Creating IBM 120GXP IC35L080AVVA07" <<
92 bytes_per_sector = 512;
95 rot_latency = 0.00417;
96 head_switch_time = 0.0015;
97 cyl_switch_time = 0.002;
98 revolution_time = 0.0083;
99 interface_speed = 100000000;
103 add_zone(last_cyl, 1938, 928, first_sect);
104 add_zone(last_cyl, 3756, 921, first_sect);
105 add_zone(last_cyl, 5564, 896, first_sect);
106 add_zone(last_cyl, 7687, 896, first_sect);
107 add_zone(last_cyl, 9526, 888, first_sect);
108 add_zone(last_cyl, 11334, 883, first_sect);
109 add_zone(last_cyl, 13331, 864, first_sect);
110 add_zone(last_cyl, 15128, 850, first_sect);
111 add_zone(last_cyl, 16925, 840, first_sect);
112 add_zone(last_cyl, 18922, 822, first_sect);
113 add_zone(last_cyl, 20709, 806, first_sect);
114 add_zone(last_cyl, 22601, 792, first_sect);
115 add_zone(last_cyl, 24138, 787, first_sect);
116 add_zone(last_cyl, 26024, 768, first_sect);
117 add_zone(last_cyl, 27652, 752, first_sect);
118 add_zone(last_cyl, 29501, 740, first_sect);
119 add_zone(last_cyl, 31234, 725, first_sect);
120 add_zone(last_cyl, 33009, 698, first_sect);
121 add_zone(last_cyl, 34784, 691, first_sect);
122 add_zone(last_cyl, 36609, 672, first_sect);
123 add_zone(last_cyl, 38374, 648, first_sect);
124 add_zone(last_cyl, 40139, 630, first_sect);
125 add_zone(last_cyl, 41904, 614, first_sect);
126 add_zone(last_cyl, 43519, 595, first_sect);
127 add_zone(last_cyl, 45250, 576, first_sect);
128 add_zone(last_cyl, 47004, 552, first_sect);
129 add_zone(last_cyl, 48758, 533, first_sect);
130 add_zone(last_cyl, 50491, 512, first_sect);
131 add_zone(last_cyl, 52256, 493, first_sect);
132 add_zone(last_cyl, 54010, 471, first_sect);
133 add_zone(last_cyl, 55571, 448, first_sect);
136 set<Zone, ZoneCmp>::iterator it = zones.begin();
138 for ( ; it != zones.end(); it++, i++)
142 std::cout <<
"Zone " << i <<
" first sector: " << (*it).first_sector;
143 std::cout <<
" sectors: " << (*it).sectors <<
" sustained rate: ";
144 std::cout << (*it).sustained_data_rate / 1024 / 1024 <<
" MiB/s" << std::endl;
147 std::cout <<
"Last sector : " << first_sect << std::endl;
148 std::cout <<
"Approx. capacity: " << (first_sect / 1024 / 1024) * bytes_per_sector <<
" MiB" << std::endl;
151 std::cout <<
"Transfer 16 MiB from zone 0 : " <<
152 get_delay(0, 16 * 1024 * 1024) <<
" s" << std::endl;
153 std::cout <<
"Transfer 16 MiB from zone 30: " <<
154 get_delay(file::offset_type(158204036) * file::offset_type(bytes_per_sector), 16 * 1024 * 1024) <<
" s" << std::endl;
159 void sim_disk_file::serve(
void* buffer, offset_type offset, size_type
bytes,
160 request::request_type type)
162 scoped_mutex_lock fd_lock(fd_mutex);
166 stats::scoped_read_write_timer read_write_timer(bytes, type == request::WRITE);
168 void* mem = mmap(NULL, bytes, PROT_READ | PROT_WRITE, MAP_SHARED, file_des, offset);
169 if (mem == MAP_FAILED)
174 " Page size: " << sysconf(_SC_PAGESIZE) <<
175 " offset modulo page size " << (offset % sysconf(_SC_PAGESIZE)));
183 if (type == request::READ)
185 memcpy(buffer, mem, bytes);
189 memcpy(mem, buffer, bytes);
195 double delay = get_delay(offset, bytes);
201 int seconds_to_wait =
static_cast<int>(floor(delay));
203 sleep(seconds_to_wait);
205 usleep((useconds_t)((delay - seconds_to_wait) * 1000000.));
208 const char* sim_disk_file::io_type()
const
215 void sim_disk_file::set_size(offset_type newsize)
217 scoped_mutex_lock fd_lock(fd_mutex);
218 if (newsize > _size())
221 "lseek() fd=" << file_des <<
" pos=" << newsize - 1);
223 "write() fd=" << file_des <<
" size=1");
229 #endif // #if STXXL_HAVE_SIMDISK_FILE
#define STXXL_THROW_ERRNO_NE_0(expr, exception_type, error_message)
Throws exception_type if (expr != 0) with "Error in [function] : [error_message] : [errno message]"...
#define STXXL_BEGIN_NAMESPACE
void STXXL_UNUSED(const U &)
#define STXXL_THROW_ERRNO_LT_0(expr, exception_type, error_message)
Throws exception_type if (expr < 0) with "Error in [function] : [error_message] : [errno message]"...
#define STXXL_THROW_ERRNO(exception_type, error_message)
Throws exception_type with "Error in [function] : [error_message] : [errno message]".
static const size_t bytes
number of bytes in uint_pair
double timestamp()
Returns number of seconds since the epoch, high resolution.
#define STXXL_END_NAMESPACE