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

Public Methods | |
| Producer (int n=1, int i=0) | |
| virtual void | run () |
Private Attributes | |
| int | item |
| int | name |
| _uint64 | started |
| double | elapsed |
| double | total |
|
||||||||||||
|
Definition at line 79 of file PCBuffer.cpp. |
|
|
Reimplemented from Basic_PThread. Definition at line 83 of file PCBuffer.cpp. 00084 {
00085 QBColor();
00086 printf( "\nProducer %u started. ", name );
00087 fixprio( 8 );
00088 sched_yield();
00089
00090 for(;;)
00091 {
00092 if ( ++item > STEPS ) break;
00093
00094 register size_t where = item % BBSIZE;
00095
00096 slot[ where ]->P(); // Slot is free ?
00097 sender.P(); // Take write control
00098
00099 started = timer.getCycles();
00100
00101 boundedBuffer.enqueue( item );
00102
00103 QBColor();
00104 printf(
00105 "\nProducer %u produced component %2u in slot %2u. ",
00106 name, item, where
00107 );
00108
00109 elapsed = timer.getElapsed( started );
00110 total += elapsed;
00111
00112 elapsed *= 1000;
00113 printf( "\nProducer %u took %4.2f ms. ", name, elapsed );
00114 fflush( stdout );
00115
00116 sender.V(); // Another sender can have control
00117 message.V(); // One message completed
00118
00119 } // End of infinite loop
00120
00121 QBColor( 12 );
00122 printf( "\nProducer %u terminates. Total time spent %6.2f ms. \n", name, total*1000 );
00123 QBColor();
00124 fflush( stdout );
00125 ++done;
00126 }
|
|
|
Definition at line 44 of file PCBuffer.hpp. |
|
|
Definition at line 41 of file PCBuffer.hpp. |
|
|
Definition at line 42 of file PCBuffer.hpp. |
|
|
Definition at line 43 of file PCBuffer.hpp. |
|
|
Definition at line 45 of file PCBuffer.hpp. |
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001