From 010fba24e03a0b4e570cd000b55e4f61ce990c1d Mon Sep 17 00:00:00 2001 From: lefevre Date: Mon, 8 Nov 2021 17:46:19 +0100 Subject: [PATCH] tp04 --- ASR3.1/TP04 processus recouvrement/a.out | Bin 0 -> 16248 bytes ASR3.1/TP04 processus recouvrement/ouvrir.c | 47 ++++++++++++++++ ASR3.1/TP04 processus recouvrement/sum.c | 57 ++++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100755 ASR3.1/TP04 processus recouvrement/a.out create mode 100644 ASR3.1/TP04 processus recouvrement/ouvrir.c create mode 100644 ASR3.1/TP04 processus recouvrement/sum.c diff --git a/ASR3.1/TP04 processus recouvrement/a.out b/ASR3.1/TP04 processus recouvrement/a.out new file mode 100755 index 0000000000000000000000000000000000000000..6186b14dcfc0919b22135cf4286c9cdf9f96b028 GIT binary patch literal 16248 zcmeHOU2GKB6~4Q+!9ct=#83wsJf+Z>L|)qjTqh~Xu7Ago0S9bI1!TP5AA7?7WpG!~o))O3t1Ko!74u)F0zg2thzj`K zC>|EeKrfY?RUfbbYAw0uEyi-NGm?e&shT9ILd6SrHmVC43m13$X7 zWbxU+mw7L>x72m0q5LyadPPHAA8g*<5RcTy^<;LWex#+jzInSplk#tq4P(C=;lMG~ zwYy(<$HWwJ?C%ktBHc?mm`Fj}YB(_M=-=yK_460^&V6|Ojgz~dFM0Fy?dDh8(FV^0 zW1?c>8_OXyfH`URt|9ZU)>8xEXLW;AX(hfSUm~1I`TmrE=q^>i8ea)rqoq z8-!55F=cx5SJd%~%muKAMaPkcfJFbLd|_(R;Uv@eZc3}P60I& zhLgEeRtkjY@P(Mavi4Q%hPV)0C}X}b-pwJf?S~kU=z-kvGiok-Dxyx5ZmE-@JLa3F z;QWrlE0&t;z+%cOUWTG!6|X=sZWXUBu+vb~Ep}%7_!-YDTh)nuT99f;{pO2`IRm*cT%VyrYo6o;(%Ma!wc%Wx;=aI*R2=4FB{W{p+otq2x z1#^GzS10Qa0llwh>s=g^Ga5Ln=k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POhLTx-+DN6NhB<1Z2D3Ws|Is5v1zWr8ad7(4d^nUD z7XHX+5}L5kG_0DVQ3L<>U8HDGXGG&6bf8i?ZVJCValZ+FBo}@hlu(zF7tJ3XreQc7 z0bkZE4{JPH9$bdNp@bfWR#OlQe*CflD;OkJ_~Eulz-TYrc>h@e=YQ}hfoHrWHT3^A zBhUY+TH10M@r!WS_k6UFKVtxmY{K&~rkbH(_a7mD#?5R<$j?iryB+>K-(XbOkkILW z0QkSc9FEVQ=e3M{{=8?#+5ZsuqwA>{WPVr5^sjQAQHc7KKZ7<=u;P9l8^@jCca+WdJQKUd?t1?9X@y>g@g^ zK*o(0wvfueevDplw)^w^w1xb+pHBaR4$c^h`_J=0mHfFKw#T;YQbFyLd7+B^opWsV zwcrpL?@INMybq)uI GD*gc?P1k1t literal 0 HcmV?d00001 diff --git a/ASR3.1/TP04 processus recouvrement/ouvrir.c b/ASR3.1/TP04 processus recouvrement/ouvrir.c new file mode 100644 index 0000000..f79d4b3 --- /dev/null +++ b/ASR3.1/TP04 processus recouvrement/ouvrir.c @@ -0,0 +1,47 @@ +#include +#include +#include + + +typedef struct assoc { + char * ext; + char * exe; +} assoc; + + + +int main(int argc, char const *argv[]){ + + + assoc assocs [] = { + {"pdf","/usr/bin/xpdf"}, + {"html","/usr/bin/firefox"}, + {"c","/usr/bin/vim"} + /* etc */ +}; + + + if (argc < 2){ + printf("Usage : %s \n", argv[2]); + return EXIT_FAILURE; + } + + + char * extension = strrchr (argv[1], '.') + 1; // pour récupérer la chaine suivant (+1) + + if (extension == NULL){ + printf ("Pas d'extensions \n"); + } else { + printf ("extention : %s\n", extension); + } + + + for (int i = 0; i < assoc; i++){ + if (strcmp (extension, assocs[i]) == 0){ + printf("ok\n"); + } + } + + + return EXIT_FAILURE; +} \ No newline at end of file diff --git a/ASR3.1/TP04 processus recouvrement/sum.c b/ASR3.1/TP04 processus recouvrement/sum.c new file mode 100644 index 0000000..1d11f52 --- /dev/null +++ b/ASR3.1/TP04 processus recouvrement/sum.c @@ -0,0 +1,57 @@ +#include +#include +#include +#include +#include +#include +#include +static inline double tstamp(void) +{ + struct timespec tv; + clock_gettime(CLOCK_REALTIME, &tv); + return tv.tv_sec + tv.tv_nsec * 1.0e-9; +} +void somme_partielle(long int * sommes,long int n,long int N,long int M) +{ + long int S = 0; + for(long int i = n;i<=N;i+=M) + S+=i; + + //printf("%d = %ld\n",getpid(),S); + sommes[n-1] = S; +} + +int main(int argc, char *argv[]) +{ + long int N, + M, + S=0; + long int * sommes = NULL; + double start,end; + + start = tstamp(); + assert(argc == 3); + N=strtol(argv[1],NULL,0); + M=strtol(argv[2],NULL,0); + + sommes = (long int *) mmap(NULL,M*sizeof(long int), + PROT_WRITE,MAP_ANONYMOUS|MAP_SHARED,-1,0); + + for (long int i = 0;i