Changeset 90c4df0 for src/tests/sched-ext.c
- Timestamp:
- Aug 22, 2017, 1:44:12 PM (6 years ago)
- Branches:
- aaron-thesis, arm-eh, 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:
- 80c72a7
- Parents:
- e50e9ff
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/sched-ext.c
re50e9ff r90c4df0 7 7 #include <time.h> 8 8 9 static const unsigned long N = 2_500ul;9 static const unsigned long N = 500ul; 10 10 11 11 #ifndef PREEMPTION_RATE … … 24 24 thread Acceptee {}; 25 25 26 volatile bool done; 27 28 unsigned rand10() { 29 return (unsigned)rand48() % 10; 30 } 31 26 32 //---------------------------------------------------------------------------------------------------- 27 33 // Acceptor … … 29 35 30 36 void do_wait( global_t * mutex a ) { 31 sout | "Preparing to wait" | endl; 37 sout | "Waiting to accept" | endl; 38 yield( rand10() ); 39 40 sout | "Accepting" | endl; 32 41 33 42 __acceptable_t acceptable; 34 acceptable.func = ( void_fptr_t)do_notify;43 acceptable.func = (fptr_t)do_notify; 35 44 acceptable.count = 1; 36 45 acceptable.monitors = &a; 37 46 acceptable.run_preaccept = false; 38 47 39 sout | "Waiting for notify" | endl;48 __accept_internal( 1, &acceptable ); 40 49 41 int ret = __accept_internal( 1, &acceptable );42 sout | "Back from wating, accepted" | ret | endl;50 sout | "Accepted" | endl; 51 yield( rand10() ); 43 52 } 44 53 45 54 void main( Acceptor* this ) { 46 do_wait( &globalA ); 55 for( int i = 0; i < N; i++ ) { 56 do_wait( &globalA ); 57 sout | i | endl; 58 } 59 60 done = true; 47 61 } 48 62 … … 50 64 // Acceptee 51 65 void do_notify( global_t * mutex a ) { 52 sout | "Notifying" | endl; 66 53 67 } 54 68 55 69 void main( Acceptee* this ) { 56 for( volatile int i = 0; i < N; i++ ); 57 58 sout | "Call Notify" | endl; 59 do_notify( &globalA ); 70 while( !done ) { 71 yield( rand10() ); 72 do_notify( &globalA ); 73 yield( rand10() ); 74 } 60 75 } 61 76 … … 63 78 // Main 64 79 int main(int argc, char* argv[]) { 65 processor p; 80 done = false; 81 rand48seed( time( NULL ) ); 82 printf("%p\n", &globalA); 66 83 sout | "Starting" | endl; 67 84 { 68 85 Acceptor r; 69 Acceptee e; 86 Acceptee e[13]; 87 70 88 } 71 89 sout | "Done" | endl;
Note: See TracChangeset
for help on using the changeset viewer.