-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.h
58 lines (46 loc) · 1.23 KB
/
header.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Autor: Maciej Makówka
// POSIX
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <signal.h>
#include <stddef.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <semaphore.h>
#include <sys/types.h>
#include <unistd.h>
#include <time.h>
// moze bedzie potrzebne
#include <mqueue.h> // funkcja zwiazane z posixowymi kolejkami komunikatow
#include <sys/mman.h> // posixowa pamiec wspolna
//#include <pthread.h>
#include <pthread.h>
#define LICZBA_TOROW 10
#define EXPRESS_PRIOR 1
#define TOWAROWY_PRIOR 2
#define ZWYKLY_PRIOR 3
#define NATEZENIE 10
#define DLUGOSC_TUNELU 100
#define EXPRESS_V 20 // max predkosc ekspresu w tunelu
#define TOWAR_V 5 // max predkosc towarowego w tunelu
#define ZWYKLY_V 10 // max predkosc zwyklego w tunelu
#define GEN_TIME 8
struct node { // kazdy tor potrzebuje swojej kolejki...
pid_t pociagID;
int priorytet;
time_t czas;
struct node *ptr;
};
struct tory {
struct node *front[LICZBA_TOROW];
struct node *rear[LICZBA_TOROW];
int ilePociagowNaTorze[LICZBA_TOROW];
};
struct struktura_oczekujacych {
int priorytet[LICZBA_TOROW];
time_t czas[LICZBA_TOROW];
pid_t front[LICZBA_TOROW];
sem_t semaphore[LICZBA_TOROW];
};