//------------------------------------------------ // Runs in every thread of every read queue, pops // readreq objects, does the read and reports the // read transaction duration. // static void* run_reads(void* pv_req_queue) { cf_queue* p_req_queue = (cf_queue*)pv_req_queue; readreq* p_readreq; while (g_running) { if (cf_queue_pop(p_req_queue, (void*)&p_readreq, 100) != CF_QUEUE_OK) { continue; } if (g_use_valloc) { uint8_t* p_buffer = cf_valloc(p_readreq->size); if (p_buffer) { read_and_report(p_readreq, p_buffer); free(p_buffer); } else { fprintf(stdout, "ERROR: read buffer cf_valloc()\n"); } } else { uint8_t stack_buffer[p_readreq->size + 4096]; uint8_t* p_buffer = align_4096(stack_buffer); read_and_report(p_readreq, p_buffer); } free(p_readreq); cf_atomic_int_decr(&g_read_reqs_queued); } return (0); }
//------------------------------------------------ // Runs in every transaction thread, pops // trans_req objects, does the transaction and // reports the duration. // static void* run_transactions(void* pv_req_q) { rand_seed_thread(); queue* req_q = (queue*)pv_req_q; trans_req req; while (g_running) { if (queue_pop(req_q, (void*)&req, 100) != QUEUE_OK) { continue; } uint8_t stack_buffer[req.size + 4096]; uint8_t* buf = align_4096(stack_buffer); if (req.is_write) { write_and_report(&req, buf); } else { read_and_report(&req, buf); } atomic32_decr(&g_reqs_queued); } return NULL; }