1 | #include <locks.hfa> |
---|
2 | #include <mutex_stmt.hfa> |
---|
3 | #include <stdio.h> |
---|
4 | |
---|
5 | #include "../bench.h" |
---|
6 | |
---|
7 | test_spinlock LOCKS; |
---|
8 | |
---|
9 | inline void lock( test_spinlock &a, test_spinlock &b ) { |
---|
10 | lock(a); lock(b); |
---|
11 | } |
---|
12 | inline void lock( test_spinlock &a, test_spinlock &b, test_spinlock &c, test_spinlock &d ) { |
---|
13 | lock(a); lock(b); lock(c); lock(d); |
---|
14 | } |
---|
15 | inline void lock( test_spinlock &a, test_spinlock &b, test_spinlock &c, test_spinlock &d, test_spinlock &e, test_spinlock &f, test_spinlock &g, test_spinlock &h ) { |
---|
16 | lock(a); lock(b); lock(c); lock(d); lock(e); lock(f); lock(g); lock(h); |
---|
17 | } |
---|
18 | inline void unlock( test_spinlock &a, test_spinlock &b ) { |
---|
19 | unlock(a); unlock(b); |
---|
20 | } |
---|
21 | inline void unlock( test_spinlock &a, test_spinlock &b, test_spinlock &c, test_spinlock &d ) { |
---|
22 | unlock(a); unlock(b); unlock(c); unlock(d); |
---|
23 | } |
---|
24 | inline void unlock( test_spinlock &a, test_spinlock &b, test_spinlock &c, test_spinlock &d, test_spinlock &e, test_spinlock &f, test_spinlock &g, test_spinlock &h ) { |
---|
25 | unlock(a); unlock(b); unlock(c); unlock(d); unlock(e); unlock(f); unlock(g); unlock(h); |
---|
26 | } |
---|
27 | |
---|
28 | bool done = false; |
---|
29 | uint64_t total = 0; |
---|
30 | thread worker {}; |
---|
31 | void main( worker & w ) { |
---|
32 | BENCH( lock( LOCKS ); unlock( LOCKS );, total, done ) |
---|
33 | } |
---|
34 | |
---|
35 | int main( int argc, char * argv[] ) { |
---|
36 | BENCH_START() |
---|
37 | processor p[threads]; // one extra for main thread |
---|
38 | { |
---|
39 | worker w[threads]; |
---|
40 | sleep( 10`s ); |
---|
41 | done = true; |
---|
42 | } |
---|
43 | printf( "%lu\n", total ); |
---|
44 | } |
---|
45 | |
---|
46 | // Local Variables: // |
---|
47 | // tab-width: 4 // |
---|
48 | // End: // |
---|