| 10 |
#include <stdio.h> |
#include <stdio.h> |
| 11 |
#include <stdlib.h> |
#include <stdlib.h> |
| 12 |
#include <string.h> |
#include <string.h> |
| 13 |
|
#include <time.h> |
| 14 |
#include <unistd.h> |
#include <unistd.h> |
| 15 |
|
|
| 16 |
#if __STDC_VERSION__ >= 201112L |
#if __STDC_VERSION__ >= 201112L |
| 42 |
atexit(visResultater); |
atexit(visResultater); |
| 43 |
signal(SIGINT, signalhandler); |
signal(SIGINT, signalhandler); |
| 44 |
|
|
| 45 |
|
#ifdef __FreeBSD__ |
| 46 |
srandomdev(); |
srandomdev(); |
| 47 |
|
#else |
| 48 |
|
srandom((unsigned int)time(NULL)); |
| 49 |
|
#endif |
| 50 |
|
|
| 51 |
memset((void *)&antallBesok, 0, sizeof(antallBesok)); |
memset((void *)&antallBesok, 0, sizeof(antallBesok)); |
| 52 |
brytere[0] = random() & 1; |
brytere[0] = random() & 1; |
| 69 |
fprintf(stderr, |
fprintf(stderr, |
| 70 |
"%s: pthread_create(&tid, NULL, livstidsfange, (void *)%2zu) = %s (%d)\n", |
"%s: pthread_create(&tid, NULL, livstidsfange, (void *)%2zu) = %s (%d)\n", |
| 71 |
argv[0], i, strerror(errno), errno); |
argv[0], i, strerror(errno), errno); |
| 72 |
exit(1); |
_exit(1); |
| 73 |
} // if |
} // if |
| 74 |
} // for |
} // for |
| 75 |
|
|
| 125 |
} // if |
} // if |
| 126 |
else { |
else { |
| 127 |
brytere[0] = !brytere[0]; |
brytere[0] = !brytere[0]; |
| 128 |
printf("livstidsfange %2zu vipper %s bryter 1\n", i + 1, brytere[0] == 1U ? "opp" : "ned"); |
printf("livstidsfange %2zu vipper %s bryter 1\n", i + 1, brytere[0] == true ? "opp" : "ned"); |
| 129 |
|
|
| 130 |
if (forrigeGangErGyldig == true && forrigeGang == false) { |
if (forrigeGangErGyldig == true && forrigeGang == false) { |
| 131 |
antallLivstidsfanger++; |
antallLivstidsfanger++; |