From 52bded653488ac579a948071f8bddf76896df18f Mon Sep 17 00:00:00 2001 From: "quentin.perret" Date: Mon, 13 Jun 2022 17:11:16 +0200 Subject: [PATCH] almost debug second thread --- Code-C/getArray.c | 13 +++---------- Code-C/initialParameters.h | 2 +- Code-C/main | Bin 24632 -> 24600 bytes Code-C/main.c | 23 ++++++++++++----------- Code-C/power.c | 1 + Code-C/simulateFlux.c | 4 ++-- 6 files changed, 19 insertions(+), 24 deletions(-) diff --git a/Code-C/getArray.c b/Code-C/getArray.c index 8b2087c..7389042 100644 --- a/Code-C/getArray.c +++ b/Code-C/getArray.c @@ -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; } } \ No newline at end of file diff --git a/Code-C/initialParameters.h b/Code-C/initialParameters.h index 9a2e2f4..ba11617 100644 --- a/Code-C/initialParameters.h +++ b/Code-C/initialParameters.h @@ -1,7 +1,7 @@ #include #include "queue.h" -extern bool rawDataWriteFlag , stopFlag; +extern bool rawDataWriteFlag; extern int nRow; extern int nCol; extern double freqEch; diff --git a/Code-C/main b/Code-C/main index fdb4b168bbc5f9156fe034b1d95e48e07e446b48..31dc9ce46809548b4d233859cd21ed2c5066e57b 100755 GIT binary patch delta 3731 zcmZ8k4Nz3q6~1@%`G>lTLY9ZXf{37yQ36O*6dgq$3L-T$qTo+Q4Q&`JjwICyB0-7U z6>H|isMHuu)3Iqyh7QpvCJJVvXpLh2ijAgdz&!sFq*gG&yngrHi$(9u-tWHiedoM$ z&;8lm!*zUT9p4ticm92poA=+`kJ)WArSs$dF;B^-he*2PXuz+w?-aC50{s{xt z(%VJfEu4L@#&kUGY5I9Jx0+i7Bu z5%Pt*r)_elWwkr!r`5GPU4xF$n?YalS}NA31^WGHS-zaN4PRQP_bUSthd!_@YKsbd z%5@x3nOV_cS%x>Q(M2CKUz8rM@iK@sd3x*`ok+!9BdCyrfCKAy23#NYyr}suHS1x)dDD)2SnPS?U)s z)EZLL8DPKX0l?h-UprEpjP#yRrAyUkQq?L{FHqI67`;TWzm)8&l6_sUN%ZxwNIhGy zOC_5l*#&~VPwtQiJzB7Zk{u@5aKRp@?2zHHU3VX^+6|Dk>!kkNP&?oA0CP3%37HbS zPq42@wpg<31gqbr!mtq(5*jh6y&WO3Ok$C)(X7x|Jyls18dN zmnvPT{!Gt@y^&Jt&zK;YdHas-)ydX`*}40s^fSCCv15D>C1)VHIS{7JFqwIOn(pB| zmeRtTQ}((rCvRGlQK`KvhmAgM)L6zaqxnDE1#UppCNaZ3KZxg#@z@|9|3FJ4a!ZpQ z8XJXiqfC`cx==Ifr4YR;qPU)!4(d z-&UnnXLwtT%H_=qr_%W04g456A~X3|nj0C!XVR}DBa@yTET(lz7Ux_rjK-$A;?agr6KBlu*4qd17`L4#aX6b-$cl`L zn<%7}NVhVl(Wso&PsT^-z2{92IG?5?fV~uLG1^N>5p>^ zZ>v#$E8OswK&gEVGn_haF78fXthjJ6kM1!0u8XVIrJWvKDzZ$fg@-TDCHg^qgg0i_ zeOaHBxd!w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|`w}GX7!tT=peEZLxa$RnF2MQY^0z`~L4uzP4jY4#g}(;yO*CcZ z++jD-YJpPn)LKU9Jig3Q9Ws+L*B~`{vgZ~CN@wYx=2gKIJ3mSKEzO>vhIH4?zkrmz zDw`#lZjh6tWLmVqK%3>5t=UP^73M?whDr+z(i65flLQBBjVsvUK>0Zb62e%d5OsEj&>W25MHl9KptD{_#-4&LXuri5s*_h-Q?~Ck*lyC-lz}x&DUmGg;X0iu^4U z_8FR;(C>4@Qe>gAib(xJXqF250y8%(7WOst0rs^;u#JLUFK*m#7%Met^%1RZ)AX02 zXIUJ46ThOJ3k}(1DBtfp;-t2Uxk80KIF=hy#VpCfeoEZjJfY8^)}g?*x7Ap8kErn&&5T#fkWP0Kd-E4jVEI937w}s zzatPY+p*=7hyC~;@q^`QVNI#rSsz+F=>@X`r1kWz!n9$1D>^`r6{blC=!3$f{{tpE BvNr$# diff --git a/Code-C/main.c b/Code-C/main.c index a6c84b8..bccc3f9 100644 --- a/Code-C/main.c +++ b/Code-C/main.c @@ -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); } \ No newline at end of file diff --git a/Code-C/power.c b/Code-C/power.c index 52153ec..4b58106 100644 --- a/Code-C/power.c +++ b/Code-C/power.c @@ -3,6 +3,7 @@ #include "fileGestion.h" #include "initialParameters.h" #include "queue.h" +#include void powerCalculation(long **p, double powerArray[] , int N, int M , double period , double invTimeBandwidth){ for(int i = 0; i < M-1; i++){ diff --git a/Code-C/simulateFlux.c b/Code-C/simulateFlux.c index 57f3596..28e1980 100644 --- a/Code-C/simulateFlux.c +++ b/Code-C/simulateFlux.c @@ -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; }