-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutils.h
More file actions
64 lines (51 loc) · 1.42 KB
/
Copy pathutils.h
File metadata and controls
64 lines (51 loc) · 1.42 KB
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
#ifndef UTILS_H
#define UTILS_H
#include <pthread.h>
#define BUF_CAP 64
typedef struct {
int numero_cuenta;
char titular[50];
float saldo;
int bloqueado;
} Cuenta;
typedef enum { P_BAJA = 0, P_MEDIA = 1, P_ALTA = 2 } Prioridad;
typedef struct {
Prioridad prio;
Cuenta snapshot;
} Operacion;
typedef struct {
Operacion ops[BUF_CAP];
int n;
} BufferPrioridad;
typedef struct {
Cuenta cuentas[100];
int num_cuentas;
pthread_mutex_t mutex;
BufferPrioridad buffer;
} TablaCuentas;
typedef struct {
int limite_retiro;
int limite_transferencia;
int umbral_retiros;
int umbral_transferencias;
int num_hilos;
char archivo_cuentas[50];
char archivo_log[50];
} Config;
/* Memoria */
int crear_shm();
TablaCuentas* adjuntar_shm(int shm_id);
void liberar_shm(void *ptr, int shm_id);
void inicializar_mutex_proceso_compartido(pthread_mutex_t *mutex);
void destruir_mutex(pthread_mutex_t *mutex);
/* Ficheros */
Config leer_config(const char *ruta);
int cargar_cuentas(const char *ruta, Cuenta *cuentas);
void volcar_cuentas(const char *ruta, Cuenta *cuentas, int n);
void append_log(const char *ruta_log, const char *linea);
void log_transaccion_individual(int cuenta, const char *linea);
void obtener_timestamp(char *dst, size_t n);
/* Entrada/Salida */
void buffer_push(BufferPrioridad *b, const Cuenta *cta, Prioridad prio);
void *gestionar_entrada_salida(void *arg);
#endif