Changeset c63f470
- Timestamp:
- Dec 18, 2022, 12:24:50 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- cbd1ba8
- Parents:
- fd6e3a4
- Location:
- tests/concurrent/pthread
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/pthread/.expect/bounded_buffer.txt
rfd6e3a4 rc63f470 1 producer total value is 2 34262 consumer total value is 2 34261 producer total value is 24150 2 consumer total value is 24150 -
tests/concurrent/pthread/bounded_buffer.cfa
rfd6e3a4 rc63f470 63 63 64 64 void *producer( void *arg ) { 65 66 const int NoOfItems = rand() % 40;65 Buffer(int) &buf = *(Buffer(int)*)arg; 66 const int NoOfItems = prng(*active_thread(), 40); 67 67 int item; 68 68 for ( int i = 1; i <= NoOfItems; i += 1 ) { // produce a bunch of items 69 item = rand() % 100 + 1;// produce a random number69 item = prng(*active_thread(), 1, 101); // produce a random number 70 70 //sout | "Producer:" | pthread_self() | " value:" | item; 71 71 insert( buf,item ); // insert element into queue … … 101 101 pthread_mutex_init(&consumer_cnt_lock, NULL); 102 102 // parallelism 103 s random( 1003 );103 set_seed( 1003 ); 104 104 105 105 processor p[5];
Note: See TracChangeset
for help on using the changeset viewer.