-
Notifications
You must be signed in to change notification settings - Fork 0
/
wc_map_reduce.h
54 lines (40 loc) · 945 Bytes
/
wc_map_reduce.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
// Thomas Stitt - CMPSC 473- Project 3 - 4/5/15
#include <pthread.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include "wc_dict.h"
#define NO_MORE_WORDS -1
int b;
char* file_buffer;
typedef struct wc_node {
char* word;
int count;
struct wc_node* next;
} wc_node;
typedef struct queue {
wc_node* head;
wc_node* tail;
int count;
} queue;
typedef struct reader_args {
char* start_addr;
int length;
pthread_mutex_t* lock;
pthread_cond_t* cond;
queue* read_add_buf;
} reader_args;
typedef struct adder_args {
pthread_mutex_t* lock;
pthread_cond_t* cond;
queue* read_add_buf;
entry** add_reduce_buf;
} adder_args;
void* map_adder(void* args);
void* map_reader(void* args);
int reduce(entry** dicts, int n);
int main(int argc, char** argv);
int is_word_char(char c);
void pthread_mutex_lock_safe(pthread_mutex_t *mutex);