-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsharedData.h
34 lines (30 loc) · 1.1 KB
/
sharedData.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
#include <pthread.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cctype>
using namespace std;
// Main structure containing all shared data
struct ProgramData {
vector<string> files; // List of input files
map<string, set<int>> reducer_data; // Global data for the Reducer
pthread_mutex_t reducer_mutex; // Mutex for protecting reducer data
pthread_mutex_t mapper_mutex; // Mutex for protecting mapper data
pthread_barrier_t barrier; // Barrier to synchronize threads
};
// Structure for thread arguments
struct ThreadArgs {
int id; // Thread ID
vector<int> assigned_files; // Files assigned to this thread
ProgramData* program_data; // Pointer to the shared ProgramData
};
// Structure for Reducer thread arguments
struct ReducerArgs {
int id; // Reducer ID
int num_reducers; // Total number of reducers
ProgramData* program_data; // Pointer to the shared ProgramData
};