:spakles:
This commit is contained in:
BIN
A2/fauxgrep
Executable file
BIN
A2/fauxgrep
Executable file
Binary file not shown.
BIN
A2/fauxgrep-mt
BIN
A2/fauxgrep-mt
Binary file not shown.
@ -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);
|
||||
|
BIN
A2/fhistogram
Executable file
BIN
A2/fhistogram
Executable file
Binary file not shown.
@ -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");
|
||||
|
BIN
A2/testfile
BIN
A2/testfile
Binary file not shown.
Reference in New Issue
Block a user