-
Notifications
You must be signed in to change notification settings - Fork 0
/
tipi_simulatore_societa.h
66 lines (52 loc) · 1.53 KB
/
tipi_simulatore_societa.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
59
60
61
62
63
64
65
66
#ifndef __TIPI_SIMULATORE_SOCIETA__
#define __TIPI_SIMULATORE_SOCIETA__
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#define DEBUG printf("Sono arrivato alla linea %d del file %s con PID %i.\n", __LINE__, __FILE__, getpid())
#define ERRNO printf("Error number = %i\n", errno)
#define SHM_A_KEY 1234
#define SHM_B_KEY 1235
#define SHM_DESCRIZIONE_KEY 1243
#define SEM_SINC_GESTORE 1236
#define SEM_SINC_INDIVIDUI 1237
#define SEM_SHM_A 1238
#define SEM_SHM_B 1239
#define SEM_SHM_DESCRIZIONE 1244
#define SEM_AZIONE_A 1245
#define SEM_AZIONE_B 1246
#define SEM_AZIONE 1247
#define MSG_A_B 1240
#define MSG_GESTORE_A 1241
#define MSG_GESTORE_B 1242
#define LUNGHEZZA_NOME 128
typedef enum { FALSE, TRUE } bool;
/**
* La struttura dati utilizzata per rappresentare un individuo
*/
typedef struct {
char tipo;
char nome [LUNGHEZZA_NOME];
unsigned long genoma;
} caratteristiche_individuo;
/**
* La struttura dati utilizzata per la memorizzazione nella shared memory
*/
typedef struct {
bool utilizzata;
pid_t pid;
caratteristiche_individuo caratteristiche;
} rappresentazione_individuo;
/**
* Struttura utilizzata per tracciare i cambiamenti durante la simulazione
*/
typedef struct {
int individui_a_creati;
int individui_b_creati;
caratteristiche_individuo individuo_nome_lungo;
caratteristiche_individuo individuo_genoma_lungo;
int individui_a_attivi;
int individui_b_attivi;
int processi_totali_terminati;
} descrizione_simulazione;
#endif