#include <PCBuffer.hpp>
Inheritance diagram for Consumer::

Public Methods | |
| Consumer (int n=1) | |
| virtual void | run () |
Private Attributes | |
| int | name |
| size_t | slotno |
| _uint64 | started |
| double | elapsed |
| double | total |
Static Private Attributes | |
| int | item = 0 |
|
|
Definition at line 128 of file PCBuffer.cpp. |
|
|
Reimplemented from Basic_PThread. Definition at line 132 of file PCBuffer.cpp. 00133 {
00134 printf( "\nConsumer %u started. ", name );
00135 fixprio( 8 );
00136 sched_yield();
00137
00138 while( item < STEPS )
00139 {
00140 message.P(); // Is there a message ?
00141
00142 if ( item > STEPS ) break; // Program's done
00143
00144 receiver.P(); // Receiver take control
00145
00146 started = timer.getCycles();
00147
00148 ++item;
00149
00150 char msg = boundedBuffer.dequeue(); // Consumed
00151
00152 register size_t where = item % BBSIZE;
00153
00154 printf(
00155 "\nConsumer %u took message %2u from slot %2u in step %2u. ",
00156 name, msg, where, item
00157 );
00158 fflush( stdout );
00159
00160 elapsed = timer.getElapsed( started );
00161 total += elapsed;
00162
00163 elapsed *= 1000;
00164 printf( "\nConsumer %u took %4.2f ms. ", name, elapsed );
00165 fflush( stdout );
00166
00167 slot[ where ]->V(); // Free the slot
00168 receiver.V(); // Release control
00169 sched_yield();
00170
00171 } // End of infinite loop
00172
00173 QBColor( 12 );
00174 printf( "\nConsumer %u terminates. Total time spent %6.2f ms. \n", name, total*1000 );
00175 QBColor();
00176 fflush( stdout );
00177
00178 if ( item == STEPS ) {
00179 ++item;
00180 message.V(); // Ask the other one to quit, if last step
00181 }
00182
00183 ++done;
00184 }
|
|
|
Definition at line 60 of file PCBuffer.hpp. |
|
|
Definition at line 68 of file PCBuffer.hpp. |
|
|
Definition at line 56 of file PCBuffer.hpp. |
|
|
Definition at line 58 of file PCBuffer.hpp. |
|
|
Definition at line 59 of file PCBuffer.hpp. |
|
|
Definition at line 61 of file PCBuffer.hpp. |
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001