#include #include #include #include "../bench.h" test_spinlock LOCKS; inline void lock( test_spinlock &a, test_spinlock &b ) { lock(a); lock(b); } inline void lock( test_spinlock &a, test_spinlock &b, test_spinlock &c, test_spinlock &d ) { lock(a); lock(b); lock(c); lock(d); } 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 ) { lock(a); lock(b); lock(c); lock(d); lock(e); lock(f); lock(g); lock(h); } inline void unlock( test_spinlock &a, test_spinlock &b ) { unlock(a); unlock(b); } inline void unlock( test_spinlock &a, test_spinlock &b, test_spinlock &c, test_spinlock &d ) { unlock(a); unlock(b); unlock(c); unlock(d); } 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 ) { unlock(a); unlock(b); unlock(c); unlock(d); unlock(e); unlock(f); unlock(g); unlock(h); } bool done = false; uint64_t total = 0; thread worker {}; static inline void ?{}( worker & this, cluster & clu ) { ((thread &)this){ clu }; } void main( worker & w ) { BENCH( lock( LOCKS ); unlock( LOCKS );, total, done ) } int main( int argc, char * argv[] ) { BENCH_START() cluster clus; processor * proc[threads]; for ( i; threads ) // create procs (*(proc[i] = alloc())){clus}; worker * w[threads]; for ( i; threads ) // create threads (*(w[i] = alloc())){ clus }; sleep( 10`s ); done = true; for ( i; threads ) // delete threads delete(w[i]); for ( i; threads ) // delete procs delete(proc[i]); printf( "%lu\n", total ); } // Local Variables: // // tab-width: 4 // // End: //