diff --git a/A2/fauxgrep b/A2/fauxgrep new file mode 100755 index 0000000..0a44b0b Binary files /dev/null and b/A2/fauxgrep differ diff --git a/A2/fauxgrep-mt b/A2/fauxgrep-mt index 9e6d729..b55b683 100755 Binary files a/A2/fauxgrep-mt and b/A2/fauxgrep-mt differ diff --git a/A2/fauxgrep-mt.c b/A2/fauxgrep-mt.c index aff6241..02a80d7 100644 --- a/A2/fauxgrep-mt.c +++ b/A2/fauxgrep-mt.c @@ -35,7 +35,7 @@ int fauxgrep_file(char const *needle, char const *path) { while (getline(&line, &linelen, f) != -1) { if (strstr(line, needle) != NULL) { - printf("%s:%d: %s", path, lineno, line); + //printf("%s:%d: %s", path, lineno, line); } lineno++; @@ -48,7 +48,6 @@ int fauxgrep_file(char const *needle, char const *path) { } void* fauxgrep_thread(void* arg) { - //printf("thread initialized\n"); char* needle = arg; char const* path; while (job_queue_pop(&q, (void**) &path) == 0) { @@ -118,6 +117,7 @@ int main(int argc, char * const *argv) { case FTS_D: break; case FTS_F: + //printf("%s\n", p->fts_accpath); job_queue_push(&q, strdup(p->fts_path)); break; default: @@ -125,9 +125,12 @@ int main(int argc, char * const *argv) { } } + //printf("done pusing jobs\n"); + fts_close(ftsp); job_queue_destroy(&q); + //printf("done destroying jobqueue\n"); for (int i = 0 ; i < num_threads ; i++) { pthread_join(threads[i], NULL); diff --git a/A2/fhistogram b/A2/fhistogram new file mode 100755 index 0000000..e3f4ae9 Binary files /dev/null and b/A2/fhistogram differ diff --git a/A2/job_queue.c b/A2/job_queue.c index 58435d4..e2b1bd1 100644 --- a/A2/job_queue.c +++ b/A2/job_queue.c @@ -32,6 +32,7 @@ int job_queue_destroy(struct job_queue *job_queue) { free(job_queue->jobs); job_queue->jobs = NULL; + //job_queue = NULL; pthread_mutex_unlock(&queue_push); pthread_mutex_unlock(&queue_pop); @@ -87,7 +88,7 @@ int job_queue_pop(struct job_queue *job_queue, void **data) { } if (job_queue->size == job_queue->capacity - 1) { - pthread_mutex_unlock(&queue_pop); + pthread_mutex_unlock(&queue_push); } //printf("pop end\n"); diff --git a/A2/testfile b/A2/testfile index 80374c6..bd0c8b5 100755 Binary files a/A2/testfile and b/A2/testfile differ