// g++ -g3 -ggdb -O0 -D_REENTRANT=1 sp-test.cpp -o sp-test.exe -lpthread #include using std::cout; using std::cerr; using std::endl; using std::ostream; #include using std::string; #include using std::vector; #include using std::stringstream; using std::istringstream; using std::ostringstream; #include using boost::shared_ptr; #include #include #include #include #include #if !defined(nullptr_t) # define nullptr NULL #endif #if !defined(byte) typedef unsigned char byte; #endif struct Block { explicit Block() { } virtual ~Block() { } byte block[24]; }; static const unsigned int THREAD_COUNT = 128; static const unsigned int ITERATIONS = 2048; void* WorkerThreadProc(void* param); void Message(ostream& strm, const string& msg); typedef shared_ptr BlockPtr; static const unsigned int SIZE = 128; BlockPtr blocks[SIZE]; int main(int, char**) { srand(0); pthread_t threads[THREAD_COUNT]; // *** Worker Threads *** for(unsigned int i=0; i