- Timestamp:
- May 5, 2017, 10:56:12 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- bd951f7
- Parents:
- 8cb6fcd
- Location:
- src/benchmark
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/benchmark/Monitor.c
r8cb6fcd re0b8ccd5 9 9 mon_t mon1, mon2; 10 10 11 void dummy( mon_t * mutex a ) {} 11 12 void dummy( mon_t * mutex a, mon_t * mutex b ) {} 12 13 14 13 15 14 int main() { 16 15 long long int StartTime, EndTime; 16 17 StartTime = Time(); 18 for( int i = 0; i < N; i++ ) { 19 dummy( &mon1 ); 20 } 21 EndTime = Time(); 22 23 sout | ( EndTime - StartTime ) / N; 17 24 18 25 StartTime = Time(); -
src/benchmark/SchedInt.c
r8cb6fcd re0b8ccd5 7 7 condition condA; 8 8 condition condB; 9 condition condC; 10 condition condD; 9 11 10 12 monitor mon_t {}; … … 14 16 thread thrdA {}; 15 17 thread thrdB {}; 18 thread thrdC {}; 19 thread thrdD {}; 16 20 17 void sideA( mon_t * mutex a, mon_t * mutex b ) { 21 //------------------------------------------------------------------- 22 // 1 monitor signal cycle 23 void sideA( mon_t * mutex a ) { 18 24 long long int StartTime, EndTime; 19 25 … … 26 32 EndTime = Time(); 27 33 28 sout | ( EndTime - StartTime ) / N | endl;34 sout | ( EndTime - StartTime ) / N; 29 35 } 30 36 31 void sideB( mon_t * mutex a , mon_t * mutex b) {37 void sideB( mon_t * mutex a ) { 32 38 for( int i = 0;; i++ ) { 33 39 signal(&condB); … … 37 43 } 38 44 39 void main( thrdA * this ) { sideA( &mon1, &mon2 ); } 40 void main( thrdB * this ) { sideB( &mon1, &mon2 ); } 45 //------------------------------------------------------------------- 46 // 2 monitor signal cycle 47 void sideC( mon_t * mutex a, mon_t * mutex b ) { 48 long long int StartTime, EndTime; 49 50 StartTime = Time(); 51 for( int i = 0;; i++ ) { 52 signal(&condC); 53 if( i > N ) break; 54 wait(&condD); 55 } 56 EndTime = Time(); 57 58 sout | ( EndTime - StartTime ) / N | endl; 59 } 60 61 void sideD( mon_t * mutex a, mon_t * mutex b ) { 62 for( int i = 0;; i++ ) { 63 signal(&condD); 64 if( i > N ) break; 65 wait(&condC); 66 } 67 } 68 69 void main( thrdA * this ) { sideA( &mon1 ); } 70 void main( thrdB * this ) { sideB( &mon1 ); } 71 void main( thrdC * this ) { sideC( &mon1, &mon2 ); } 72 void main( thrdD * this ) { sideD( &mon1, &mon2 ); } 41 73 42 74 int main() { 43 thrdA a; 44 thrdB b; 75 { 76 thrdA a; 77 thrdB b; 78 } 79 { 80 thrdC c; 81 thrdD d; 82 } 45 83 }
Note: See TracChangeset
for help on using the changeset viewer.