almost debug second thread
This commit is contained in:
parent
bfe730e0ba
commit
52bded6534
|
@ -15,27 +15,23 @@ long **get(int N, int M) /* Allocate the array */
|
|||
|
||||
void fillArrayWithRawData(char *rawDataFileName,long** p, int N, int M) {
|
||||
int i, j;
|
||||
|
||||
char *buffer;
|
||||
size_t bufsize = 200;
|
||||
buffer = (char *)malloc(bufsize * sizeof(char));
|
||||
char* token;
|
||||
|
||||
FILE *f = fopen(rawDataFileName,"r");
|
||||
|
||||
for(i = 0 ; i < N ; i++){
|
||||
if (!getline(&buffer, &bufsize, f)) break; // condition d'arret de la boucle si fichier fini
|
||||
//printf("buffer : %s token : ",buffer);
|
||||
j = 0;
|
||||
while((token = strsep(&buffer,",")) != NULL){ // séparation valeur par virgule initiale : csv
|
||||
//printf(token);
|
||||
p[i][j] = atoi(token);
|
||||
//printf("%d,", p[i][j]);
|
||||
//printf("%d, " , p[i][j]);
|
||||
j++;
|
||||
}
|
||||
//printf("\n\n");
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief print all the element of a bidimensionnal array p of shape : N x M
|
||||
|
@ -76,14 +72,11 @@ long **getRawDataArray(char* rawDataFileName , int N , int M){
|
|||
long **p;
|
||||
p = get(N, M);
|
||||
fillArrayWithRawData(rawDataFileName,p ,N, M);
|
||||
//printf("before test\n");
|
||||
if(checkArrayFullyFill(p,N,M)==0){
|
||||
//printf("after test 0\n");
|
||||
if(checkArrayFullyFill(p,N,M)){
|
||||
clearRawData(N);
|
||||
return p;
|
||||
}
|
||||
else{
|
||||
//printf("after test 1\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
#include <stdbool.h>
|
||||
#include "queue.h"
|
||||
|
||||
extern bool rawDataWriteFlag , stopFlag;
|
||||
extern bool rawDataWriteFlag;
|
||||
extern int nRow;
|
||||
extern int nCol;
|
||||
extern double freqEch;
|
||||
|
|
BIN
Code-C/main
BIN
Code-C/main
Binary file not shown.
|
@ -5,7 +5,7 @@
|
|||
#include "initialParameters.h"
|
||||
#include "queue.h"
|
||||
|
||||
bool rawDataWriteFlag = 0, stopFlag = 0;
|
||||
bool rawDataWriteFlag;
|
||||
int nRow = 100000;
|
||||
int nCol = 9;
|
||||
double freqEch = 250;
|
||||
|
@ -22,20 +22,21 @@ double period = 0;
|
|||
double invTimeBandWidth = 0;
|
||||
|
||||
void *threadCalcul(void *vargp){
|
||||
printf("start thread calcul\n");
|
||||
Pqueue rawDataQueue = firstRawDataQueue;
|
||||
while(queueGetNextE(rawDataQueue) != NULL){
|
||||
printf("wile calcul\n");
|
||||
//pthread_mutex_lock(&mutex);
|
||||
power(queueGetTabChar(rawDataQueue),nRow,nCol,period,invTimeBandWidth);
|
||||
/*remove(queueGetTabChar(rawDataQueue));
|
||||
rawDataQueue = queueRmFrstE(rawDataQueue);*/
|
||||
|
||||
//pthread_mutex_unlock(&mutex);
|
||||
while(rawDataWriteFlag){
|
||||
while(queueGetNextE(rawDataQueue) != NULL){
|
||||
char* fileName = queueGetTabChar(rawDataQueue);
|
||||
//queuePrintE(rawDataQueue);
|
||||
printf("%s\n",fileName);
|
||||
power(fileName,nRow,nCol,period,invTimeBandWidth);
|
||||
/*remove(queueGetTabChar(rawDataQueue));
|
||||
rawDataQueue = queueRmFrstE(rawDataQueue);*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc , char** argv){
|
||||
rawDataWriteFlag = true;
|
||||
|
||||
period = 1 / freqEch;
|
||||
invTimeBandWidth = 1 /(nRow * period);
|
||||
|
@ -45,7 +46,7 @@ int main(int argc , char** argv){
|
|||
pthread_create(&rawData , NULL, simulateFlux, (void *)&rawData);
|
||||
|
||||
pthread_t calcul;
|
||||
//pthread_create(&calcul , NULL, threadCalcul, (void *)&calcul);
|
||||
pthread_create(&calcul , NULL, threadCalcul, (void *)&calcul);
|
||||
|
||||
pthread_exit(NULL);
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
#include "fileGestion.h"
|
||||
#include "initialParameters.h"
|
||||
#include "queue.h"
|
||||
#include <assert.h>
|
||||
|
||||
void powerCalculation(long **p, double powerArray[] , int N, int M , double period , double invTimeBandwidth){
|
||||
for(int i = 0; i < M-1; i++){
|
||||
|
|
|
@ -114,7 +114,6 @@ bool writeOneRawData(FILE *rawDataFile){
|
|||
}
|
||||
|
||||
void *simulateFlux(void *vargp){
|
||||
printf("start thread simul\n");
|
||||
|
||||
char *fileName = createNewRawDataFileName();
|
||||
FILE *rawDataFile = fopen(fileName,"w+");
|
||||
|
@ -131,5 +130,6 @@ void *simulateFlux(void *vargp){
|
|||
FILE *rawDataFile = fopen(fileName,"w+");
|
||||
}
|
||||
}
|
||||
queuePrintWholeQ(firstRawDataQueue);
|
||||
//queuePrintWholeQ(firstRawDataQueue);
|
||||
rawDataWriteFlag = false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue