Changeset d22e567 in mainline for uspace/app/rcubench/rcubench.c
- Timestamp:
- 2012-12-04T21:11:02Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6a585dd
- Parents:
- f74ec77
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/rcubench/rcubench.c
rf74ec77 rd22e567 67 67 68 68 69 /* Combats compiler optimizations. */70 static volatile size_t dummy = 0;71 72 static size_t sum_array(size_t *array, size_t len)73 {74 size_t sum = 0;75 76 for (size_t k = 0; k < len; ++k)77 sum += array[k];78 79 return sum;80 }81 69 82 70 83 71 static void kernel_futex_bench(bench_t *bench) 84 72 { 85 futex_t * const fut = &bench->bench_fut;86 73 const size_t iters = bench->iters; 87 size_t sum = 0;88 74 89 75 for (size_t i = 0; i < iters; ++i) { 90 /* Do some work with the futex locked to encourage contention. */ 91 futex_down(fut); 92 sum += sum_array(bench->array, bench->array_size); 93 futex_up(fut); 94 95 /* 96 * Do half as much work to give other threads a chance to acquire 97 * the futex. 98 */ 99 sum += sum_array(bench->array, bench->array_size / 2); 100 } 101 102 /* 103 * Writing to a global volatile variable separated with a cc-barrier 104 * should discourage the compiler from optimizing away sum_array()s. 105 */ 106 compiler_barrier(); 107 dummy = sum; 76 int val = 0; 77 __SYSCALL1(SYS_FUTEX_WAKEUP, (sysarg_t) &val); 78 __SYSCALL1(SYS_FUTEX_SLEEP, (sysarg_t) &val); 79 } 108 80 } 109 81 … … 179 151 } 180 152 181 static const char *results_txt = "/tmp/ rcu-bench-results.txt";153 static const char *results_txt = "/tmp/urcu-bench-results.txt"; 182 154 183 155 static bool open_results(void) … … 211 183 printf("rcubench [test-name] [k-iterations] [n-threads] {work-size}\n"); 212 184 printf("Available tests: \n"); 213 printf(" ke-futex .. threads down/up a shared futex and do some work when\n");214 printf(" in critical section; do a little less work outside CS.\n");185 printf(" sys-futex.. threads make wakeup/sleepdown futex syscalls in a loop\n"); 186 printf(" but for separate variables/futex kernel objects.\n"); 215 187 printf(" lock .. threads lock/unlock separate futexes.\n"); 216 188 printf(" sema .. threads down/up separate futexes.\n"); … … 232 204 futex_initialize(&bench->bench_fut, 1); 233 205 234 if (0 == str_cmp(argv[1], " ke-futex")) {206 if (0 == str_cmp(argv[1], "sys-futex")) { 235 207 bench->func = kernel_futex_bench; 236 208 } else if (0 == str_cmp(argv[1], "lock")) {
Note:
See TracChangeset
for help on using the changeset viewer.