diff --git a/ASR3.1/TP04 processus recouvrement/a.out b/ASR3.1/TP04 processus recouvrement/a.out new file mode 100755 index 0000000..6186b14 Binary files /dev/null and b/ASR3.1/TP04 processus recouvrement/a.out differ 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