Changeset ff29f08 for src/tests/concurrent
- Timestamp:
- May 18, 2018, 2:09:21 PM (8 years ago)
- Branches:
- new-env, with_gc
- Children:
- 2472a19
- Parents:
- f6f0cca3 (diff), c7d8100c (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. - Location:
- src/tests/concurrent
- Files:
-
- 5 edited
-
examples/.expect/boundedBufferEXT.txt (modified) (1 diff)
-
examples/boundedBufferEXT.c (modified) (2 diffs)
-
examples/boundedBufferINT.c (modified) (2 diffs)
-
preempt.c (modified) (2 diffs)
-
thread.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/tests/concurrent/examples/.expect/boundedBufferEXT.txt
rf6f0cca3 rff29f08 1 concurrent/examples/boundedBufferEXT.c:39:1 error: No alternatives for function in call to waitfor 2 /u/pabuhr/software/cfa-cc/include/cfa/bits/containers.h:170:1 error: candidate function not viable: no mutex parameters 3 forall 4 _6573_20_T: sized object type 5 ... with assertions 6 get_next: pointer to function 7 ... with parameters 8 reference to instance of type _6573_20_T (not function type) 9 ... returning 10 _retval_get_next: reference to pointer to instance of type _6573_20_T (not function type) 11 ... with attributes: 12 Attribute with name: unused 13 14 15 16 lvalue function 17 ... with parameters 18 this: reference to instance of struct __queue with body 1 19 ... with parameters 20 instance of type _6573_20_T (not function type) 21 22 it: pointer to pointer to instance of type _6573_20_T (not function type) 23 ... returning 24 _retval_remove: pointer to instance of type _6573_20_T (not function type) 25 ... with attributes: 26 Attribute with name: unused 27 28 29 /usr/include/stdio.h:178:1 error: candidate function not viable: no mutex parameters 30 lvalue function 31 ... with parameters 32 __filename: C pointer to const char 33 ... returning 34 _retval_remove: signed int 35 ... with attributes: 36 Attribute with name: unused 37 38 39 concurrent/examples/boundedBufferEXT.c:47:1 error: No alternatives for function in call to waitfor 40 concurrent/examples/boundedBufferEXT.c:37:1 error: candidate function not viable: too few mutex arguments 41 forall 42 _6578_20_T: sized object type 43 ... with assertions 44 ?=?: pointer to function 45 ... with parameters 46 reference to instance of type _6578_20_T (not function type) 47 instance of type _6578_20_T (not function type) 48 ... returning 49 _retval__operator_assign: instance of type _6578_20_T (not function type) 50 ... with attributes: 51 Attribute with name: unused 52 53 54 ?{}: pointer to function 55 ... with parameters 56 reference to instance of type _6578_20_T (not function type) 57 ... returning nothing 58 59 ?{}: pointer to function 60 ... with parameters 61 reference to instance of type _6578_20_T (not function type) 62 instance of type _6578_20_T (not function type) 63 ... returning nothing 64 65 ^?{}: pointer to function 66 ... with parameters 67 reference to instance of type _6578_20_T (not function type) 68 ... returning nothing 69 70 71 lvalue function 72 ... with parameters 73 buffer: mutex reference to instance of struct Buffer with body 1 74 ... with parameters 75 instance of type _6578_20_T (not function type) 76 77 elem: instance of type _6578_20_T (not function type) 78 ... returning nothing 79 1 total:400000 -
src/tests/concurrent/examples/boundedBufferEXT.c
rf6f0cca3 rff29f08 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 // boundedBufferEXT.c -- 6 // 4 // 5 // boundedBufferEXT.c -- 6 // 7 7 // Author : Peter A. Buhr 8 8 // Created On : Wed Apr 18 22:52:12 2018 9 9 // Last Modified By : Peter A. Buhr 10 // Last Modified On : Fri Apr 20 22:25:14201811 // Update Count : 612 // 10 // Last Modified On : Wed May 2 16:12:58 2018 11 // Update Count : 7 12 // 13 13 14 14 #include <stdlib> // random … … 22 22 enum { BufferSize = 50 }; 23 23 24 forall( otype T ) 25 monitor Buffer {26 int front, back, count;27 T elements[BufferSize];28 }; 24 forall( otype T ) { 25 monitor Buffer { 26 int front, back, count; 27 T elements[BufferSize]; 28 }; // Buffer 29 29 30 forall( otype T ) 31 void ?{}( Buffer(T) & buffer ) with( buffer ) { [front, back, count] = 0; } 30 void ?{}( Buffer(T) & buffer ) with( buffer ) { [front, back, count] = 0; } 32 31 33 forall( otype T ) 34 int query( Buffer(T) & buffer ) { return buffer.count; } 32 int query( Buffer(T) & buffer ) { return buffer.count; } // read-only, no mutual exclusion 35 33 36 forall( otype T ) // forward 37 T remove( Buffer(T) & mutex buffer ); 34 T remove( Buffer(T) & mutex buffer ); // forward 38 35 39 forall( otype T ) 40 void insert( Buffer(T) & mutex buffer, T elem ) with( buffer ) { 41 if ( count == BufferSize ) waitfor( remove ); 42 elements[back] = elem; 43 back = ( back + 1 ) % BufferSize; 44 count += 1; 45 } 36 void insert( Buffer(T) & mutex buffer, T elem ) with( buffer ) { 37 if ( count == BufferSize ) waitfor( remove, buffer ); 38 elements[back] = elem; 39 back = ( back + 1 ) % BufferSize; 40 count += 1; 41 } // insert 46 42 47 forall( otype T ) 48 T remove( Buffer(T) & mutex buffer ) with( buffer ) { 49 if ( count == 0 ) waitfor( insert );50 T elem = elements[front];51 front = ( front + 1 ) % BufferSize;52 count -= 1;53 return elem;43 T remove( Buffer(T) & mutex buffer ) with( buffer ) { 44 if ( count == 0 ) waitfor( insert, buffer ); 45 T elem = elements[front]; 46 front = ( front + 1 ) % BufferSize; 47 count -= 1; 48 return elem; 49 } // remove 54 50 } 55 51 -
src/tests/concurrent/examples/boundedBufferINT.c
rf6f0cca3 rff29f08 8 8 // Created On : Mon Oct 30 12:45:13 2017 9 9 // Last Modified By : Peter A. Buhr 10 // Last Modified On : Fri Apr 20 22:18:18201811 // Update Count : 7810 // Last Modified On : Thu Apr 26 23:08:17 2018 11 // Update Count : 82 12 12 // 13 13 … … 22 22 enum { BufferSize = 50 }; 23 23 24 forall( otype T ) 25 monitor Buffer {26 condition full, empty;27 int front, back, count;28 T elements[BufferSize];29 }; 24 forall( otype T ) { 25 monitor Buffer { 26 condition full, empty; 27 int front, back, count; 28 T elements[BufferSize]; 29 }; // Buffer 30 30 31 forall( otype T ) 32 void ?{}( Buffer(T) & buffer ) with( buffer ) { [front, back, count] = 0; } 31 void ?{}( Buffer(T) & buffer ) with( buffer ) { [front, back, count] = 0; } 33 32 34 forall( otype T ) 35 int query( Buffer(T) & buffer ) { return buffer.count; } 33 int query( Buffer(T) & buffer ) { return buffer.count; } // read-only, no mutual exclusion 36 34 37 forall( otype T ) 38 void insert( Buffer(T) & mutex buffer, T elem ) with( buffer ) { 39 if ( count == BufferSize ) wait( empty ); 40 elements[back] = elem; 41 back = ( back + 1 ) % BufferSize; 42 count += 1; 43 signal( full ); 44 } 35 void insert( Buffer(T) & mutex buffer, T elem ) with( buffer ) { 36 if ( count == BufferSize ) wait( empty ); 37 elements[back] = elem; 38 back = ( back + 1 ) % BufferSize; 39 count += 1; 40 signal( full ); 41 } // insert 45 42 46 forall( otype T ) 47 T remove( Buffer(T) & mutex buffer ) with( buffer ) { 48 if ( count == 0 ) wait( full );49 T elem = elements[front];50 front = ( front + 1 ) % BufferSize;51 count -= 1;52 signal( empty );53 return elem;43 T remove( Buffer(T) & mutex buffer ) with( buffer ) { 44 if ( count == 0 ) wait( full ); 45 T elem = elements[front]; 46 front = ( front + 1 ) % BufferSize; 47 count -= 1; 48 signal( empty ); 49 return elem; 50 } // remove 54 51 } 55 52 -
src/tests/concurrent/preempt.c
rf6f0cca3 rff29f08 17 17 #endif 18 18 19 extern void __cfaabi_check_preemption(); 20 19 21 static volatile int counter = 0; 20 22 … … 29 31 void main(worker_t & this) { 30 32 while(counter < N) { 33 __cfaabi_check_preemption(); 31 34 if( (counter % 7) == this.value ) { 35 __cfaabi_check_preemption(); 32 36 int next = __atomic_add_fetch_4(&counter, 1, __ATOMIC_SEQ_CST); 37 __cfaabi_check_preemption(); 33 38 if( (next % 100) == 0 ) printf("%d\n", (int)next); 39 __cfaabi_check_preemption(); 34 40 } 41 __cfaabi_check_preemption(); 35 42 } 36 43 } -
src/tests/concurrent/thread.c
rf6f0cca3 rff29f08 7 7 thread Second { semaphore* lock; }; 8 8 9 void ?{}( First & this, semaphore & lock ) {this.lock = &lock; }10 void ?{}( Second & this, semaphore & lock ) { this.lock = &lock; }9 void ?{}( First & this, semaphore & lock ) { ((thread&)this){"Thread 1"}; this.lock = &lock; } 10 void ?{}( Second & this, semaphore & lock ) { ((thread&)this){"Thread 2"}; this.lock = &lock; } 11 11 12 12 void main(First& this) {
Note:
See TracChangeset
for help on using the changeset viewer.