feat: update tests
This commit is contained in:
parent
5352d16c8f
commit
22fb8fd863
@ -32,7 +32,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (argc < 2) {
|
||||
printf("argument manquant: nombre de threads\n");
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
nb = atoi(argv[1]);
|
||||
|
@ -40,7 +40,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (argc < 2) {
|
||||
printf("argument manquant: nombre de threads\n");
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
nb = atoi(argv[1]);
|
||||
|
@ -31,7 +31,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (argc < 2) {
|
||||
printf("argument manquant: nombre de threads\n");
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
nb = atoi(argv[1]);
|
||||
@ -39,7 +39,7 @@ int main(int argc, char *argv[])
|
||||
th = malloc(nb*sizeof(*th));
|
||||
if (!th) {
|
||||
perror("malloc");
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
gettimeofday(&tv1, NULL);
|
||||
|
@ -36,7 +36,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (argc < 3) {
|
||||
printf("arguments manquants: nombre de threads, puis nombre de yield\n");
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
nbth = atoi(argv[1]);
|
||||
|
@ -36,8 +36,9 @@ static void * thfunc(void *_nbth)
|
||||
struct timeval tv1, tv2;
|
||||
unsigned long us;
|
||||
gettimeofday(&tv1, NULL);
|
||||
for(i=0; i<nbyield; i++)
|
||||
for(i=0; i<nbyield; i++){
|
||||
thread_yield();
|
||||
}
|
||||
gettimeofday(&tv2, NULL);
|
||||
us = (tv2.tv_sec-tv1.tv_sec)*1000000+(tv2.tv_usec-tv1.tv_usec);
|
||||
printf("%d yield avec plein de threads dans join: %ld us\n",
|
||||
@ -52,7 +53,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 3) {
|
||||
printf("arguments manquants: nombre de threads, puis nombre de yield\n");
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
nbthrd = atoi(argv[1]);
|
||||
|
@ -55,7 +55,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (argc < 3) {
|
||||
printf("arguments manquants: nombre de threads, puis nombre de yield\n");
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
nbthread = atoi(argv[1]);
|
||||
|
@ -69,7 +69,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (argc < 2) {
|
||||
printf("argument manquant: entier x pour lequel calculer fibonacci(x)\n");
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
value = atoi(argv[1]);
|
||||
|
@ -53,20 +53,20 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (argc < 2) {
|
||||
printf("argument manquant: nombre de threads\n");
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
nb = atoi(argv[1]);
|
||||
|
||||
if (thread_mutex_init(&lock) != 0) {
|
||||
fprintf(stderr, "thread_mutex_init failed\n");
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
th = malloc(nb*sizeof(*th));
|
||||
if (!th) {
|
||||
perror("malloc");
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
gettimeofday(&tv1, NULL);
|
||||
|
@ -60,7 +60,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (argc < 2) {
|
||||
printf("argument manquant: nombre de threads\n");
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
nb = atoi(argv[1]);
|
||||
@ -69,14 +69,14 @@ int main(int argc, char *argv[])
|
||||
for(i=0; i<NB_MUTEX; i++) {
|
||||
if (thread_mutex_init(&lock[i]) != 0) {
|
||||
fprintf(stderr, "thread_mutex_init(lock[%d]) failed\n", i);
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
th = malloc(nbthrd*sizeof(*th));
|
||||
if (!th) {
|
||||
perror("malloc");
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
gettimeofday(&tv1, NULL);
|
||||
|
@ -31,7 +31,7 @@ static void * thfunc(void *dummy __attribute__((unused)))
|
||||
|
||||
/* on incremente progressivement fini jusque 5 pour debloquer le main */
|
||||
for(i=0; i<5; i++) {
|
||||
printf(" le fils yield sans le mutex et incrémente le compteur %u\n", fini);
|
||||
fprintf(stderr, " le fils yield sans le mutex et incrémente le compteur %u\n", fini);
|
||||
thread_yield();
|
||||
fini++;
|
||||
}
|
||||
@ -39,7 +39,7 @@ static void * thfunc(void *dummy __attribute__((unused)))
|
||||
/* on attend que main remette à 0 */
|
||||
thread_mutex_lock(&lock);
|
||||
while (fini != 0) {
|
||||
printf(" le fils yield avec le mutex en attendant que le compteur %u soit 0\n", fini);
|
||||
fprintf(stderr, " le fils yield avec le mutex en attendant que le compteur %u soit 0\n", fini);
|
||||
thread_yield();
|
||||
}
|
||||
thread_mutex_unlock(&lock);
|
||||
@ -55,7 +55,7 @@ int main(void)
|
||||
/* on cree le mutex et le thread */
|
||||
if (thread_mutex_init(&lock) != 0) {
|
||||
fprintf(stderr, "thread_mutex_init failed\n");
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
err = thread_create(&th, thfunc, NULL);
|
||||
assert(!err);
|
||||
@ -63,14 +63,14 @@ int main(void)
|
||||
/* on prend le lock puis on attend que l'autre mette fini = 5 */
|
||||
thread_mutex_lock(&lock);
|
||||
while (fini != 5) {
|
||||
printf("le père yield avec le mutex en attendant que le compteur %u soit 5\n", fini);
|
||||
fprintf(stderr, "le père yield avec le mutex en attendant que le compteur %u soit 5\n", fini);
|
||||
thread_yield();
|
||||
}
|
||||
thread_mutex_unlock(&lock);
|
||||
|
||||
/* on baisse progressivement jusque 0 */
|
||||
for(i=0; i<5; i++) {
|
||||
printf("le père yield sans le mutex et décrémente le compteur %u\n", fini);
|
||||
fprintf(stderr, "le père yield sans le mutex et décrémente le compteur %u\n", fini);
|
||||
thread_yield();
|
||||
fini--;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ int main(void)
|
||||
/* on cree le mutex et le thread */
|
||||
if (thread_mutex_init(&lock) != 0) {
|
||||
fprintf(stderr, "thread_mutex_init failed\n");
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
err = thread_create(&th, thfunc, NULL);
|
||||
assert(!err);
|
||||
|
@ -54,20 +54,20 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (argc < 2) {
|
||||
printf("argument manquant: nombre de threads\n");
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
nb = atoi(argv[1]);
|
||||
th = malloc(nb * sizeof(*th));
|
||||
if (!th) {
|
||||
perror("malloc(th)");
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
values = calloc( nb+1, sizeof(long) );
|
||||
if (!values) {
|
||||
perror("malloc(values)");
|
||||
return -1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
gettimeofday(&tv1, NULL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user