Changeset 6c7b1e7
- Timestamp:
- Oct 31, 2017, 1:41:33 PM (7 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:
- 0dc954b
- Parents:
- c59bde6
- Location:
- src/tests
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/boundedBuffer.c
rc59bde6 r6c7b1e7 8 8 // Created On : Mon Oct 30 12:45:13 2017 9 9 // Last Modified By : Peter A. Buhr 10 // Last Modified On : Mon Oct 30 18:00:10201711 // Update Count : 710 // Last Modified On : Mon Oct 30 23:02:46 2017 11 // Update Count : 9 12 12 // 13 13 14 14 #include <stdlib> 15 #include <fstream> 15 #include <fstream> // random 16 16 #include <kernel> 17 17 #include <thread> 18 #include <unistd.h> // getpid18 #include <unistd.h> // getpid 19 19 20 20 monitor Buffer { … … 52 52 void main( Producer & prod ) { 53 53 for ( int i = 1; i <= prod.N; i += 1 ) { 54 yield( rand 48( 5 ) );54 yield( random( 5 ) ); 55 55 insert( prod.buffer, 1 ); 56 56 } // for … … 69 69 cons.sum = 0; 70 70 for ( ;; ) { 71 yield( rand 48( 5 ) );71 yield( random( 5 ) ); 72 72 int item = remove( cons.buffer ); 73 73 if ( item == -1 ) break; // sentinel ? … … 90 90 processor p; 91 91 92 //rand 48seed( getpid() );93 rand 48seed( 1003 );92 //random_seed( getpid() ); 93 random_seed( 1003 ); 94 94 95 95 for ( i = 0; i < Cons; i += 1 ) { // create consumers -
src/tests/datingService.c
rc59bde6 r6c7b1e7 9 9 // Created On : Mon Oct 30 12:56:20 2017 10 10 // Last Modified By : Peter A. Buhr 11 // Last Modified On : Mon Oct 30 17:58:41 201712 // Update Count : 1 411 // Last Modified On : Mon Oct 30 23:02:11 2017 12 // Update Count : 15 13 13 // 14 14 15 #include <stdlib> // rand 4815 #include <stdlib> // random 16 16 #include <fstream> 17 17 #include <kernel> … … 61 61 62 62 void main( Girl & g ) { 63 yield( rand 48( 100 ) ); // don't all start at the same time63 yield( random( 100 ) ); // don't all start at the same time 64 64 unsigned int partner = girl( g.TheExchange, g.id, g.ccode ); 65 65 //sout | "Girl:" | g.id | "is dating Boy at" | partner | "with ccode" | g.ccode | endl; … … 79 79 80 80 void main( Boy & b ) { 81 yield( rand 48( 100 ) ); // don't all start at the same time81 yield( random( 100 ) ); // don't all start at the same time 82 82 unsigned int partner = boy( b.TheExchange, b.id, b.ccode ); 83 83 //sout | " Boy:" | b.id | "is dating Girl" | partner | "with ccode" | b.ccode | endl; … … 96 96 Boy *boys[NoOfPairs]; 97 97 98 rand 48seed( getpid() );98 random_seed( getpid() ); 99 99 100 100 for ( unsigned int i = 0; i < NoOfPairs; i += 1 ) { -
src/tests/prodcons.c
rc59bde6 r6c7b1e7 10 10 // Created On : Mon Sep 18 12:23:39 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Oct 30 18:01:19201713 // Update Count : 4 112 // Last Modified On : Mon Oct 30 23:06:05 2017 13 // Update Count : 42 14 14 // 15 15 16 16 #include <fstream> 17 17 #include <coroutine> 18 #include <stdlib> // rand 4818 #include <stdlib> // random 19 19 #include <unistd.h> // getpid 20 20 … … 30 30 // 1st resume starts here 31 31 for ( int i = 0; i < prod.N; i += 1 ) { 32 int p1 = rand 48( 100 );33 int p2 = rand 48( 100 );32 int p1 = random( 100 ); 33 int p2 = random( 100 ); 34 34 sout | p1 | " " | p2 | endl; 35 35 int status = delivery( *prod.c, p1, p2 ); … … 90 90 Prod prod; 91 91 Cons cons = { prod }; 92 rand 48seed( /* getpid() */ 103 ); // fixed seed for testing92 random_seed( /* getpid() */ 103 ); // fixed seed for testing 93 93 start( prod, 5, cons ); 94 94 sout | "main stops" | endl; -
src/tests/random.c
rc59bde6 r6c7b1e7 10 10 // Created On : Tue Jul 5 21:29:30 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 6 18:00:29 201613 // Update Count : 312 // Last Modified On : Mon Oct 30 23:06:49 2017 13 // Update Count : 6 14 14 // 15 15 … … 19 19 20 20 int main() { 21 // rand48seed( getpid() ); // set random seed22 rand 48seed( 1003 );// fixed seed for repeatable tests21 //srandom( getpid() ); // set random seed 22 random_seed( 1003 ); // fixed seed for repeatable tests 23 23 24 24 // test polymorphic calls to random and stream 25 char c = rand 48();25 char c = random(); 26 26 sout | c | endl; 27 int i = rand 48();27 int i = random(); 28 28 sout | i | endl; 29 unsigned int ui = rand 48();29 unsigned int ui = random(); 30 30 sout | ui | endl; 31 long int li = rand 48();31 long int li = random(); 32 32 sout | li | endl; 33 unsigned long int uli = rand 48();33 unsigned long int uli = random(); 34 34 sout | uli | endl; 35 float f = rand 48();35 float f = random(); 36 36 sout | f | endl; 37 double d = rand 48();37 double d = random(); 38 38 sout | d | endl; 39 float _Complex fc = rand 48();39 float _Complex fc = random(); 40 40 sout | fc | endl; 41 double _Complex dc = rand 48();41 double _Complex dc = random(); 42 42 sout | dc | endl; 43 long double _Complex ldc = rand 48();43 long double _Complex ldc = random(); 44 44 sout | ldc | endl; 45 45 } // main -
src/tests/rational.c
rc59bde6 r6c7b1e7 10 10 // Created On : Mon Mar 28 08:43:12 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 23 21:40:11201713 // Update Count : 6 612 // Last Modified On : Tue Oct 10 23:25:04 2017 13 // Update Count : 67 14 14 // 15 15 -
src/tests/sched-ext-barge.c
rc59bde6 r6c7b1e7 42 42 void main( barger_t & this ) { 43 43 yield(); 44 while( barge( global ) ) { yield( ((unsigned)rand48()) % 10); }44 while( barge( global ) ) { yield(random( 10 )); } 45 45 } 46 46 47 47 bool do_call( global_t & mutex this ) { 48 yield( ((unsigned)rand48()) % 10);48 yield(random( 10 )); 49 49 if( this.state != WAITFOR && !this.done && this.started ) { 50 50 serr | "Barging before caller detected" | endl; … … 57 57 thread caller_t {}; 58 58 void main( caller_t & this ) { 59 while( do_call(global) ) { yield( ((unsigned)rand48()) % 10); }59 while( do_call(global) ) { yield(random( 10 )); } 60 60 } 61 61 … … 63 63 this.started = true; 64 64 for( int i = 0; i < N; i++) { 65 yield( ((unsigned)rand48()) % 10);65 yield(random( 10 )); 66 66 this.state = WAITFOR; 67 67 waitfor(do_call, this) { -
src/tests/sched-ext-dtor.c
rc59bde6 r6c7b1e7 45 45 46 46 void main( dummy_t & this ) { 47 yield( ((unsigned)rand48()) % 10);47 yield(random( 10 )); 48 48 set_state( this, MAIN ); 49 49 waitfor( ^?{}, this ) { … … 58 58 for( int i = 0; i < N; i++ ){ 59 59 dummy_t dummy[4]; 60 yield( ((unsigned)rand48()) % 100);60 yield( random( 100 ) ); 61 61 } 62 62 sout | "Stopping" | endl; -
src/tests/sched-ext-recurse.c
rc59bde6 r6c7b1e7 15 15 static const unsigned long N = 5_000ul; 16 16 17 static inline void rand_yield() { yield( ((unsigned)rand48()) % 10); }17 static inline void rand_yield() { yield(random( 10 )); } 18 18 19 19 enum state_t { FIRST, SECOND, THIRD, LAST, STOP }; … … 23 23 for (i = 0; i < 4; i++) 24 24 { 25 int j = ((unsigned)rand48()) % 4;25 int j = random( 4 ); 26 26 enum state_t t = array[j]; 27 27 array[j] = array[i]; … … 131 131 132 132 int main() { 133 rand 48seed( time(NULL) );133 random_seed( time(NULL) ); 134 134 sout | "Starting" | endl; 135 135 { -
src/tests/sched-ext-when.c
rc59bde6 r6c7b1e7 15 15 static const unsigned long N = 4_998ul; 16 16 17 static inline void rand_yield() { yield( ((unsigned)rand48()) % 10); }17 static inline void rand_yield() { yield(random( 10 )); } 18 18 19 19 monitor global_t { … … 77 77 78 78 int main() { 79 rand 48seed( time(NULL) );79 random_seed( time(NULL) ); 80 80 sout | "Starting" | endl; 81 81 { -
src/tests/sched-ext.c
rc59bde6 r6c7b1e7 26 26 volatile bool done; 27 27 28 unsigned rand10() {29 return (unsigned)rand48() % 10;30 }31 32 28 //---------------------------------------------------------------------------------------------------- 33 29 // Acceptor … … 36 32 void do_wait( global_t * mutex a ) { 37 33 sout | "Waiting to accept" | endl; 38 yield( rand 10() );34 yield( random( 10 ) ); 39 35 40 36 sout | "Accepting" | endl; … … 48 44 49 45 sout | "Accepted" | endl; 50 yield( rand 10() );46 yield( random( 10 ) ); 51 47 } 52 48 … … 68 64 void main( Acceptee* this ) { 69 65 while( !done ) { 70 yield( rand 10() );66 yield( random( 10 ) ); 71 67 do_notify( &globalA ); 72 yield( rand 10() );68 yield( random( 10 ) ); 73 69 } 74 70 } … … 78 74 int main(int argc, char* argv[]) { 79 75 done = false; 80 rand 48seed( time( NULL ) );76 random_seed( time( NULL ) ); 81 77 printf("%p\n", &globalA); 82 78 sout | "Starting" | endl; -
src/tests/sched-int-barge.c
rc59bde6 r6c7b1e7 64 64 65 65 if( action == 0 ) { 66 c.do_signal = max( ((unsigned)rand48()) % 10, 1);67 c.do_wait1 = ((unsigned)rand48()) % (c.do_signal);68 c.do_wait2 = ((unsigned)rand48()) % (c.do_signal);66 c.do_signal = max( random( 10 ), 1); 67 c.do_wait1 = random( c.do_signal ); 68 c.do_wait2 = random( c.do_signal ); 69 69 70 70 if(c.do_wait1 == c.do_wait2) sout | "Same" | endl; … … 109 109 110 110 int main(int argc, char* argv[]) { 111 rand 48seed(0);111 random_seed(0); 112 112 processor p; 113 113 { -
src/tests/sched-int-block.c
rc59bde6 r6c7b1e7 49 49 wait( &cond, (uintptr_t)this_thread ); 50 50 51 yield( ((unsigned)rand48()) % 10);51 yield( random( 10 ) ); 52 52 53 53 if(a.last_thread != a.last_signaller || b.last_thread != b.last_signaller ) { … … 58 58 a.last_thread = b.last_thread = this_thread; 59 59 60 yield( ((unsigned)rand48()) % 10);60 yield( random( 10 ) ); 61 61 } 62 62 … … 70 70 //------------------------------------------------------------------------------ 71 71 void signal_op( global_data_t & mutex a, global_data_t & mutex b ) { 72 yield( ((unsigned)rand48()) % 10);72 yield( random( 10 ) ); 73 73 74 74 [a.last_thread, b.last_thread, a.last_signaller, b.last_signaller] = this_thread; … … 83 83 } 84 84 85 yield( ((unsigned)rand48()) % 10);85 yield( random( 10 ) ); 86 86 87 87 if(a.last_thread != next || b.last_thread != next) { … … 118 118 119 119 int main(int argc, char* argv[]) { 120 rand 48seed( time( NULL ) );120 random_seed( time( NULL ) ); 121 121 done = false; 122 122 processor p; -
src/tests/sched-int-disjoint.c
rc59bde6 r6c7b1e7 88 88 signal( &cond, a, data ); 89 89 90 yield( (unsigned)rand48() % 10);90 yield( random( 10 ) ); 91 91 92 92 //This is technically a mutual exclusion violation but the mutex monitor protects us … … 109 109 // Main loop 110 110 int main(int argc, char* argv[]) { 111 rand 48seed( time( NULL ) );111 random_seed( time( NULL ) ); 112 112 all_done = false; 113 113 processor p; -
src/tests/sched-int-wait.c
rc59bde6 r6c7b1e7 62 62 63 63 while( waiter_left != 0 ) { 64 unsigned action = (unsigned)rand48() % 4;64 unsigned action = random( 4 ); 65 65 switch( action ) { 66 66 case 0: … … 127 127 // Main 128 128 int main(int argc, char* argv[]) { 129 rand 48seed( time( NULL ) );129 random_seed( time( NULL ) ); 130 130 waiter_left = 4; 131 131 processor p[2];
Note: See TracChangeset
for help on using the changeset viewer.