Changeset 26fd986 for benchmark/schedint
- Timestamp:
- Jan 21, 2020, 6:14:34 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 5518719
- Parents:
- c12869e
- Location:
- benchmark/schedint
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/schedint/JavaThread.java
rc12869e r26fd986 63 63 synchronized(m) { 64 64 s.start(); 65 while( ! Monitor.go ) {65 while( ! Monitor.go ) { // waiter must start first 66 66 Thread.yield(); 67 67 } -
benchmark/schedint/cfa1.cfa
rc12869e r26fd986 7 7 8 8 volatile int go = 0; 9 9 10 condition c; 10 11 monitor M {} m1; … … 13 14 signal( c ); 14 15 } 15 16 16 void __attribute__((noinline)) wait( M & mutex p1 ) { 17 17 go = 1; … … 19 19 wait( c ); 20 20 } 21 go = 0;22 21 } 23 22 24 23 thread T {}; 25 24 void main( T & ) { 26 while ( go == 0 ) { yield(); } 25 while ( go == 0 ) { yield(); } // waiter must start first 27 26 BENCH( 28 while ( go == 1) { call( m1 ); },27 for ( times ) { call( m1 ); }, 29 28 result 30 29 ) -
benchmark/schedint/cfa2.cfa
rc12869e r26fd986 7 7 8 8 volatile int go = 0; 9 9 10 condition c; 10 11 monitor M {} m1, m2; … … 13 14 signal( c ); 14 15 } 15 16 16 void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2 ) { 17 17 go = 1; … … 19 19 wait( c ); 20 20 } 21 go = 0;22 21 } 23 22 24 23 thread T {}; 25 24 void main( T & ) { 26 while ( go == 0 ) { yield(); } 25 while ( go == 0 ) { yield(); } // waiter must start first 27 26 BENCH( 28 while ( go == 1) { call( m1, m2 ); },27 for ( times ) { call( m1, m2 ); }, 29 28 result 30 29 ) -
benchmark/schedint/cfa4.cfa
rc12869e r26fd986 4 4 #include <stdio.h> 5 5 6 #include " bench.h"6 #include "../bench.h" 7 7 8 8 volatile int go = 0; 9 9 10 condition c; 10 11 monitor M {} m1, m2, m3, m4; … … 13 14 signal( c ); 14 15 } 15 16 16 void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) { 17 17 go = 1; … … 19 19 wait( c ); 20 20 } 21 go = 0;22 21 } 23 22 24 23 thread T {}; 25 24 void main( T & ) { 26 while ( go == 0 ) { yield(); } 25 while ( go == 0 ) { yield(); } // waiter must start first 27 26 BENCH( 28 while ( go == 1) { call( m1, m2, m3, m4 ); },27 for ( times ) { call( m1, m2, m3, m4 ); }, 29 28 result 30 29 ) -
benchmark/schedint/pthreads.c
rc12869e r26fd986 6 6 volatile int go = 0; 7 7 8 pthread_mutex_t m; 8 9 pthread_cond_t c; 9 pthread_mutex_t m;10 10 11 11 void __attribute__((noinline)) call() { 12 pthread_mutex_lock( &m);13 pthread_cond_signal( &c);14 pthread_mutex_unlock( &m);12 pthread_mutex_lock( &m ); 13 pthread_cond_signal( &c ); 14 pthread_mutex_unlock( &m ); 15 15 } 16 16 17 int__attribute__((noinline)) wait() {17 void __attribute__((noinline)) wait() { 18 18 pthread_mutex_lock(&m); 19 19 go = 1; 20 for ( size_t i = 0; i < times; i++ ) { 21 pthread_cond_wait( &c, &m ); 22 } 23 go = 0; 24 pthread_mutex_unlock( &m ); 25 } 26 27 void * thread_main( __attribute__((unused)) void * arg ) { 28 while ( go == 0 ) { sched_yield(); } // waiter must start first 29 // barging for lock acquire => may not execute N times 20 30 BENCH( 21 for (size_t i = 0; i < times; i++) { 22 pthread_cond_wait(&c, &m); 23 }, 31 while ( go == 1 ) { call(); }, 24 32 result 25 33 ) 26 34 printf( "%g\n", result ); 27 go = 0;28 pthread_mutex_unlock(&m);29 return 0;30 }31 32 void* thread_main(__attribute__((unused)) void * arg ) {33 while(go == 0) { sched_yield(); }34 while(go == 1) { call(); }35 35 return NULL; 36 36 } … … 39 39 BENCH_START() 40 40 pthread_t thread; 41 if ( pthread_create(&thread, NULL, thread_main, NULL) < 0) {41 if ( pthread_create( &thread, NULL, thread_main, NULL ) < 0 ) { 42 42 perror( "failure" ); 43 43 return 1; 44 44 } 45 45 wait(); 46 if ( pthread_join( thread, NULL) < 0) {46 if ( pthread_join( thread, NULL ) < 0 ) { 47 47 perror( "failure" ); 48 48 return 1; -
benchmark/schedint/rust.rs
rc12869e r26fd986 18 18 19 19 let th = thread::spawn( move || { 20 while *m2.lock().unwrap() == 0 { 20 while *m2.lock().unwrap() == 0 { // waiter must start first 21 21 thread::yield_now(); 22 22 } -
benchmark/schedint/upp.cc
rc12869e r26fd986 11 11 cond.signal(); 12 12 } 13 void __attribute__((noinline)) wait() { 14 go = 1; 15 for ( size_t i = 0; i < times; i++ ) { 16 cond.wait(); 17 } 18 } 19 } m; 13 20 14 int __attribute__((noinline)) wait() { 15 go = 1; 21 _Task T { 22 void main() { 23 while ( go == 0 ) { yield(); } // waiter must start first 16 24 BENCH( 17 for ( size_t i = 0; i < times; i++) {18 cond.wait();25 for ( size_t i = 0; i < times; i++ ) { 26 m.call(); 19 27 }, 20 28 result 21 29 ) 22 30 printf( "%g\n", result ); 23 go = 0;24 return 0;25 }26 };27 28 M m;29 30 _Task T {31 void main() {32 while(go == 0) { yield(); }33 while(go == 1) { m.call(); }34 35 31 } 36 32 }; … … 39 35 BENCH_START() 40 36 T t; 41 returnm.wait();37 m.wait(); 42 38 } 43 39
Note: See TracChangeset
for help on using the changeset viewer.