MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / read_one_req

Function read_one_req

libCacheSim/traceReader/reader.c:236–340  ·  view source on GitHub ↗

* @brief read one request from trace file * * @param reader * @param req * @return 0 if success, 1 if end of file */

Source from the content-addressed store, hash-verified

234 * @return 0 if success, 1 if end of file
235 */
236int read_one_req(reader_t *const reader, request_t *const req) {
237 if (reader->mmap_offset >= reader->file_size) {
238 DEBUG("read_one_req: end of file, current mmap_offset %zu, file size %zu\n",
239 reader->mmap_offset, reader->file_size);
240 req->valid = false;
241 return 1;
242 }
243
244 if (reader->cap_at_n_req > 1 && reader->n_read_req >= reader->cap_at_n_req) {
245 DEBUG("read_one_req: processed %ld requests capped by the user\n",
246 (long)reader->n_read_req);
247 req->valid = false;
248 return 1;
249 }
250
251 int status = 0;
252 size_t offset_before_read = reader->mmap_offset;
253 if (reader->n_req_left > 0) {
254 reader->n_req_left -= 1;
255 req->clock_time = reader->last_req_clock_time;
256
257 } else {
258 reader->n_read_req += 1;
259 req->hv = 0;
260 req->ttl = 0;
261 req->valid = true;
262
263 switch (reader->trace_type) {
264 case CSV_TRACE:
265 offset_before_read = ftell(reader->file);
266 status = csv_read_one_req(reader, req);
267 break;
268 case PLAIN_TXT_TRACE:;
269 offset_before_read = ftell(reader->file);
270 status = txt_read_one_req(reader, req);
271 break;
272 case BIN_TRACE:
273 status = binary_read_one_req(reader, req);
274 break;
275 case VSCSI_TRACE:
276 status = vscsi_read_one_req(reader, req);
277 break;
278 case TWR_TRACE:
279 status = twr_read_one_req(reader, req);
280 break;
281 case TWRNS_TRACE:
282 status = twrNS_read_one_req(reader, req);
283 break;
284 case ORACLE_GENERAL_TRACE:
285 status = oracleGeneralBin_read_one_req(reader, req);
286 break;
287 case ORACLE_SIM_TWR_TRACE:
288 status = oracleSimTwrBin_read_one_req(reader, req);
289 break;
290 case ORACLE_SYS_TWRNS_TRACE:
291 status = oracleSysTwrNSBin_read_one_req(reader, req);
292 break;
293 case ORACLE_SIM_TWRNS_TRACE:

Callers 15

mainFunction · 0.85
gen_miss_traceMethod · 0.85
mainFunction · 0.85
test_reader_basicFunction · 0.85
test_reader_more1Function · 0.85
test_twrFunction · 0.85
runSimulationFunction · 0.85
runSimFunction · 0.85
runMethod · 0.85
_get_lru_hit_cntFunction · 0.85
get_stack_distFunction · 0.85
get_access_distFunction · 0.85

Calls 14

csv_read_one_reqFunction · 0.85
txt_read_one_reqFunction · 0.85
binary_read_one_reqFunction · 0.85
vscsi_read_one_reqFunction · 0.85
twr_read_one_reqFunction · 0.85
twrNS_read_one_reqFunction · 0.85
lcs_read_one_reqFunction · 0.85
valpin_read_one_reqFunction · 0.85

Tested by 4

mainFunction · 0.68
test_reader_basicFunction · 0.68
test_reader_more1Function · 0.68
test_twrFunction · 0.68