/* * UthbProducer1and2D.cpp * * Created on: Aug 15, 2012 * Author: rryan */ #include #include #include #include // Uthbook items #include "Uthbook.h" #include "HistogramCreatorFunctions.h" using namespace std; int main(int narg, char *argv[]) { // create shared memory uthCreateSharedMem(); // // create 1D float histogram and data // const char* title2 = "1D Float Histogram"; // int nBin2 = 7; // float xMin2 = 0.0; // float xMax2 = 10.0; // vector myData2 = sort(gaussianDataFloat(-2.0, 12.0, 50)); // //// book 1D float histogram into shared memory // uthBook1Shared(title2, nBin2, xMin2, xMax2); // for (int i = 0; i < myData2.size(); i++) { // uthFillShared(0, myData2.at(i), 0, 1); // } // // uthPrintShared(0); // create 2D float histogram and data const char* title4 = "2D Float Histogram"; int nBinx4 = 10; int nBiny4 = 11; float xMin4 = 1.0; float xMax4 = 11.0; float yMin4 = 15.0; float yMax4 = 25.0; vector > myData2x; for (int i=0;i<(int) (xMax4-xMin4+2);i++) { myData2x.push_back(sort(gaussianDataFloat(14.0,26.0,1000))); } // book 2D float histogram into shared memory uthBook2Shared(title4, nBinx4, xMin4, xMax4, nBiny4, yMin4, yMax4); for (int i = 0; i < myData2x.size(); i++) { // printf("%s:%d\tmyData2x[%i]: %i\n",__FILE__, __LINE__, i, (int) myData2x[i]); for (int j=0;j<(int) myData2x[i].size();j++) { // cout << toString(myDatay) << endl; uthFillShared(0, i, myData2x[i][j], 1); } } uthPrintShared(0); // waits until done cout << "enter letter to quit..." << endl; string dumb; cin >> dumb; /* * int shm_unlink(const char *name) * removes a shared memory object specified by name. If some * process is still using the shared memory segment associated * to name, the segment is not removed until all references * to it have been closed. Commonly, shm_unlink is called * right after a successful shm_create, in order to assure * the memory object will be freed as soon as it's no longer * used. */ // requesting the removal of the shm object -- shm_unlink() if (shm_unlink(shmPath) != 0) { perror("In shm_unlink()"); } }