Changeset 4cedd9f
- Timestamp:
- Nov 2, 2017, 2:15:19 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:
- 8fc45b7
- Parents:
- e1e8408
- Location:
- src
- Files:
-
- 1 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
src/benchmark/Makefile.am
re1e8408 r4cedd9f 27 27 28 28 noinst_PROGRAMS = 29 30 all : ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT) 29 31 30 32 bench$(EXEEXT) : … … 63 65 ctxswitch-pthread$(EXEEXT): 64 66 @BACKEND_CC@ ctxswitch/pthreads.c -DBENCH_N=50000000 -I. -lrt -pthread ${AM_CFLAGS} ${CFLAGS} ${ccflags} 65 66 ## =========================================================================================================67 creation$(EXEEXT) :\68 creation-pthread.run \69 creation-cfa_coroutine.run \70 creation-cfa_thread.run \71 creation-upp_coroutine.run \72 creation-upp_thread.run73 74 creation-cfa_coroutine$(EXEEXT):75 ${CC} creation/cfa_cor.c -DBENCH_N=10000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}76 77 creation-cfa_thread$(EXEEXT):78 ${CC} creation/cfa_thrd.c -DBENCH_N=10000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}79 80 creation-upp_coroutine$(EXEEXT):81 u++ creation/upp_cor.cc -DBENCH_N=50000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags}82 83 creation-upp_thread$(EXEEXT):84 u++ creation/upp_thrd.cc -DBENCH_N=50000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags}85 86 creation-pthread$(EXEEXT):87 @BACKEND_CC@ creation/pthreads.c -DBENCH_N=250000 -I. -lrt -pthread ${AM_CFLAGS} ${CFLAGS} ${ccflags}88 67 89 68 ## ========================================================================================================= … … 153 132 154 133 ## ========================================================================================================= 134 creation$(EXEEXT) :\ 135 creation-pthread.run \ 136 creation-cfa_coroutine.run \ 137 creation-cfa_thread.run \ 138 creation-upp_coroutine.run \ 139 creation-upp_thread.run 140 141 creation-cfa_coroutine$(EXEEXT): 142 ${CC} creation/cfa_cor.c -DBENCH_N=10000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 143 144 creation-cfa_thread$(EXEEXT): 145 ${CC} creation/cfa_thrd.c -DBENCH_N=10000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 146 147 creation-upp_coroutine$(EXEEXT): 148 u++ creation/upp_cor.cc -DBENCH_N=50000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 149 150 creation-upp_thread$(EXEEXT): 151 u++ creation/upp_thrd.cc -DBENCH_N=50000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 152 153 creation-pthread$(EXEEXT): 154 @BACKEND_CC@ creation/pthreads.c -DBENCH_N=250000 -I. -lrt -pthread ${AM_CFLAGS} ${CFLAGS} ${ccflags} 155 156 ## ========================================================================================================= 155 157 156 158 %.run : %$(EXEEXT) ${REPEAT} -
src/benchmark/Makefile.in
re1e8408 r4cedd9f 444 444 .NOTPARALLEL: 445 445 446 all : ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT) 447 446 448 bench$(EXEEXT) : 447 449 @for ccflags in "-debug" "-nodebug"; do \ … … 479 481 @BACKEND_CC@ ctxswitch/pthreads.c -DBENCH_N=50000000 -I. -lrt -pthread ${AM_CFLAGS} ${CFLAGS} ${ccflags} 480 482 481 creation$(EXEEXT) :\482 creation-pthread.run \483 creation-cfa_coroutine.run \484 creation-cfa_thread.run \485 creation-upp_coroutine.run \486 creation-upp_thread.run487 488 creation-cfa_coroutine$(EXEEXT):489 ${CC} creation/cfa_cor.c -DBENCH_N=10000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}490 491 creation-cfa_thread$(EXEEXT):492 ${CC} creation/cfa_thrd.c -DBENCH_N=10000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}493 494 creation-upp_coroutine$(EXEEXT):495 u++ creation/upp_cor.cc -DBENCH_N=50000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags}496 497 creation-upp_thread$(EXEEXT):498 u++ creation/upp_thrd.cc -DBENCH_N=50000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags}499 500 creation-pthread$(EXEEXT):501 @BACKEND_CC@ creation/pthreads.c -DBENCH_N=250000 -I. -lrt -pthread ${AM_CFLAGS} ${CFLAGS} ${ccflags}502 503 483 mutex$(EXEEXT) :\ 504 484 mutex-function.run \ … … 562 542 waitfor-cfa4$(EXEEXT): 563 543 ${CC} schedext/cfa4.c -DBENCH_N=500000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 544 545 creation$(EXEEXT) :\ 546 creation-pthread.run \ 547 creation-cfa_coroutine.run \ 548 creation-cfa_thread.run \ 549 creation-upp_coroutine.run \ 550 creation-upp_thread.run 551 552 creation-cfa_coroutine$(EXEEXT): 553 ${CC} creation/cfa_cor.c -DBENCH_N=10000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 554 555 creation-cfa_thread$(EXEEXT): 556 ${CC} creation/cfa_thrd.c -DBENCH_N=10000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 557 558 creation-upp_coroutine$(EXEEXT): 559 u++ creation/upp_cor.cc -DBENCH_N=50000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 560 561 creation-upp_thread$(EXEEXT): 562 u++ creation/upp_thrd.cc -DBENCH_N=50000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 563 564 creation-pthread$(EXEEXT): 565 @BACKEND_CC@ creation/pthreads.c -DBENCH_N=250000 -I. -lrt -pthread ${AM_CFLAGS} ${CFLAGS} ${ccflags} 564 566 565 567 %.run : %$(EXEEXT) ${REPEAT} -
src/benchmark/csv-data.c
re1e8408 r4cedd9f 111 111 StartTime = Time(); 112 112 for( int i = 0;; i++ ) { 113 signal( &cond1a);114 if( i > N ) break; 115 wait( &cond1b);113 signal(cond1a); 114 if( i > N ) break; 115 wait(cond1b); 116 116 } 117 117 EndTime = Time(); … … 122 122 void side1B( mon_t & mutex a ) { 123 123 for( int i = 0;; i++ ) { 124 signal( &cond1b);125 if( i > N ) break; 126 wait( &cond1a);124 signal(cond1b); 125 if( i > N ) break; 126 wait(cond1a); 127 127 } 128 128 } … … 159 159 StartTime = Time(); 160 160 for( int i = 0;; i++ ) { 161 signal( &cond2a);162 if( i > N ) break; 163 wait( &cond2b);161 signal(cond2a); 162 if( i > N ) break; 163 wait(cond2b); 164 164 } 165 165 EndTime = Time(); … … 170 170 void side2B( mon_t & mutex a, mon_t & mutex b ) { 171 171 for( int i = 0;; i++ ) { 172 signal( &cond2b);173 if( i > N ) break; 174 wait( &cond2a);172 signal(cond2b); 173 if( i > N ) break; 174 wait(cond2a); 175 175 } 176 176 } -
src/benchmark/schedint/cfa1.c
re1e8408 r4cedd9f 15 15 16 16 void __attribute__((noinline)) call( M & mutex a1 ) { 17 signal( &c);17 signal(c); 18 18 } 19 19 … … 22 22 BENCH( 23 23 for (size_t i = 0; i < n; i++) { 24 wait( &c);24 wait(c); 25 25 }, 26 26 result -
src/benchmark/schedint/cfa2.c
re1e8408 r4cedd9f 15 15 16 16 void __attribute__((noinline)) call( M & mutex a1, M & mutex a2 ) { 17 signal( &c);17 signal(c); 18 18 } 19 19 … … 22 22 BENCH( 23 23 for (size_t i = 0; i < n; i++) { 24 wait( &c);24 wait(c); 25 25 }, 26 26 result -
src/benchmark/schedint/cfa4.c
re1e8408 r4cedd9f 15 15 16 16 void __attribute__((noinline)) call( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) { 17 signal( &c);17 signal(c); 18 18 } 19 19 … … 22 22 BENCH( 23 23 for (size_t i = 0; i < n; i++) { 24 wait( &c);24 wait(c); 25 25 }, 26 26 result -
src/libcfa/concurrency/kernel
re1e8408 r4cedd9f 39 39 void ?{}(semaphore & this, int count = 1); 40 40 void ^?{}(semaphore & this); 41 void P(semaphore *this);42 void V(semaphore *this);41 void P (semaphore & this); 42 void V (semaphore & this); 43 43 44 44 … … 51 51 }; 52 52 53 void ?{} (cluster & this);53 void ?{} (cluster & this); 54 54 void ^?{}(cluster & this); 55 55 -
src/libcfa/concurrency/kernel.c
re1e8408 r4cedd9f 158 158 LIB_DEBUG_PRINT_SAFE("Kernel : core %p signaling termination\n", &this); 159 159 this.do_terminate = true; 160 P( &this.terminated );160 P( this.terminated ); 161 161 pthread_join( this.kernel_thread, NULL ); 162 162 } … … 216 216 } 217 217 218 V( &this->terminated );218 V( this->terminated ); 219 219 220 220 LIB_DEBUG_PRINT_SAFE("Kernel : core %p terminated\n", this); … … 618 618 void ^?{}(semaphore & this) {} 619 619 620 void P(semaphore *this) {621 lock( &this ->lock DEBUG_CTX2 );622 this ->count -= 1;623 if ( this ->count < 0 ) {620 void P(semaphore & this) { 621 lock( &this.lock DEBUG_CTX2 ); 622 this.count -= 1; 623 if ( this.count < 0 ) { 624 624 // queue current task 625 append( &this ->waiting, (thread_desc *)this_thread );625 append( &this.waiting, (thread_desc *)this_thread ); 626 626 627 627 // atomically release spin lock and block 628 BlockInternal( &this ->lock );628 BlockInternal( &this.lock ); 629 629 } 630 630 else { 631 unlock( &this ->lock );632 } 633 } 634 635 void V(semaphore *this) {631 unlock( &this.lock ); 632 } 633 } 634 635 void V(semaphore & this) { 636 636 thread_desc * thrd = NULL; 637 lock( &this ->lock DEBUG_CTX2 );638 this ->count += 1;639 if ( this ->count <= 0 ) {637 lock( &this.lock DEBUG_CTX2 ); 638 this.count += 1; 639 if ( this.count <= 0 ) { 640 640 // remove task at head of waiting list 641 thrd = pop_head( &this ->waiting );642 } 643 644 unlock( &this ->lock );641 thrd = pop_head( &this.waiting ); 642 } 643 644 unlock( &this.lock ); 645 645 646 646 // make new owner -
src/libcfa/concurrency/monitor
re1e8408 r4cedd9f 116 116 } 117 117 118 void wait( condition *this, uintptr_t user_info = 0 );119 bool signal( condition *this );120 bool signal_block( condition *this );121 static inline bool is_empty( condition * this ) { return !this->blocked.head; }122 uintptr_t front( condition *this );118 void wait( condition & this, uintptr_t user_info = 0 ); 119 bool signal( condition & this ); 120 bool signal_block( condition & this ); 121 static inline bool is_empty( condition & this ) { return !this.blocked.head; } 122 uintptr_t front( condition & this ); 123 123 124 124 //----------------------------------------------------------------------------- -
src/libcfa/concurrency/monitor.c
re1e8408 r4cedd9f 45 45 46 46 static inline thread_desc * check_condition ( __condition_criterion_t * ); 47 static inline void brand_condition ( condition *);47 static inline void brand_condition ( condition & ); 48 48 static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t &, monitor_desc ** monitors, int count ); 49 49 … … 69 69 unsigned short count = cnt; /* Save the count to a local variable */ \ 70 70 unsigned int recursions[ count ]; /* Save the current recursion levels to restore them later */ \ 71 __waitfor_mask_t masks [ count ];/* Save the current waitfor masks to restore them later */ \71 __waitfor_mask_t masks [ count ]; /* Save the current waitfor masks to restore them later */ \ 72 72 spinlock * locks [ count ]; /* We need to pass-in an array of locks to BlockInternal */ \ 73 73 … … 387 387 //----------------------------------------------------------------------------- 388 388 // Internal scheduling 389 void wait( condition *this, uintptr_t user_info = 0 ) {389 void wait( condition & this, uintptr_t user_info = 0 ) { 390 390 brand_condition( this ); 391 391 392 392 // Check that everything is as expected 393 assertf( this ->monitors != NULL, "Waiting with no monitors (%p)", this->monitors );394 verifyf( this ->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count );395 verifyf( this ->monitor_count < 32u, "Excessive monitor count (%i)", this->monitor_count );393 assertf( this.monitors != NULL, "Waiting with no monitors (%p)", this.monitors ); 394 verifyf( this.monitor_count != 0, "Waiting with 0 monitors (%i)", this.monitor_count ); 395 verifyf( this.monitor_count < 32u, "Excessive monitor count (%i)", this.monitor_count ); 396 396 397 397 // Create storage for monitor context 398 monitor_ctx( this ->monitors, this->monitor_count );398 monitor_ctx( this.monitors, this.monitor_count ); 399 399 400 400 // Create the node specific to this wait operation … … 403 403 // Append the current wait operation to the ones already queued on the condition 404 404 // We don't need locks for that since conditions must always be waited on inside monitor mutual exclusion 405 append( &this ->blocked, &waiter );405 append( &this.blocked, &waiter ); 406 406 407 407 // Lock all monitors (aggregates the locks as well) … … 429 429 } 430 430 431 bool signal( condition *this ) {431 bool signal( condition & this ) { 432 432 if( is_empty( this ) ) { return false; } 433 433 434 434 //Check that everything is as expected 435 verify( this ->monitors );436 verify( this ->monitor_count != 0 );435 verify( this.monitors ); 436 verify( this.monitor_count != 0 ); 437 437 438 438 //Some more checking in debug 439 439 LIB_DEBUG_DO( 440 440 thread_desc * this_thrd = this_thread; 441 if ( this ->monitor_count != this_thrd->monitors.size ) {442 abortf( "Signal on condition %p made with different number of monitor(s), expected %i got %i", this, this->monitor_count, this_thrd->monitors.size );443 } 444 445 for(int i = 0; i < this ->monitor_count; i++) {446 if ( this ->monitors[i] != this_thrd->monitors.list[i] ) {447 abortf( "Signal on condition %p made with different monitor, expected %p got %i", this, this->monitors[i], this_thrd->monitors.list[i] );441 if ( this.monitor_count != this_thrd->monitors.size ) { 442 abortf( "Signal on condition %p made with different number of monitor(s), expected %i got %i", &this, this.monitor_count, this_thrd->monitors.size ); 443 } 444 445 for(int i = 0; i < this.monitor_count; i++) { 446 if ( this.monitors[i] != this_thrd->monitors.list[i] ) { 447 abortf( "Signal on condition %p made with different monitor, expected %p got %i", &this, this.monitors[i], this_thrd->monitors.list[i] ); 448 448 } 449 449 } 450 450 ); 451 451 452 unsigned short count = this ->monitor_count;452 unsigned short count = this.monitor_count; 453 453 454 454 // Lock all monitors 455 lock_all( this ->monitors, NULL, count );455 lock_all( this.monitors, NULL, count ); 456 456 457 457 //Pop the head of the waiting queue 458 __condition_node_t * node = pop_head( &this ->blocked );458 __condition_node_t * node = pop_head( &this.blocked ); 459 459 460 460 //Add the thread to the proper AS stack … … 466 466 467 467 //Release 468 unlock_all( this ->monitors, count );468 unlock_all( this.monitors, count ); 469 469 470 470 return true; 471 471 } 472 472 473 bool signal_block( condition *this ) {474 if( !this ->blocked.head ) { return false; }473 bool signal_block( condition & this ) { 474 if( !this.blocked.head ) { return false; } 475 475 476 476 //Check that everything is as expected 477 verifyf( this ->monitors != NULL, "Waiting with no monitors (%p)", this->monitors );478 verifyf( this ->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count );477 verifyf( this.monitors != NULL, "Waiting with no monitors (%p)", this.monitors ); 478 verifyf( this.monitor_count != 0, "Waiting with 0 monitors (%i)", this.monitor_count ); 479 479 480 480 // Create storage for monitor context 481 monitor_ctx( this ->monitors, this->monitor_count );481 monitor_ctx( this.monitors, this.monitor_count ); 482 482 483 483 // Lock all monitors (aggregates the locks them as well) … … 491 491 492 492 //Find the thread to run 493 thread_desc * signallee = pop_head( &this ->blocked )->waiting_thread;493 thread_desc * signallee = pop_head( &this.blocked )->waiting_thread; 494 494 set_owner( monitors, count, signallee ); 495 495 496 LIB_DEBUG_PRINT_BUFFER_DECL( "Kernel : signal_block condition %p (s: %p)\n", this, signallee );496 LIB_DEBUG_PRINT_BUFFER_DECL( "Kernel : signal_block condition %p (s: %p)\n", &this, signallee ); 497 497 498 498 //Everything is ready to go to sleep … … 512 512 513 513 // Access the user_info of the thread waiting at the front of the queue 514 uintptr_t front( condition *this ) {514 uintptr_t front( condition & this ) { 515 515 verifyf( !is_empty(this), 516 516 "Attempt to access user data on an empty condition.\n" 517 517 "Possible cause is not checking if the condition is empty before reading stored data." 518 518 ); 519 return this ->blocked.head->user_info;519 return this.blocked.head->user_info; 520 520 } 521 521 … … 811 811 } 812 812 813 static inline void brand_condition( condition *this ) {813 static inline void brand_condition( condition & this ) { 814 814 thread_desc * thrd = this_thread; 815 if( !this ->monitors ) {815 if( !this.monitors ) { 816 816 // LIB_DEBUG_PRINT_SAFE("Branding\n"); 817 817 assertf( thrd->monitors.list != NULL, "No current monitor to brand condition %p", thrd->monitors.list ); 818 this ->monitor_count = thrd->monitors.size;819 820 this ->monitors = malloc( this->monitor_count * sizeof( *this->monitors ) );821 for( int i = 0; i < this ->monitor_count; i++ ) {822 this ->monitors[i] = thrd->monitors.list[i];818 this.monitor_count = thrd->monitors.size; 819 820 this.monitors = malloc( this.monitor_count * sizeof( *this.monitors ) ); 821 for( int i = 0; i < this.monitor_count; i++ ) { 822 this.monitors[i] = thrd->monitors.list[i]; 823 823 } 824 824 } -
src/tests/boundedBuffer.c
re1e8408 r4cedd9f 1 // 1 // 2 2 // The contents of this file are covered under the licence agreement in the 3 3 // file "LICENCE" distributed with Cforall. 4 // 5 // boundedBuffer.c -- 6 // 4 // 5 // boundedBuffer.c -- 6 // 7 7 // Author : Peter A. Buhr 8 8 // Created On : Mon Oct 30 12:45:13 2017 … … 10 10 // Last Modified On : Mon Oct 30 18:00:10 2017 11 11 // Update Count : 7 12 // 12 // 13 13 14 14 #include <stdlib> … … 31 31 32 32 void insert( Buffer & mutex buffer, int elem ) { 33 if ( buffer.count == 20 ) wait( &buffer.empty );33 if ( buffer.count == 20 ) wait( buffer.empty ); 34 34 buffer.elements[buffer.back] = elem; 35 35 buffer.back = ( buffer.back + 1 ) % 20; 36 36 buffer.count += 1; 37 signal( &buffer.full );37 signal( buffer.full ); 38 38 } 39 39 int remove( Buffer & mutex buffer ) { 40 if ( buffer.count == 0 ) wait( &buffer.full );40 if ( buffer.count == 0 ) wait( buffer.full ); 41 41 int elem = buffer.elements[buffer.front]; 42 42 buffer.front = ( buffer.front + 1 ) % 20; 43 43 buffer.count -= 1; 44 signal( &buffer.empty );44 signal( buffer.empty ); 45 45 return elem; 46 46 } -
src/tests/datingService.c
re1e8408 r4cedd9f 1 // -*- Mode: C -*- 2 // 1 // -*- Mode: C -*- 2 // 3 3 // The contents of this file are covered under the licence agreement in the 4 4 // file "LICENCE" distributed with Cforall. 5 // 6 // datingService.c -- 7 // 5 // 6 // datingService.c -- 7 // 8 8 // Author : Peter A. Buhr 9 9 // Created On : Mon Oct 30 12:56:20 2017 … … 11 11 // Last Modified On : Mon Oct 30 17:58:41 2017 12 12 // Update Count : 14 13 // 13 // 14 14 15 15 #include <stdlib> // rand48 … … 18 18 #include <thread> 19 19 #include <unistd.h> // getpid 20 21 bool empty( condition & c ) {22 return c.blocked.head == NULL;23 }24 20 25 21 enum { NoOfPairs = 20 }; … … 31 27 32 28 unsigned int girl( DatingService & mutex ds, unsigned int PhoneNo, unsigned int ccode ) { 33 if ( empty( ds.Boys[ccode] ) ) {34 wait( &ds.Girls[ccode] );29 if ( is_empty( ds.Boys[ccode] ) ) { 30 wait( ds.Girls[ccode] ); 35 31 ds.GirlPhoneNo = PhoneNo; 36 32 } else { 37 33 ds.GirlPhoneNo = PhoneNo; 38 signal_block( &ds.Boys[ccode] );34 signal_block( ds.Boys[ccode] ); 39 35 } // if 40 36 return ds.BoyPhoneNo; … … 42 38 43 39 unsigned int boy( DatingService & mutex ds, unsigned int PhoneNo, unsigned int ccode ) { 44 if ( empty( ds.Girls[ccode] ) ) {45 wait( &ds.Boys[ccode] );40 if ( is_empty( ds.Girls[ccode] ) ) { 41 wait( ds.Boys[ccode] ); 46 42 ds.BoyPhoneNo = PhoneNo; 47 43 } else { 48 44 ds.BoyPhoneNo = PhoneNo; 49 signal_block( &ds.Girls[ccode] );45 signal_block( ds.Girls[ccode] ); 50 46 } // if 51 47 return ds.GirlPhoneNo; -
src/tests/sched-int-barge.c
re1e8408 r4cedd9f 73 73 if( action == c.do_wait1 || action == c.do_wait2 ) { 74 74 c.state = WAIT; 75 wait( &cond );75 wait( cond ); 76 76 77 77 if(c.state != SIGNAL) { … … 83 83 c.state = SIGNAL; 84 84 85 signal( &cond );86 signal( &cond );85 signal( cond ); 86 signal( cond ); 87 87 } 88 88 else { -
src/tests/sched-int-block.c
re1e8408 r4cedd9f 47 47 //------------------------------------------------------------------------------ 48 48 void wait_op( global_data_t & mutex a, global_data_t & mutex b, unsigned i ) { 49 wait( &cond, (uintptr_t)this_thread );49 wait( cond, (uintptr_t)this_thread ); 50 50 51 51 yield( rand48(10) ); … … 74 74 [a.last_thread, b.last_thread, a.last_signaller, b.last_signaller] = this_thread; 75 75 76 if( !is_empty( &cond ) ) {76 if( !is_empty( cond ) ) { 77 77 78 thread_desc * next = front( &cond );78 thread_desc * next = front( cond ); 79 79 80 if( ! signal_block( &cond ) ) {80 if( ! signal_block( cond ) ) { 81 81 sout | "ERROR expected to be able to signal" | endl; 82 82 abort(); -
src/tests/sched-int-disjoint.c
re1e8408 r4cedd9f 59 59 // Waiting logic 60 60 bool wait( global_t & mutex m, global_data_t & mutex d ) { 61 wait( &cond );61 wait( cond ); 62 62 if( d.state != SIGNAL ) { 63 63 sout | "ERROR barging!" | endl; … … 80 80 //------------------------------------------------------------------------------ 81 81 // Signalling logic 82 void signal( condition *cond, global_t & mutex a, global_data_t & mutex b ) {82 void signal( condition & cond, global_t & mutex a, global_data_t & mutex b ) { 83 83 b.state = SIGNAL; 84 84 signal( cond ); … … 86 86 87 87 void logic( global_t & mutex a ) { 88 signal( &cond, a, data );88 signal( cond, a, data ); 89 89 90 90 yield( rand48(10) ); -
src/tests/sched-int-wait.c
re1e8408 r4cedd9f 41 41 //---------------------------------------------------------------------------------------------------- 42 42 // Tools 43 void signal( condition *cond, global_t & mutex a, global_t & mutex b ) {43 void signal( condition & cond, global_t & mutex a, global_t & mutex b ) { 44 44 signal( cond ); 45 45 } 46 46 47 void signal( condition *cond, global_t & mutex a, global_t & mutex b, global_t & mutex c ) {47 void signal( condition & cond, global_t & mutex a, global_t & mutex b, global_t & mutex c ) { 48 48 signal( cond ); 49 49 } 50 50 51 void wait( condition *cond, global_t & mutex a, global_t & mutex b ) {51 void wait( condition & cond, global_t & mutex a, global_t & mutex b ) { 52 52 wait( cond ); 53 53 } 54 54 55 void wait( condition *cond, global_t & mutex a, global_t & mutex b, global_t & mutex c ) {55 void wait( condition & cond, global_t & mutex a, global_t & mutex b, global_t & mutex c ) { 56 56 wait( cond ); 57 57 } … … 65 65 switch( action ) { 66 66 case 0: 67 signal( &condABC, globalA, globalB, globalC );67 signal( condABC, globalA, globalB, globalC ); 68 68 break; 69 69 case 1: 70 signal( &condAB , globalA, globalB );70 signal( condAB , globalA, globalB ); 71 71 break; 72 72 case 2: 73 signal( &condBC , globalB, globalC );73 signal( condBC , globalB, globalC ); 74 74 break; 75 75 case 3: 76 signal( &condAC , globalA, globalC );76 signal( condAC , globalA, globalC ); 77 77 break; 78 78 default: … … 88 88 void main( WaiterABC & this ) { 89 89 for( int i = 0; i < N; i++ ) { 90 wait( &condABC, globalA, globalB, globalC );90 wait( condABC, globalA, globalB, globalC ); 91 91 } 92 92 … … 98 98 void main( WaiterAB & this ) { 99 99 for( int i = 0; i < N; i++ ) { 100 wait( &condAB , globalA, globalB );100 wait( condAB , globalA, globalB ); 101 101 } 102 102 … … 108 108 void main( WaiterAC & this ) { 109 109 for( int i = 0; i < N; i++ ) { 110 wait( &condAC , globalA, globalC );110 wait( condAC , globalA, globalC ); 111 111 } 112 112 … … 118 118 void main( WaiterBC & this ) { 119 119 for( int i = 0; i < N; i++ ) { 120 wait( &condBC , globalB, globalC );120 wait( condBC , globalB, globalC ); 121 121 } 122 122 -
src/tests/thread.c
re1e8408 r4cedd9f 15 15 yield(); 16 16 } 17 V( this.lock);17 V(*this.lock); 18 18 } 19 19 20 20 void main(Second& this) { 21 P( this.lock);21 P(*this.lock); 22 22 for(int i = 0; i < 10; i++) { 23 23 sout | "Second : Suspend No." | i + 1 | endl;
Note: See TracChangeset
for help on using the changeset viewer.