Changeset 7f6a7c9 for tests/io/comp_fair.cfa
- Timestamp:
- Sep 21, 2022, 11:02:15 AM (3 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation
- Children:
- 95dab9e
- Parents:
- 428adbc (diff), 0bd46fd (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. - File:
-
- 1 edited
-
tests/io/comp_fair.cfa (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/io/comp_fair.cfa
r428adbc r7f6a7c9 27 27 28 28 struct { 29 barrier & bar;30 int pipe[2];29 barrier & bar; 30 int pipe[2]; 31 31 32 32 } globals; … … 65 65 thread Reader {}; 66 66 void main(Reader & this) { 67 bool do_read = has_user_level_blocking( (fptr_t)async_read ); 67 char thrash[1]; 68 bool do_read = has_user_level_blocking( (fptr_t)async_read ); 68 69 69 for(TIMES) { 70 io_future_t f; 71 if ( do_read ) { 72 char thrash[1]; 73 async_read(f, globals.pipe[0], thrash, 1, 0); 74 } else { 75 fulfil(f, 0); // If we don't have user-level blocking just play along 76 } 70 for(TIMES) { 71 io_future_t f; 72 if ( do_read ) { 73 async_read(f, globals.pipe[0], thrash, 1, 0); 74 } else { 75 fulfil(f, 0); // If we don't have user-level blocking just play along 76 } 77 77 78 block( globals.bar );78 block( globals.bar ); 79 79 80 80 yield( prng( this, 15 ) ); 81 81 82 unsigned i = __atomic_add_fetch( &counter, 1, __ATOMIC_SEQ_CST );82 unsigned i = __atomic_add_fetch( &counter, 1, __ATOMIC_SEQ_CST ); 83 83 if(0 == (i % 100)) sout | i; 84 84 85 wait( f );85 wait( f ); 86 86 87 if(f.result < 0)88 abort | "Read error" | -f.result | ":" | strerror(-f.result);87 if(f.result < 0) 88 abort | "Read error" | -f.result | ":" | strerror(-f.result); 89 89 90 block( globals.bar );91 }90 block( globals.bar ); 91 } 92 92 } 93 93 … … 97 97 thread Writer {}; 98 98 void main(Writer & this) { 99 for(TIMES) {100 block( globals.bar );99 for(TIMES) { 100 block( globals.bar ); 101 101 102 sleep( 1`us );102 sleep( 1`us ); 103 103 104 char buf[1] = { '+' };105 int ret = write( globals.pipe[1], buf, 1 );106 if(ret < 0)107 abort | "Write error" | errno | ":" | strerror(errno);104 char buf[1] = { '+' }; 105 int ret = write( globals.pipe[1], buf, 1 ); 106 if(ret < 0) 107 abort | "Write error" | errno | ":" | strerror(errno); 108 108 109 block( globals.bar );110 }109 block( globals.bar ); 110 } 111 111 } 112 112 … … 122 122 123 123 int main() { 124 barrier bar = { 2 };125 &globals.bar = &bar;126 int ret = pipe(globals.pipe);127 if(ret != 0)128 abort | "Pipe error" | errno | ":" | strerror(errno);124 barrier bar = { 2 }; 125 &globals.bar = &bar; 126 int ret = pipe(globals.pipe); 127 if(ret != 0) 128 abort | "Pipe error" | errno | ":" | strerror(errno); 129 129 130 130 processor p; … … 134 134 Spinner s; 135 135 Reader ior; 136 Writer iow;136 Writer iow; 137 137 } 138 138 sout | "done";
Note:
See TracChangeset
for help on using the changeset viewer.