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 | /*
* Copyright 2021 Jeisson Hidalgo-Cespedes - Universidad de Costa Rica
*/
#ifndef DYNAMIC_SIMULATION_H
#define DYNAMIC_SIMULATION_H
#include <semaphore.h>
#include <time.h>
#include "simulation.h"
#include "queue.h"
typedef struct {
simulation_t* simulation;
data_t* durations; // conditional safe
struct timespec start_time;
queue_t work_queue;
sem_t can_work;
} dynamic_simulation_t;
int dynamic_simulation_init(dynamic_simulation_t* dynamic_simulation
, simulation_t* simulation);
void dynamic_simulation_destroy(dynamic_simulation_t* dynamic_simulation);
int dynamic_simulation_run(dynamic_simulation_t* dynamic_simulation);
size_t calculate_block_start(size_t rank, size_t work_count
, size_t worker_count);
size_t calculate_block_finish(size_t rank, size_t work_count
, size_t worker_count);
#endif // DYNAMIC_SIMULATION_H
|