Changeset 16988e8 for src/tests


Ignore:
Timestamp:
Dec 6, 2017, 11:49:36 AM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
16a63a78
Parents:
a85e44c (diff), 971d9f2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/tests
Files:
6 edited
2 moved

Legend:

Unmodified
Added
Removed
  • src/tests/concurrent/examples/.expect/datingService.txt

    ra85e44c r16988e8  
     1Girl:17 is dating Boy at 2 with ccode 17
     2 Boy:2 is dating Girl 17 with ccode 17
     3 Boy:14 is dating Girl 5 with ccode 5
     4Girl:5 is dating Boy at 14 with ccode 5
     5 Boy:9 is dating Girl 10 with ccode 10
     6Girl:10 is dating Boy at 9 with ccode 10
     7 Boy:1 is dating Girl 18 with ccode 18
     8Girl:18 is dating Boy at 1 with ccode 18
     9 Boy:16 is dating Girl 3 with ccode 3
     10Girl:3 is dating Boy at 16 with ccode 3
     11 Boy:5 is dating Girl 14 with ccode 14
     12Girl:14 is dating Boy at 5 with ccode 14
     13 Boy:15 is dating Girl 4 with ccode 4
     14Girl:4 is dating Boy at 15 with ccode 4
     15Girl:0 is dating Boy at 19 with ccode 0
     16 Boy:19 is dating Girl 0 with ccode 0
     17Girl:9 is dating Boy at 10 with ccode 9
     18 Boy:10 is dating Girl 9 with ccode 9
     19Girl:11 is dating Boy at 8 with ccode 11
     20 Boy:8 is dating Girl 11 with ccode 11
     21 Boy:12 is dating Girl 7 with ccode 7
     22Girl:7 is dating Boy at 12 with ccode 7
     23 Boy:11 is dating Girl 8 with ccode 8
     24Girl:8 is dating Boy at 11 with ccode 8
     25Girl:16 is dating Boy at 3 with ccode 16
     26 Boy:3 is dating Girl 16 with ccode 16
     27Girl:15 is dating Boy at 4 with ccode 15
     28 Boy:4 is dating Girl 15 with ccode 15
     29Girl:19 is dating Boy at 0 with ccode 19
     30 Boy:0 is dating Girl 19 with ccode 19
     31Girl:2 is dating Boy at 17 with ccode 2
     32 Boy:17 is dating Girl 2 with ccode 2
     33 Boy:13 is dating Girl 6 with ccode 6
     34Girl:6 is dating Boy at 13 with ccode 6
     35 Boy:7 is dating Girl 12 with ccode 12
     36Girl:12 is dating Boy at 7 with ccode 12
     37Girl:13 is dating Boy at 6 with ccode 13
     38 Boy:6 is dating Girl 13 with ccode 13
     39Girl:1 is dating Boy at 18 with ccode 1
     40 Boy:18 is dating Girl 1 with ccode 1
  • src/tests/concurrent/examples/boundedBuffer.c

    ra85e44c r16988e8  
    88// Created On       : Mon Oct 30 12:45:13 2017
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Mon Oct 30 23:02:46 2017
    11 // Update Count     : 9
     10// Last Modified On : Tue Dec  5 23:01:51 2017
     11// Update Count     : 10
    1212//
    1313
     
    3030int query( Buffer & buffer ) { return buffer.count; }
    3131
    32 void insert( Buffer & mutex buffer, int elem ) {
    33         if ( buffer.count == 20 ) wait( buffer.empty );
    34         buffer.elements[buffer.back] = elem;
    35         buffer.back = ( buffer.back + 1 ) % 20;
    36         buffer.count += 1;
    37         signal( buffer.full );
     32void insert( Buffer & mutex buffer, int elem ) with( buffer ) {
     33        if ( count == 20 ) wait( empty );
     34        elements[back] = elem;
     35        back = ( back + 1 ) % 20;
     36        count += 1;
     37        signal( full );
    3838}
    39 int remove( Buffer & mutex buffer ) {
    40         if ( buffer.count == 0 ) wait( buffer.full );
    41         int elem = buffer.elements[buffer.front];
    42         buffer.front = ( buffer.front + 1 ) % 20;
    43         buffer.count -= 1;
    44         signal( buffer.empty );
     39int remove( Buffer & mutex buffer ) with( buffer ) {
     40        if ( count == 0 ) wait( full );
     41        int elem = elements[front];
     42        front = ( front + 1 ) % 20;
     43        count -= 1;
     44        signal( empty );
    4545        return elem;
    4646}
  • src/tests/concurrent/examples/datingService.c

    ra85e44c r16988e8  
    99// Created On       : Mon Oct 30 12:56:20 2017
    1010// Last Modified By : Peter A. Buhr
    11 // Last Modified On : Mon Oct 30 23:02:11 2017
    12 // Update Count     : 15
     11// Last Modified On : Tue Dec  5 23:06:40 2017
     12// Update Count     : 18
    1313//
    1414
     
    2626}; // DatingService
    2727
    28 unsigned int girl( DatingService & mutex ds, unsigned int PhoneNo, unsigned int ccode ) {
    29         if ( is_empty( ds.Boys[ccode] ) ) {
    30                 wait( ds.Girls[ccode] );
    31                 ds.GirlPhoneNo = PhoneNo;
     28unsigned int girl( DatingService & mutex ds, unsigned int PhoneNo, unsigned int ccode ) with( ds ) {
     29        if ( is_empty( Boys[ccode] ) ) {
     30                wait( Girls[ccode] );
     31                GirlPhoneNo = PhoneNo;
    3232        } else {
    33                 ds.GirlPhoneNo = PhoneNo;
    34                 signal_block( ds.Boys[ccode] );
     33                GirlPhoneNo = PhoneNo;
     34                signal_block( Boys[ccode] );
    3535        } // if
    36         return ds.BoyPhoneNo;
     36        return BoyPhoneNo;
    3737} // DatingService girl
    3838
    39 unsigned int boy( DatingService & mutex ds, unsigned int PhoneNo, unsigned int ccode ) {
    40         if ( is_empty( ds.Girls[ccode] ) ) {
    41                 wait( ds.Boys[ccode] );
    42                 ds.BoyPhoneNo = PhoneNo;
     39unsigned int boy( DatingService & mutex ds, unsigned int PhoneNo, unsigned int ccode ) with( ds ) {
     40        if ( is_empty( Girls[ccode] ) ) {
     41                wait( Boys[ccode] );
     42                BoyPhoneNo = PhoneNo;
    4343        } else {
    44                 ds.BoyPhoneNo = PhoneNo;
    45                 signal_block( ds.Girls[ccode] );
     44                BoyPhoneNo = PhoneNo;
     45                signal_block( Girls[ccode] );
    4646        } // if
    47         return ds.GirlPhoneNo;
     47        return GirlPhoneNo;
    4848} // DatingService boy
    4949
     
    5959        yield( random( 100 ) );                                                         // don't all start at the same time
    6060        unsigned int partner = girl( g.TheExchange, g.id, g.ccode );
    61         //sout | "Girl:" | g.id | "is dating Boy at" | partner | "with ccode" | g.ccode | endl;
     61        sout | "Girl:" | g.id | "is dating Boy at" | partner | "with ccode" | g.ccode | endl;
    6262        girlck[g.id] = partner;
    6363} // Girl main
     
    7777        yield( random( 100 ) );                                                         // don't all start at the same time
    7878        unsigned int partner = boy( b.TheExchange, b.id, b.ccode );
    79         //sout | " Boy:" | b.id | "is dating Girl" | partner | "with ccode" | b.ccode | endl;
     79        sout | " Boy:" | b.id | "is dating Girl" | partner | "with ccode" | b.ccode | endl;
    8080        boyck[b.id] = partner;
    8181} // Boy main
     
    9292        Boy  *boys[NoOfPairs];
    9393
    94         random_seed( getpid() );
     94        random_seed( /*getpid()*/ 103 );
    9595
    9696        for ( unsigned int i = 0; i < NoOfPairs; i += 1 ) {
  • src/tests/concurrent/examples/matrixSum.c

    ra85e44c r16988e8  
    1111// Created On       : Mon Oct  9 08:29:28 2017
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Sun Oct 29 21:08:48 2017
    14 // Update Count     : 2
     13// Last Modified On : Tue Dec  5 22:56:46 2017
     14// Update Count     : 4
    1515//
    1616
     
    2929}
    3030
    31 void main( Adder & adder ) {
    32     *adder.subtotal = 0;
    33     for ( int c = 0; c < adder.cols; c += 1 ) {
    34                 *adder.subtotal += adder.row[c];
     31void main( Adder & adder ) with( adder ) {
     32    *subtotal = 0;
     33    for ( int c = 0; c < cols; c += 1 ) {
     34                *subtotal += row[c];
    3535    } // for
    3636}
  • src/tests/coroutine/fibonacci.c

    ra85e44c r16988e8  
    1010// Created On       : Thu Jun  8 07:29:37 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Sep 17 21:38:15 2017
    13 // Update Count     : 7
     12// Last Modified On : Tue Dec  5 22:27:54 2017
     13// Update Count     : 14
    1414//
    1515
     
    1717#include <coroutine>
    1818
    19 coroutine Fibonacci {
    20         int fn;                                                                                         // used for communication
    21 };
     19coroutine Fibonacci { int fn; };                                                // used for communication
    2220
    23 void ?{}( Fibonacci & this ) {
    24         this.fn = 0;
    25 }
     21void ?{}( Fibonacci & fib ) with( fib ) { fn = 0; }
    2622
    27 void main( Fibonacci & this ) {
     23void main( Fibonacci & fib ) with( fib ) {
    2824        int fn1, fn2;                                                                           // retained between resumes
    29         this.fn = 0;                                                                            // case 0
    30         fn1 = this.fn;
     25
     26        fn = 0; fn1 = fn;                                                                       // 1st case
    3127        suspend();                                                                                      // restart last resume
    3228
    33         this.fn = 1;                                                                            // case 1
    34         fn2 = fn1;  fn1 = this.fn;
     29        fn = 1; fn2 = fn1;  fn1 = fn;                                           // 2nd case
    3530        suspend();                                                                                      // restart last resume
    3631
    37         for ( ;; ) {                                                                            // general case
    38                 this.fn = fn1 + fn2;
    39                 fn2 = fn1;  fn1 = this.fn;
     32        for ( ;; ) {
     33                fn = fn1 + fn2; fn2 = fn1;  fn1 = fn;                   // general case
    4034                suspend();                                                                              // restart last resume
    4135        } // for
    4236}
    4337
    44 int next( Fibonacci & this ) {
    45         resume( this );                                                                         // restart last suspend
    46         return this.fn;
     38int next( Fibonacci & fib ) with( fib ) {
     39        resume( fib );                                                                          // restart last suspend
     40        return fn;
    4741}
    4842
  • src/tests/coroutine/fmtLines.c

    ra85e44c r16988e8  
    1010// Created On       : Sun Sep 17 21:56:15 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Oct  1 11:57:19 2017
    13 // Update Count     : 34
     12// Last Modified On : Tue Dec  5 21:56:35 2017
     13// Update Count     : 38
    1414//
    1515
     
    2626}
    2727
    28 void ^?{}( Format & fmt ) {
    29         if ( fmt.g != 0 || fmt.b != 0 ) sout | endl;
     28void ^?{}( Format & fmt ) with( fmt ) {
     29        if ( g != 0 || b != 0 ) sout | endl;
    3030}
    3131
    32 void main( Format & fmt ) {
     32void main( Format & fmt ) with( fmt ) {
    3333        for ( ;; ) {                                                                            // for as many characters
    34                 for ( fmt.g = 0; fmt.g < 5; fmt.g += 1 ) {              // groups of 5 blocks
    35                         for ( fmt.b = 0; fmt.b < 4; fmt.b += 1 ) {      // blocks of 4 characters
     34                for ( g = 0; g < 5; g += 1 ) {                                  // groups of 5 blocks
     35                        for ( b = 0; b < 4; b += 1 ) {                          // blocks of 4 characters
    3636                                for ( ;; ) {                                                    // for newline characters
    3737                                        suspend();
    38                                         if ( fmt.ch != '\n' ) break;            // ignore newline
     38                                        if ( ch != '\n' ) break;                        // ignore newline
    3939                                } // for
    40                                 sout | fmt.ch;                                                  // print character
     40                                sout | ch;                                                              // print character
    4141                        } // for
    4242                        sout | "  ";                                                            // print block separator
  • src/tests/coroutine/prodcons.c

    ra85e44c r16988e8  
    1010// Created On       : Mon Sep 18 12:23:39 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Oct 30 23:06:05 2017
    13 // Update Count     : 42
     12// Last Modified On : Tue Dec  5 22:40:55 2017
     13// Update Count     : 46
    1414//
    1515
     
    2424
    2525coroutine Prod {
    26         Cons *c;
     26        Cons * c;
    2727        int N, money, receipt;
    2828};
    29 void main( Prod & prod ) {                                                              // starter ::main
     29void main( Prod & prod ) with( prod ) {                                 // starter ::main
    3030        // 1st resume starts here
    31         for ( int i = 0; i < prod.N; i += 1 ) {
     31        for ( int i = 0; i < N; i += 1 ) {
    3232                int p1 = random( 100 );
    3333                int p2 = random( 100 );
    3434                sout | p1 | " " | p2 | endl;
    35                 int status = delivery( *prod.c, p1, p2 );
    36                 sout | " $" | prod.money | endl;
     35                int status = delivery( *c, p1, p2 );
     36                sout | " $" | money | endl;
    3737                sout | status | endl;
    38                 prod.receipt += 1;
     38                receipt += 1;
    3939        }
    40         stop( *prod.c );
     40        stop( *c );
    4141        sout | "prod stops" | endl;
    4242}
     
    6464}
    6565void ^?{}( Cons & cons ) {}
    66 void main( Cons & cons ) {                                                              // starter prod
     66void main( Cons & cons ) with( cons ) {                                 // starter prod
    6767        // 1st resume starts here
    6868        int money = 1, receipt;
    69         for ( ; ! cons.done; ) {
    70                 sout | cons.p1 | " " | cons.p2 | endl;
     69        for ( ; ! done; ) {
     70                sout | p1 | " " | p2 | endl;
    7171                sout | " $" | money | endl;
    72                 cons.status += 1;
    73                 receipt = payment( *cons.p, money );
     72                status += 1;
     73                receipt = payment( *p, money );
    7474                sout | " #" | receipt | endl;
    7575                money += 1;
Note: See TracChangeset for help on using the changeset viewer.