Changeset 4cedd9f


Ignore:
Timestamp:
Nov 2, 2017, 2:15:19 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
8fc45b7
Parents:
e1e8408
Message:

Updated public concurrency API to use references

Location:
src
Files:
1 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • src/benchmark/Makefile.am

    re1e8408 r4cedd9f  
    2727
    2828noinst_PROGRAMS =
     29
     30all : ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT)
    2931
    3032bench$(EXEEXT) :
     
    6365ctxswitch-pthread$(EXEEXT):
    6466        @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.run
    73 
    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}
    8867
    8968## =========================================================================================================
     
    153132
    154133## =========================================================================================================
     134creation$(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
     141creation-cfa_coroutine$(EXEEXT):
     142        ${CC}        creation/cfa_cor.c   -DBENCH_N=10000000   -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     143
     144creation-cfa_thread$(EXEEXT):
     145        ${CC}        creation/cfa_thrd.c  -DBENCH_N=10000000   -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     146
     147creation-upp_coroutine$(EXEEXT):
     148        u++          creation/upp_cor.cc  -DBENCH_N=50000000   -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     149
     150creation-upp_thread$(EXEEXT):
     151        u++          creation/upp_thrd.cc -DBENCH_N=50000000   -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     152
     153creation-pthread$(EXEEXT):
     154        @BACKEND_CC@ creation/pthreads.c  -DBENCH_N=250000     -I. -lrt -pthread                    ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     155
     156## =========================================================================================================
    155157
    156158%.run : %$(EXEEXT) ${REPEAT}
  • src/benchmark/Makefile.in

    re1e8408 r4cedd9f  
    444444.NOTPARALLEL:
    445445
     446all : ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT)
     447
    446448bench$(EXEEXT) :
    447449        @for ccflags in "-debug" "-nodebug"; do \
     
    479481        @BACKEND_CC@ ctxswitch/pthreads.c  -DBENCH_N=50000000  -I. -lrt -pthread                    ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    480482
    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.run
    487 
    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 
    503483mutex$(EXEEXT) :\
    504484        mutex-function.run      \
     
    562542waitfor-cfa4$(EXEEXT):
    563543        ${CC}        schedext/cfa4.c     -DBENCH_N=500000      -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     544
     545creation$(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
     552creation-cfa_coroutine$(EXEEXT):
     553        ${CC}        creation/cfa_cor.c   -DBENCH_N=10000000   -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     554
     555creation-cfa_thread$(EXEEXT):
     556        ${CC}        creation/cfa_thrd.c  -DBENCH_N=10000000   -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     557
     558creation-upp_coroutine$(EXEEXT):
     559        u++          creation/upp_cor.cc  -DBENCH_N=50000000   -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     560
     561creation-upp_thread$(EXEEXT):
     562        u++          creation/upp_thrd.cc -DBENCH_N=50000000   -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     563
     564creation-pthread$(EXEEXT):
     565        @BACKEND_CC@ creation/pthreads.c  -DBENCH_N=250000     -I. -lrt -pthread                    ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    564566
    565567%.run : %$(EXEEXT) ${REPEAT}
  • src/benchmark/csv-data.c

    re1e8408 r4cedd9f  
    111111        StartTime = Time();
    112112        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);
    116116        }
    117117        EndTime = Time();
     
    122122void side1B( mon_t & mutex a ) {
    123123        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);
    127127        }
    128128}
     
    159159        StartTime = Time();
    160160        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);
    164164        }
    165165        EndTime = Time();
     
    170170void side2B( mon_t & mutex a, mon_t & mutex b ) {
    171171        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);
    175175        }
    176176}
  • src/benchmark/schedint/cfa1.c

    re1e8408 r4cedd9f  
    1515
    1616void __attribute__((noinline)) call( M & mutex a1 ) {
    17         signal(&c);
     17        signal(c);
    1818}
    1919
     
    2222        BENCH(
    2323                for (size_t i = 0; i < n; i++) {
    24                         wait(&c);
     24                        wait(c);
    2525                },
    2626                result
  • src/benchmark/schedint/cfa2.c

    re1e8408 r4cedd9f  
    1515
    1616void __attribute__((noinline)) call( M & mutex a1, M & mutex a2 ) {
    17         signal(&c);
     17        signal(c);
    1818}
    1919
     
    2222        BENCH(
    2323                for (size_t i = 0; i < n; i++) {
    24                         wait(&c);
     24                        wait(c);
    2525                },
    2626                result
  • src/benchmark/schedint/cfa4.c

    re1e8408 r4cedd9f  
    1515
    1616void __attribute__((noinline)) call( M & mutex a1, M & mutex a2, M & mutex a3, M & mutex a4 ) {
    17         signal(&c);
     17        signal(c);
    1818}
    1919
     
    2222        BENCH(
    2323                for (size_t i = 0; i < n; i++) {
    24                         wait(&c);
     24                        wait(c);
    2525                },
    2626                result
  • src/libcfa/concurrency/kernel

    re1e8408 r4cedd9f  
    3939void  ?{}(semaphore & this, int count = 1);
    4040void ^?{}(semaphore & this);
    41 void P(semaphore * this);
    42 void V(semaphore * this);
     41void   P (semaphore & this);
     42void   V (semaphore & this);
    4343
    4444
     
    5151};
    5252
    53 void ?{}(cluster & this);
     53void ?{} (cluster & this);
    5454void ^?{}(cluster & this);
    5555
  • src/libcfa/concurrency/kernel.c

    re1e8408 r4cedd9f  
    158158                LIB_DEBUG_PRINT_SAFE("Kernel : core %p signaling termination\n", &this);
    159159                this.do_terminate = true;
    160                 P( &this.terminated );
     160                P( this.terminated );
    161161                pthread_join( this.kernel_thread, NULL );
    162162        }
     
    216216        }
    217217
    218         V( &this->terminated );
     218        V( this->terminated );
    219219
    220220        LIB_DEBUG_PRINT_SAFE("Kernel : core %p terminated\n", this);
     
    618618void ^?{}(semaphore & this) {}
    619619
    620 void P(semaphore * this) {
    621         lock( &this->lock DEBUG_CTX2 );
    622         this->count -= 1;
    623         if ( this->count < 0 ) {
     620void P(semaphore & this) {
     621        lock( &this.lock DEBUG_CTX2 );
     622        this.count -= 1;
     623        if ( this.count < 0 ) {
    624624                // queue current task
    625                 append( &this->waiting, (thread_desc *)this_thread );
     625                append( &this.waiting, (thread_desc *)this_thread );
    626626
    627627                // atomically release spin lock and block
    628                 BlockInternal( &this->lock );
     628                BlockInternal( &this.lock );
    629629        }
    630630        else {
    631             unlock( &this->lock );
    632         }
    633 }
    634 
    635 void V(semaphore * this) {
     631            unlock( &this.lock );
     632        }
     633}
     634
     635void V(semaphore & this) {
    636636        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 ) {
    640640                // 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 );
    645645
    646646        // make new owner
  • src/libcfa/concurrency/monitor

    re1e8408 r4cedd9f  
    116116}
    117117
    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 );
     118void wait( condition & this, uintptr_t user_info = 0 );
     119bool signal( condition & this );
     120bool signal_block( condition & this );
     121static inline bool is_empty( condition & this ) { return !this.blocked.head; }
     122uintptr_t front( condition & this );
    123123
    124124//-----------------------------------------------------------------------------
  • src/libcfa/concurrency/monitor.c

    re1e8408 r4cedd9f  
    4545
    4646static inline thread_desc *        check_condition   ( __condition_criterion_t * );
    47 static inline void                 brand_condition   ( condition * );
     47static inline void                 brand_condition   ( condition & );
    4848static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t &, monitor_desc ** monitors, int count );
    4949
     
    6969        unsigned short count = cnt;                               /* Save the count to a local variable                                                  */ \
    7070        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                                */ \
    7272        spinlock *   locks     [ count ];                         /* We need to pass-in an array of locks to BlockInternal                               */ \
    7373
     
    387387//-----------------------------------------------------------------------------
    388388// Internal scheduling
    389 void wait( condition * this, uintptr_t user_info = 0 ) {
     389void wait( condition & this, uintptr_t user_info = 0 ) {
    390390        brand_condition( this );
    391391
    392392        // 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 );
    396396
    397397        // Create storage for monitor context
    398         monitor_ctx( this->monitors, this->monitor_count );
     398        monitor_ctx( this.monitors, this.monitor_count );
    399399
    400400        // Create the node specific to this wait operation
     
    403403        // Append the current wait operation to the ones already queued on the condition
    404404        // 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 );
    406406
    407407        // Lock all monitors (aggregates the locks as well)
     
    429429}
    430430
    431 bool signal( condition * this ) {
     431bool signal( condition & this ) {
    432432        if( is_empty( this ) ) { return false; }
    433433
    434434        //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 );
    437437
    438438        //Some more checking in debug
    439439        LIB_DEBUG_DO(
    440440                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] );
    448448                        }
    449449                }
    450450        );
    451451
    452         unsigned short count = this->monitor_count;
     452        unsigned short count = this.monitor_count;
    453453
    454454        // Lock all monitors
    455         lock_all( this->monitors, NULL, count );
     455        lock_all( this.monitors, NULL, count );
    456456
    457457        //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 );
    459459
    460460        //Add the thread to the proper AS stack
     
    466466
    467467        //Release
    468         unlock_all( this->monitors, count );
     468        unlock_all( this.monitors, count );
    469469
    470470        return true;
    471471}
    472472
    473 bool signal_block( condition * this ) {
    474         if( !this->blocked.head ) { return false; }
     473bool signal_block( condition & this ) {
     474        if( !this.blocked.head ) { return false; }
    475475
    476476        //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 );
    479479
    480480        // Create storage for monitor context
    481         monitor_ctx( this->monitors, this->monitor_count );
     481        monitor_ctx( this.monitors, this.monitor_count );
    482482
    483483        // Lock all monitors (aggregates the locks them as well)
     
    491491
    492492        //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;
    494494        set_owner( monitors, count, signallee );
    495495
    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 );
    497497
    498498        //Everything is ready to go to sleep
     
    512512
    513513// Access the user_info of the thread waiting at the front of the queue
    514 uintptr_t front( condition * this ) {
     514uintptr_t front( condition & this ) {
    515515        verifyf( !is_empty(this),
    516516                "Attempt to access user data on an empty condition.\n"
    517517                "Possible cause is not checking if the condition is empty before reading stored data."
    518518        );
    519         return this->blocked.head->user_info;
     519        return this.blocked.head->user_info;
    520520}
    521521
     
    811811}
    812812
    813 static inline void brand_condition( condition * this ) {
     813static inline void brand_condition( condition & this ) {
    814814        thread_desc * thrd = this_thread;
    815         if( !this->monitors ) {
     815        if( !this.monitors ) {
    816816                // LIB_DEBUG_PRINT_SAFE("Branding\n");
    817817                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];
    823823                }
    824824        }
  • src/tests/boundedBuffer.c

    re1e8408 r4cedd9f  
    1 // 
     1//
    22// The contents of this file are covered under the licence agreement in the
    33// file "LICENCE" distributed with Cforall.
    4 // 
    5 // boundedBuffer.c -- 
    6 // 
     4//
     5// boundedBuffer.c --
     6//
    77// Author           : Peter A. Buhr
    88// Created On       : Mon Oct 30 12:45:13 2017
     
    1010// Last Modified On : Mon Oct 30 18:00:10 2017
    1111// Update Count     : 7
    12 // 
     12//
    1313
    1414#include <stdlib>
     
    3131
    3232void insert( Buffer & mutex buffer, int elem ) {
    33         if ( buffer.count == 20 ) wait( &buffer.empty );
     33        if ( buffer.count == 20 ) wait( buffer.empty );
    3434        buffer.elements[buffer.back] = elem;
    3535        buffer.back = ( buffer.back + 1 ) % 20;
    3636        buffer.count += 1;
    37         signal( &buffer.full );
     37        signal( buffer.full );
    3838}
    3939int remove( Buffer & mutex buffer ) {
    40         if ( buffer.count == 0 ) wait( &buffer.full );
     40        if ( buffer.count == 0 ) wait( buffer.full );
    4141        int elem = buffer.elements[buffer.front];
    4242        buffer.front = ( buffer.front + 1 ) % 20;
    4343        buffer.count -= 1;
    44         signal( &buffer.empty );
     44        signal( buffer.empty );
    4545        return elem;
    4646}
  • src/tests/datingService.c

    re1e8408 r4cedd9f  
    1 //                               -*- Mode: C -*- 
    2 // 
     1//                               -*- Mode: C -*-
     2//
    33// The contents of this file are covered under the licence agreement in the
    44// file "LICENCE" distributed with Cforall.
    5 // 
    6 // datingService.c -- 
    7 // 
     5//
     6// datingService.c --
     7//
    88// Author           : Peter A. Buhr
    99// Created On       : Mon Oct 30 12:56:20 2017
     
    1111// Last Modified On : Mon Oct 30 17:58:41 2017
    1212// Update Count     : 14
    13 // 
     13//
    1414
    1515#include <stdlib>                                                                               // rand48
     
    1818#include <thread>
    1919#include <unistd.h>                                                                             // getpid
    20 
    21 bool empty( condition & c ) {
    22         return c.blocked.head == NULL;
    23 }
    2420
    2521enum { NoOfPairs = 20 };
     
    3127
    3228unsigned 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] );
    3531                ds.GirlPhoneNo = PhoneNo;
    3632        } else {
    3733                ds.GirlPhoneNo = PhoneNo;
    38                 signal_block( &ds.Boys[ccode] );
     34                signal_block( ds.Boys[ccode] );
    3935        } // if
    4036        return ds.BoyPhoneNo;
     
    4238
    4339unsigned 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] );
    4642                ds.BoyPhoneNo = PhoneNo;
    4743        } else {
    4844                ds.BoyPhoneNo = PhoneNo;
    49                 signal_block( &ds.Girls[ccode] );
     45                signal_block( ds.Girls[ccode] );
    5046        } // if
    5147        return ds.GirlPhoneNo;
  • src/tests/sched-int-barge.c

    re1e8408 r4cedd9f  
    7373        if( action == c.do_wait1 || action == c.do_wait2 ) {
    7474                c.state = WAIT;
    75                 wait( &cond );
     75                wait( cond );
    7676
    7777                if(c.state != SIGNAL) {
     
    8383                c.state = SIGNAL;
    8484
    85                 signal( &cond );
    86                 signal( &cond );
     85                signal( cond );
     86                signal( cond );
    8787        }
    8888        else {
  • src/tests/sched-int-block.c

    re1e8408 r4cedd9f  
    4747//------------------------------------------------------------------------------
    4848void 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 );
    5050
    5151        yield( rand48(10) );
     
    7474        [a.last_thread, b.last_thread, a.last_signaller, b.last_signaller] = this_thread;
    7575
    76         if( !is_empty( &cond ) ) {
     76        if( !is_empty( cond ) ) {
    7777
    78                 thread_desc * next = front( &cond );
     78                thread_desc * next = front( cond );
    7979
    80                 if( ! signal_block( &cond ) ) {
     80                if( ! signal_block( cond ) ) {
    8181                        sout | "ERROR expected to be able to signal" | endl;
    8282                        abort();
  • src/tests/sched-int-disjoint.c

    re1e8408 r4cedd9f  
    5959// Waiting logic
    6060bool wait( global_t & mutex m, global_data_t & mutex d ) {
    61         wait( &cond );
     61        wait( cond );
    6262        if( d.state != SIGNAL ) {
    6363                sout | "ERROR barging!" | endl;
     
    8080//------------------------------------------------------------------------------
    8181// Signalling logic
    82 void signal( condition * cond, global_t & mutex a, global_data_t & mutex b ) {
     82void signal( condition & cond, global_t & mutex a, global_data_t & mutex b ) {
    8383        b.state = SIGNAL;
    8484        signal( cond );
     
    8686
    8787void logic( global_t & mutex a ) {
    88         signal( &cond, a, data );
     88        signal( cond, a, data );
    8989
    9090        yield( rand48(10) );
  • src/tests/sched-int-wait.c

    re1e8408 r4cedd9f  
    4141//----------------------------------------------------------------------------------------------------
    4242// Tools
    43 void signal( condition * cond, global_t & mutex a, global_t & mutex b ) {
     43void signal( condition & cond, global_t & mutex a, global_t & mutex b ) {
    4444        signal( cond );
    4545}
    4646
    47 void signal( condition * cond, global_t & mutex a, global_t & mutex b, global_t & mutex c ) {
     47void signal( condition & cond, global_t & mutex a, global_t & mutex b, global_t & mutex c ) {
    4848        signal( cond );
    4949}
    5050
    51 void wait( condition * cond, global_t & mutex a, global_t & mutex b ) {
     51void wait( condition & cond, global_t & mutex a, global_t & mutex b ) {
    5252        wait( cond );
    5353}
    5454
    55 void wait( condition * cond, global_t & mutex a, global_t & mutex b, global_t & mutex c ) {
     55void wait( condition & cond, global_t & mutex a, global_t & mutex b, global_t & mutex c ) {
    5656        wait( cond );
    5757}
     
    6565                switch( action ) {
    6666                        case 0:
    67                                 signal( &condABC, globalA, globalB, globalC );
     67                                signal( condABC, globalA, globalB, globalC );
    6868                                break;
    6969                        case 1:
    70                                 signal( &condAB , globalA, globalB );
     70                                signal( condAB , globalA, globalB );
    7171                                break;
    7272                        case 2:
    73                                 signal( &condBC , globalB, globalC );
     73                                signal( condBC , globalB, globalC );
    7474                                break;
    7575                        case 3:
    76                                 signal( &condAC , globalA, globalC );
     76                                signal( condAC , globalA, globalC );
    7777                                break;
    7878                        default:
     
    8888void main( WaiterABC & this ) {
    8989        for( int i = 0; i < N; i++ ) {
    90                 wait( &condABC, globalA, globalB, globalC );
     90                wait( condABC, globalA, globalB, globalC );
    9191        }
    9292
     
    9898void main( WaiterAB & this ) {
    9999        for( int i = 0; i < N; i++ ) {
    100                 wait( &condAB , globalA, globalB );
     100                wait( condAB , globalA, globalB );
    101101        }
    102102
     
    108108void main( WaiterAC & this ) {
    109109        for( int i = 0; i < N; i++ ) {
    110                 wait( &condAC , globalA, globalC );
     110                wait( condAC , globalA, globalC );
    111111        }
    112112
     
    118118void main( WaiterBC & this ) {
    119119        for( int i = 0; i < N; i++ ) {
    120                 wait( &condBC , globalB, globalC );
     120                wait( condBC , globalB, globalC );
    121121        }
    122122
  • src/tests/thread.c

    re1e8408 r4cedd9f  
    1515                yield();
    1616        }
    17         V(this.lock);
     17        V(*this.lock);
    1818}
    1919
    2020void main(Second& this) {
    21         P(this.lock);
     21        P(*this.lock);
    2222        for(int i = 0; i < 10; i++) {
    2323                sout | "Second : Suspend No." | i + 1 | endl;
Note: See TracChangeset for help on using the changeset viewer.