refactoring and reducing overhead

This commit is contained in:
Dhanya Maliakal 2015-11-13 17:55:11 +01:00
parent 53f11c499d
commit 113e522399

View File

@ -856,7 +856,6 @@ int UDPStandardImplementation::startReceiver(char *c){
for(int i=0;i<numberofListeningThreads;i++) sem_post(&listenSemaphore[i]); for(int i=0;i<numberofListeningThreads;i++) sem_post(&listenSemaphore[i]);
for(int i=0; i < numberofWriterThreads; i++) sem_post(&writerSemaphore[i]); for(int i=0; i < numberofWriterThreads; i++) sem_post(&writerSemaphore[i]);
//usleep(5000000);
cout << "Receiver Started" << endl; cout << "Receiver Started" << endl;
cout << "Status: " << runStatusType(status) << endl; cout << "Status: " << runStatusType(status) << endl;
@ -927,13 +926,28 @@ void UDPStandardImplementation::startReadout(){
FILE_LOG(logDEBUG) << "Info: Transmitting last data"; FILE_LOG(logDEBUG) << "Info: Transmitting last data";
if(status == RUNNING){ if(status == RUNNING){
//wait for all packets
uint64_t prev = totalPacketsCaught; //check if all packets got
usleep(50000); int totalP = 0,prev,i;
while(prev!=totalPacketsCaught){ for(i=0; i<numberofListeningThreads; ++i){
prev=totalPacketsCaught; totalP += totalListeningFrameCount[i];
usleep(50000);
} }
//wait for all packets
if(totalP!=numberOfFrames*packetsPerFrame){
prev = -1;
//wait as long as there is change from prev totalP
while(prev != totalP){
cprintf(MAGENTA,"waiting for all packets\n");
usleep(1000);/* Need to find optimal time (exposure time and acquisition period) **/
prev = totalP;
totalP=0;
for(i=0; i<numberofListeningThreads; ++i){
totalP += totalListeningFrameCount[i];
}
}
}else cprintf(MAGENTA,"Got all packets without waiting\n");
//set status //set status
pthread_mutex_lock(&statusMutex); pthread_mutex_lock(&statusMutex);