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