5 |
|
|
6 |
#if __STDC_VERSION__ < 199901L |
#if __STDC_VERSION__ < 199901L |
7 |
#error det er tvilsomt om du får kompilert denne kildekoden med så gammel C-kompilator |
#error det er tvilsomt om du får kompilert denne kildekoden med så gammel C-kompilator |
8 |
#endif |
#endif |
9 |
|
|
10 |
#include <errno.h> |
#include <errno.h> |
11 |
#include <pthread.h> |
#include <pthread.h> |
12 |
#include <signal.h> |
#include <signal.h> |
13 |
#include <stdbool.h> |
#include <stdbool.h> |
14 |
#include <stdio.h> |
#include <stdio.h> |
15 |
#include <stdlib.h> |
#include <stdlib.h> |
16 |
#include <string.h> |
#include <string.h> |
17 |
#include <time.h> |
#include <time.h> |
18 |
#include <unistd.h> |
#include <unistd.h> |
19 |
|
|
20 |
|
#if _POSIX_THREADS < 200112L |
21 |
|
#error her mangler det støtte for POSIX Threads anno 2001 |
22 |
|
#endif |
23 |
|
|
24 |
#if __STDC_VERSION__ >= 201112L |
#if __STDC_VERSION__ >= 201112L |
25 |
#include <stdnoreturn.h> |
#include <stdnoreturn.h> |
26 |
#else |
#else |
27 |
#define noreturn |
#define noreturn |
28 |
#endif |
#endif |
29 |
|
|
30 |
#define ANTALL_LIVSTIDSFANGER 19U |
#define ANTALL_LIVSTIDSFANGER 19U |
31 |
|
|
32 |
static unsigned antallBesok[ANTALL_LIVSTIDSFANGER]; |
static unsigned antallBesok[ANTALL_LIVSTIDSFANGER]; |
33 |
|
|
34 |
static size_t tellendeLivstidsfange; |
static size_t tellendeLivstidsfange; |
35 |
static unsigned antallLivstidsfanger; |
static unsigned antallLivstidsfanger; |
36 |
|
|
37 |
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; |
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; |
38 |
static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; |
static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; |