diff options
Diffstat (limited to 'bin/rwrnlp.c')
-rw-r--r-- | bin/rwrnlp.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/bin/rwrnlp.c b/bin/rwrnlp.c index 07e3899..a73e2ad 100644 --- a/bin/rwrnlp.c +++ b/bin/rwrnlp.c | |||
@@ -146,7 +146,7 @@ struct thread_context* parse_csv(const char *file, int *num_tasks) | |||
146 | } else { | 146 | } else { |
147 | ctx[cur_task].type = write_req; | 147 | ctx[cur_task].type = write_req; |
148 | } | 148 | } |
149 | if (1 != fscanf(fstream, "%ld",&ctx[cur_task].resources)){ | 149 | if (1 != fscanf(fstream, "%lu",&ctx[cur_task].resources)){ |
150 | fprintf(stderr, "invalid resource mask near line %d\n", cur_task); | 150 | fprintf(stderr, "invalid resource mask near line %d\n", cur_task); |
151 | exit(EXIT_FAILURE); | 151 | exit(EXIT_FAILURE); |
152 | } | 152 | } |
@@ -286,32 +286,35 @@ static int loop_for(double exec_time, double emergency_exit) | |||
286 | static int job(struct thread_context *ctx, double program_end) | 286 | static int job(struct thread_context *ctx, double program_end) |
287 | { | 287 | { |
288 | double ncs_length; | 288 | double ncs_length; |
289 | double cs_length; | 289 | long lock_overhead, unlock_overhead; |
290 | if (wctime() > program_end){ | 290 | if (wctime() > program_end){ |
291 | printf("Terminating...\n"); | 291 | printf("Terminating...\n"); |
292 | return 0; | 292 | return 0; |
293 | } | 293 | } |
294 | else { | 294 | else { |
295 | ncs_length = (ctx->cost-ctx->cs_length)/2*S_PER_MS; | 295 | ncs_length = (ctx->cost-ctx->cs_length)/2*S_PER_MS; |
296 | cs_length = ctx->cs_length * S_PER_MS; | ||
297 | loop_for(ncs_length, program_end + 1); | 296 | loop_for(ncs_length, program_end + 1); |
298 | 297 | ||
299 | if(ctx->type == read_req){ | 298 | if(ctx->type == read_req){ |
300 | //printf("%d:%d read locking...\n", __sync_fetch_and_add(&events,1), gettid()); | 299 | //printf("%d:%d read locking...\n", __sync_fetch_and_add(&events,1), gettid()); |
301 | rwrnlp_read_lock(&rw_lock, ctx->resources, ctx->processor); | 300 | lock_overhead = rwrnlp_read_lock(&rw_lock, ctx->resources, ctx->processor); |
302 | //printf("%d:%d read CS...\n", __sync_fetch_and_add(&events, 1), gettid()); | 301 | //printf("%d:%d read CS...\n", __sync_fetch_and_add(&events, 1), gettid()); |
303 | loop_for(ctx->cs_length*S_PER_MS, program_end + 1); | 302 | loop_for(ctx->cs_length*S_PER_MS, program_end + 1); |
304 | //printf("%d:%d read unlocking...\n", __sync_fetch_and_add(&events,1), gettid()); | 303 | //printf("%d:%d read unlocking...\n", __sync_fetch_and_add(&events,1), gettid()); |
305 | rwrnlp_read_unlock(&rw_lock, ctx->processor); | 304 | unlock_overhead = rwrnlp_read_unlock(&rw_lock, ctx->processor); |
306 | //printf("%d:%d ncs...\n", __sync_fetch_and_add(&events,1), gettid()); | 305 | //printf("%d:%d ncs...\n", __sync_fetch_and_add(&events,1), gettid()); |
306 | printf("read lock overhead: %ld\n", lock_overhead); | ||
307 | printf("read unlock overhead: %ld\n", unlock_overhead); | ||
307 | }else{ | 308 | }else{ |
308 | //printf("%d:%d write locking %lu\n", __sync_fetch_and_add(&events,1), gettid(), ctx->resources); | 309 | //printf("%d:%d write locking %lu\n", __sync_fetch_and_add(&events,1), gettid(), ctx->resources); |
309 | rwrnlp_write_lock(&rw_lock, ctx->resources, ctx->processor); | 310 | lock_overhead = rwrnlp_write_lock(&rw_lock, ctx->resources, ctx->processor); |
310 | //printf("%d:%d write CS...\n", __sync_fetch_and_add(&events,1), gettid()); | 311 | //printf("%d:%d write CS...\n", __sync_fetch_and_add(&events,1), gettid()); |
311 | loop_for(ctx->cs_length*S_PER_MS, program_end + 1); | 312 | loop_for(ctx->cs_length*S_PER_MS, program_end + 1); |
312 | //printf("%d:%d write unlocking...\n", __sync_fetch_and_add(&events,1), gettid()); | 313 | //printf("%d:%d write unlocking...\n", __sync_fetch_and_add(&events,1), gettid()); |
313 | rwrnlp_write_unlock(&rw_lock, ctx->processor); | 314 | unlock_overhead = rwrnlp_write_unlock(&rw_lock, ctx->processor); |
314 | //printf("%d:%d ncs...\n", __sync_fetch_and_add(&events,1), gettid()); | 315 | //printf("%d:%d ncs...\n", __sync_fetch_and_add(&events,1), gettid()); |
316 | printf("write lock overhead: %ld\n", lock_overhead); | ||
317 | printf("write unlock overhead: %ld\n", unlock_overhead); | ||
315 | } | 318 | } |
316 | 319 | ||
317 | 320 | ||