diff options
Diffstat (limited to 'pa6_threaded_resolver/multi-lookup.h')
-rw-r--r-- | pa6_threaded_resolver/multi-lookup.h | 55 |
1 files changed, 23 insertions, 32 deletions
diff --git a/pa6_threaded_resolver/multi-lookup.h b/pa6_threaded_resolver/multi-lookup.h index 41e74d5..9433da9 100644 --- a/pa6_threaded_resolver/multi-lookup.h +++ b/pa6_threaded_resolver/multi-lookup.h @@ -2,43 +2,34 @@ // CSCI3753 SP24 // PA6 Threaded Resolver #include "array.h" -#include "util.h" -#include <pthread.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/syscall.h> -#include <sys/time.h> -#include <unistd.h> -#define ARRAY_SIZE 8 +#pragma once + #define MAX_INPUT_FILES 100 #define MAX_REQUESTER_THREADS 10 #define MAX_RESOLVER_THREADS 10 -#define MAX_NAME_LENGTH 16 +#define MAX_NAME_LENGTH 17 #define MAX_IP_LENGTH INET6_ADDRSTRLEN -#define ELAPSED_SECONDS(a, b) \ - ((double)(b.tv_usec - a.tv_usec) / 1000000 + (double)(b.tv_sec - a.tv_sec)) -void *request(void *data); -void *resolve(void *data); +struct requester_data { + char *req_log; + char **input_filenames; + array *stack; + int *file_idx; + int total_files; + int res_thread_cnt; + pthread_mutex_t file_idx_lock; + pthread_mutex_t req_log_lock; +}; -typedef struct { - FILE *req_log; - queue *file_names; - queue *buffer; - pthread_mutex_t *m; - pthread_cond_t *c_req; - pthread_cond_t *c_res; - pthread_mutex_t *input_lock; - pthread_mutex_t *req_log_lock; -} request_data; +struct resolver_data { + char *res_log; + array *stack; + int res_thread_cnt; + pthread_mutex_t term_lock; + pthread_mutex_t res_log_lock; +}; -typedef struct { - FILE *res_log; - queue *buffer; - pthread_mutex_t *m; - pthread_cond_t *c_req; - pthread_cond_t *c_res; - pthread_mutex_t *res_log_lock; - bool *req_done; -} resolve_data; +void *requester(void *a); +void *resolver(void *a); +double get_time_sec(void); |