Skip to content
Snippets Groups Projects
Commit cc90f8a8 authored by Alexandre Abadie's avatar Alexandre Abadie
Browse files

tests/pthread: small improvements

parent 5ce13b35
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,9 @@
#include "pthread.h"
#define FACTORIAL_PARAM (6U)
#define FACTORIAL_EXPECTED (720U)
void *run(void *parameter) {
size_t n = (size_t) parameter;
size_t factorial = 1;
......@@ -45,14 +48,21 @@ int main(void) {
pthread_t th_id;
pthread_attr_t th_attr;
size_t arg = 6;
printf("main parameter = %u\n", (unsigned int) arg);
size_t arg = FACTORIAL_PARAM;
printf("main: parameter = %u\n", (unsigned int) arg);
pthread_attr_init(&th_attr);
pthread_create(&th_id, &th_attr, run, (void *) arg);
size_t res;
pthread_join(th_id, (void **) &res);
printf("main: factorial = %u\n", (unsigned int) res);
puts("main: finished");
if (res == FACTORIAL_EXPECTED) {
puts("SUCCESS");
}
else {
puts("FAILURE");
}
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment